felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1626951 - in /felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples: ./ src/org/apache/felix/dependencymanager/samples/device/ src/org/apache/felix/dependencymanager/samples/device/impl/
Date Tue, 23 Sep 2014 06:40:27 GMT
Author: pderop
Date: Tue Sep 23 06:40:26 2014
New Revision: 1626951

URL: http://svn.apache.org/r1626951
Log:
improved the "device" test, where the adapter is now providing a "DeviceAccess" service

Added:
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceAccess.java
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/Activator.java
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceAccessConsumer.java
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceAccessImpl.java
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceImpl.java
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceParameterImpl.java
Removed:
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/Activator.java
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceConsumer.java
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceImpl.java
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceParameterImpl.java
Modified:
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/device.bnd

Modified: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/device.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/device.bnd?rev=1626951&r1=1626950&r2=1626951&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/device.bnd
(original)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/device.bnd
Tue Sep 23 06:40:26 2014
@@ -1,3 +1,4 @@
-Bundle-Activator: org.apache.felix.dependencymanager.samples.device.Activator
+Bundle-Activator: org.apache.felix.dependencymanager.samples.device.impl.Activator
 Private-Package:  \
-	org.apache.felix.dependencymanager.samples.device
\ No newline at end of file
+	org.apache.felix.dependencymanager.samples.device,\
+	org.apache.felix.dependencymanager.samples.device.impl
\ No newline at end of file

Added: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceAccess.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceAccess.java?rev=1626951&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceAccess.java
(added)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceAccess.java
Tue Sep 23 06:40:26 2014
@@ -0,0 +1,6 @@
+package org.apache.felix.dependencymanager.samples.device;
+
+public interface DeviceAccess {
+    Device getDevice();
+    DeviceParameter getDeviceParameter();
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/Activator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/Activator.java?rev=1626951&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/Activator.java
(added)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/Activator.java
Tue Sep 23 06:40:26 2014
@@ -0,0 +1,45 @@
+package org.apache.felix.dependencymanager.samples.device.impl;
+
+import java.util.Hashtable;
+
+import org.apache.felix.dependencymanager.samples.device.Device;
+import org.apache.felix.dependencymanager.samples.device.DeviceAccess;
+import org.apache.felix.dependencymanager.samples.device.DeviceParameter;
+import org.apache.felix.dm.DependencyActivatorBase;
+import org.apache.felix.dm.DependencyManager;
+import org.osgi.framework.BundleContext;
+
+/**
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class Activator extends DependencyActivatorBase {
+    @Override
+    public void init(BundleContext context, DependencyManager dm) throws Exception { 
+        createDeviceAndParameter(dm, 1);
+        createDeviceAndParameter(dm, 2);
+
+        dm.add(createAdapterService(Device.class, null)
+            .setImplementation(DeviceAccessImpl.class)
+            .setInterface(DeviceAccess.class.getName(), null));
+        
+        dm.add(createComponent()
+            .setImplementation(DeviceAccessConsumer.class)
+            .add(createServiceDependency()
+                .setService(DeviceAccess.class)
+                .setRequired(true)
+                .setCallbacks("add", null)));
+    }
+    
+    private void createDeviceAndParameter(DependencyManager dm, int id) {
+        Hashtable<String, Object> props = new Hashtable<>();
+        props.put("device.id", id);
+        dm.add(createComponent()
+            .setImplementation(new DeviceImpl(id)).setInterface(Device.class.getName(), props));
+           
+        props = new Hashtable<>();
+        props.put("device.id", id);
+        dm.add(createComponent()
+            .setImplementation(new DeviceParameterImpl(id)).setInterface(DeviceParameter.class.getName(),
props));        
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceAccessConsumer.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceAccessConsumer.java?rev=1626951&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceAccessConsumer.java
(added)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceAccessConsumer.java
Tue Sep 23 06:40:26 2014
@@ -0,0 +1,13 @@
+package org.apache.felix.dependencymanager.samples.device.impl;
+
+import java.util.Map;
+
+import org.apache.felix.dependencymanager.samples.device.DeviceAccess;
+
+public class DeviceAccessConsumer {
+    void add(Map<String, Object> props, DeviceAccess deviceAccess) {
+        System.out.println("Handling device access: id=" + props.get("device.id") 
+            + ", device=" + deviceAccess.getDevice() 
+            + ", device parameter=" + deviceAccess.getDeviceParameter());
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceAccessImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceAccessImpl.java?rev=1626951&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceAccessImpl.java
(added)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceAccessImpl.java
Tue Sep 23 06:40:26 2014
@@ -0,0 +1,29 @@
+package org.apache.felix.dependencymanager.samples.device.impl;
+
+import org.apache.felix.dependencymanager.samples.device.Device;
+import org.apache.felix.dependencymanager.samples.device.DeviceAccess;
+import org.apache.felix.dependencymanager.samples.device.DeviceParameter;
+import org.apache.felix.dm.Component;
+import org.apache.felix.dm.DependencyManager;
+
+public class DeviceAccessImpl implements DeviceAccess {
+    volatile Device device;
+    volatile DeviceParameter deviceParameter;
+
+    void init(Component c) {
+        DependencyManager dm = c.getDependencyManager();
+        c.add(dm.createServiceDependency()
+            .setService(DeviceParameter.class, "(device.id=" + device.getDeviceId() + ")")
+            .setRequired(true));
+    }
+
+    @Override
+    public Device getDevice() {
+        return device;
+    }
+
+    @Override
+    public DeviceParameter getDeviceParameter() {
+        return deviceParameter;    
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceImpl.java?rev=1626951&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceImpl.java
(added)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceImpl.java
Tue Sep 23 06:40:26 2014
@@ -0,0 +1,16 @@
+package org.apache.felix.dependencymanager.samples.device.impl;
+
+import org.apache.felix.dependencymanager.samples.device.Device;
+
+public class DeviceImpl implements Device {
+    final int id;
+    
+    DeviceImpl(int id) {
+        this.id = id;
+    }
+    
+    @Override
+    public int getDeviceId() {
+        return id;
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceParameterImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceParameterImpl.java?rev=1626951&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceParameterImpl.java
(added)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/device/impl/DeviceParameterImpl.java
Tue Sep 23 06:40:26 2014
@@ -0,0 +1,16 @@
+package org.apache.felix.dependencymanager.samples.device.impl;
+
+import org.apache.felix.dependencymanager.samples.device.DeviceParameter;
+
+public class DeviceParameterImpl implements DeviceParameter {
+    final int id;
+    
+    DeviceParameterImpl(int id) {
+        this.id = id;
+    }
+
+    @Override
+    public int getDeviceId() {
+        return id;
+    }
+}



Mime
View raw message