felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1727896 - in /felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples: ./ src/org/apache/felix/dm/lambda/samples/hello/
Date Mon, 01 Feb 2016 07:39:59 GMT
Author: pderop
Date: Mon Feb  1 07:39:59 2016
New Revision: 1727896

URL: http://svn.apache.org/viewvc?rev=1727896&view=rev
Log:
Simplified hello sample.

Modified:
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/hello.bndrun
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Activator.java
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceConsumer.java
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceProviderImpl.java

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/hello.bndrun
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/hello.bndrun?rev=1727896&r1=1727895&r2=1727896&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/hello.bndrun
(original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/hello.bndrun
Mon Feb  1 07:39:59 2016
@@ -14,6 +14,7 @@
 	org.apache.felix.dependencymanager.lambda.samples.hello;version=latest,\
 	org.apache.felix.dependencymanager;version=4.2.0,\
 	org.apache.felix.dependencymanager.shell;version=4.0.3,\
-	org.apache.felix.dependencymanager.lambda;version=latest
+	org.apache.felix.dependencymanager.lambda;version=latest,\
+	org.apache.felix.eventadmin;version=1.4.4
 
 	
\ No newline at end of file

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Activator.java?rev=1727896&r1=1727895&r2=1727896&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Activator.java
(original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Activator.java
Mon Feb  1 07:39:59 2016
@@ -22,6 +22,7 @@ import static java.lang.System.out;
 
 import org.apache.felix.dm.lambda.DependencyManagerActivator;
 import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.event.EventAdmin;
 import org.osgi.service.log.LogService;
 
 /**
@@ -36,25 +37,17 @@ public class Activator extends Dependenc
         component(comp -> comp
             .impl(ServiceProviderImpl.class)
             .provides(ServiceProvider.class, property1 -> "value1", property2 -> 123)
// property names are deduced from lambda parameter names
-            .start(ServiceProviderImpl::activate)
-            .withSrv(LogService.class, log -> log.cb(ServiceProviderImpl::bind)));
+            .withSrv(LogService.class));
 
-        // Creates a Service Consumer. Notice that if your configuration callback is "updated",
you can 
-        // simply use "withCnf(pid)" instead of explicitely providing the method reference.
+        // Creates a Service Consumer. we depend on LogService, EventAdmin and on our ServiceProvider.
+        // (LogService and EventAdmin are declared in one single method call).
         
         component(comp -> comp
             .impl(ServiceConsumer.class)
-            .withSrv(LogService.class)
+            .withSrv(LogService.class, EventAdmin.class)
             .withSrv(ServiceProvider.class, srv -> srv.filter("(property1=value1)")) 
-            .withCnf(conf -> conf.pid(ServiceConsumer.class).cb(ServiceConsumer::updated)));
 
+            .withCnf(ServiceConsumer.class));  
         
-        // Same as above, but using a shorter form of "withCnf" declaration
-//        component(comp -> comp
-//            .impl(ServiceConsumer.class)
-//            .withSrv(LogService.class)
-//            .withSrv(ServiceProvider.class, srv -> srv.filter("(property1=value1)"))

-//            .withCnf(ServiceConsumer.class));  
-
         // Creates a component that populates some properties in the Configuration Admin.
         component(comp -> comp.impl(Configurator.class).withSrv(ConfigurationAdmin.class));
     }

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceConsumer.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceConsumer.java?rev=1727896&r1=1727895&r2=1727896&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceConsumer.java
(original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceConsumer.java
Mon Feb  1 07:39:59 2016
@@ -20,6 +20,7 @@ package org.apache.felix.dm.lambda.sampl
 
 import java.util.Dictionary;
 
+import org.osgi.service.event.EventAdmin;
 import org.osgi.service.log.LogService;
 
 /**
@@ -30,10 +31,9 @@ import org.osgi.service.log.LogService;
 public class ServiceConsumer {
     volatile ServiceProvider service;
     volatile LogService log;
-    Dictionary<?, ?> conf;
+    volatile EventAdmin eventAdmin;
 
     public void updated(Dictionary<String, Object> conf) {
-        this.conf = conf;
     }
     
     public void start() {

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceProviderImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceProviderImpl.java?rev=1727896&r1=1727895&r2=1727896&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceProviderImpl.java
(original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceProviderImpl.java
Mon Feb  1 07:39:59 2016
@@ -28,12 +28,10 @@ import org.osgi.service.log.LogService;
 public class ServiceProviderImpl implements ServiceProvider {
     volatile LogService log;
 
-    void bind(LogService log) { this.log = log; }
-    
-    void activate() {
-        log.log(LogService.LOG_INFO, "ServiceProviderImpl.start");
+    void start() {
+        // default lifecycle start calback (all required dependencies have been injected
when start is called.        
     }
-
+    
     @Override
     public void hello() {
         log.log(LogService.LOG_INFO, "ServiceProviderImpl.hello");



Mime
View raw message