This is an automated email from the ASF dual-hosted git repository.

cgarcia pushed a commit to branch feature/merlot
in repository https://gitbox.apache.org/repos/asf/plc4x-extras.git


The following commit(s) were added to refs/heads/feature/merlot by this push:
     new d9cfdbe  Fix ManagedService for IoTDB. DataSourceProvider
d9cfdbe is described below

commit d9cfdbe2d49e109f0ade447a327b22f11d90bc13
Author: César García <[email protected]>
AuthorDate: Fri Mar 20 19:30:52 2026 -0400

    Fix ManagedService for IoTDB. DataSourceProvider
---
 .../merlot/archiver/impl/MerlotHtcRTImpl.java      | 44 ++++++++++++--------
 .../OSGI-INF/blueprint/archiver-service.xml        | 48 +++++++++++++++-------
 2 files changed, 60 insertions(+), 32 deletions(-)

diff --git 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotHtcRTImpl.java
 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotHtcRTImpl.java
index 76e1377..8f10ddd 100644
--- 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotHtcRTImpl.java
+++ 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotHtcRTImpl.java
@@ -29,6 +29,7 @@ import org.epics.gpclient.GPClientConfiguration;
 import org.epics.gpclient.GPClientInstance;
 import org.epics.gpclient.PV;
 import org.epics.gpclient.PVReader;
+import org.epics.gpclient.datasource.CompositeDataSource;
 import org.epics.gpclient.datasource.DataSourceProvider;
 import org.epics.vtype.VType;
 import org.slf4j.LoggerFactory;
@@ -42,6 +43,8 @@ public class MerlotHtcRTImpl implements MerlotHtc{
     
     private static final Pattern SIM_PATTERN = 
Pattern.compile("(^ACK:)((,{0,1}(16#[0-9a-fA-F]{8})(;([0-9a-fA-F]{2})))+)");
     
+    CompositeDataSource cds = new  CompositeDataSource();
+    
     private Map<String, PVReader<VType>> readerPvs = new 
ConcurrentHashMap<>();      
     private Map<String, CircularFifoQueue<Pair<LocalDateTime, PV>>> pvs = new 
ConcurrentHashMap<>();    
     
@@ -55,27 +58,11 @@ public class MerlotHtcRTImpl implements MerlotHtc{
 
         gpClient = new 
GPClientConfiguration().defaultMaxRate(Duration.ofMillis(50))
                 
.notificationExecutor(org.epics.util.concurrent.Executors.localThread())
-                .dataSource(DataSourceProvider.createDataSource())
+                .dataSource(cds)
                 
.dataProcessingThreadPool(java.util.concurrent.Executors.newScheduledThreadPool(
                         Math.max(1, Runtime.getRuntime().availableProcessors() 
- 1),
                         
org.epics.util.concurrent.Executors.namedPool("MerlotHtcRT-Worker ")))
-                .build(); 
-        
-        pv1 = gpClient.read("sim://noise")
-                .addReadListener((event, p) ->{
-                    System.out.println(event + " <1>  " + p.isConnected() + " 
" + p.getValue());
-                        
-                })
-                .start(); 
-        
-        pv2 = gpClient.read("sim://noise")
-                .addReadListener((event, p) ->{
-                    System.out.println(event + " <2> " + p.isConnected() + " " 
+ p.getValue());
-                        
-                })
-                .start();          
-        
-        
+                .build();                           
     }
 
     @Override
@@ -109,4 +96,25 @@ public class MerlotHtcRTImpl implements MerlotHtc{
         return null;
     }
     
+    public void bindDataSourceProvider(DataSourceProvider dsp) {
+        System.out.println("Encontro un servicio: " + dsp.getName());
+        cds.putDataSource(dsp);
+        if ("sim".equalsIgnoreCase(dsp.getName())){
+            pv1 = gpClient.read("sim://noise")
+                    .addReadListener((event, p) ->{
+                        System.out.println(event + " <1>  " + p.isConnected() 
+ " " + p.getValue());
+
+                    })
+                    .start(); 
+
+            pv2 = gpClient.read("sim://noise")
+                    .addReadListener((event, p) ->{
+                        System.out.println(event + " <2> " + p.isConnected() + 
" " + p.getValue());
+
+                    })
+                    .start();                  
+
+        }
+    }
+    
 }
diff --git 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/resources/OSGI-INF/blueprint/archiver-service.xml
 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/resources/OSGI-INF/blueprint/archiver-service.xml
index 5a50030..8951e96 100644
--- 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/resources/OSGI-INF/blueprint/archiver-service.xml
+++ 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/resources/OSGI-INF/blueprint/archiver-service.xml
@@ -15,11 +15,12 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
-           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-           xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
-               http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"; 
-           default-activation="eager">
+<blueprint  xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+            xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
+               http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd";
+            
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"; 
+            default-activation="eager">
 
     
     <reference
@@ -29,14 +30,7 @@
     <reference
         id="refEventAdminService"
         interface="org.osgi.service.event.EventAdmin" availability="mandatory" 
timeout="1200"/>  
-    
-<!--    <reference
-        id="refDataSource"
-        interface="org.epics.gpclient.datasource.DataSourceProvider" 
-        
filter="(.org.apache.aries.spifly.provider.implclass=org.epics.gpclient.datasource.sim.SimulationDataSourceProvider)"
-        availability="mandatory" 
-        timeout="5000"/>       -->
-    
+        
     <bean id="MerlotGPClientBean" 
             class="org.apache.plc4x.merlot.archiver.impl.MerlotGPClientImpl"
             init-method="init"  
@@ -101,7 +95,33 @@
             destroy-method="destroy"                           
             scope="singleton"
             activation="eager">
-    </bean>                    
+    </bean>       
+    
+    <!--
+        Why is this happening?
+        Standard OSGi Behavior: OSGi prefers to interact via interfaces
+        to keep bundles decoupled.
+        The "Class" Problem: The 
+        org.epics.gpclient.datasource.DataSourceProvider
+        is likely a class (or contains non-interface elements) rather than a 
+        pure Java interface.
+        The Proxy: Because Blueprint creates a "proxy" object to handle 
+        the dynamic nature of services (where services can come and go), 
+        it needs to know if it's allowed to subclass that provider to 
+        create the proxy.
+        Make sure you have the Aries Blueprint extension namespace declared 
+        at the top of your XML file, or the ext:proxy-method attribute will be 
+        ignored or cause a validation error:        
+        
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0";        
    
+    -->    
+    <reference-list
+        id="refDataSourceProvider"
+        interface="org.epics.gpclient.datasource.DataSourceProvider"
+        ext:proxy-method="classes">
+        <reference-listener
+            bind-method="bindDataSourceProvider"
+            ref="MerlotHtcRTBean"/>    
+    </reference-list>
     
     <service ref="MerlotGPClientBean" auto-export="interfaces">       
     </service>                                      

Reply via email to