felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1727410 - in /felix/sandbox/pderop/dependencymanager-lambda: org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/ org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencyman...
Date Thu, 28 Jan 2016 17:23:30 GMT
Author: pderop
Date: Thu Jan 28 17:23:30 2016
New Revision: 1727410

URL: http://svn.apache.org/viewvc?rev=1727410&view=rev
Log:
Reworked component lifecycle callbacks and removed the ComponentCallback enum.
Aspects and Adapters can now define callback methods using aspectCb() and adapterCb() methods, which allows to
use builder for configuring callbacks.

Removed:
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentCallback.java
Modified:
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterNoAutoConfigIfInstanceCallbackIsUsed.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithCallbackInstanceTest.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithModifiedInstanceBoundDependencyTest.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithPropagationTest.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithoutPropagationTest.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AspectWithCallbacksServiceDependencyTest.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AspectWithPropagationTest.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/MultipleExtraDependencyTest.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/MultipleExtraDependencyTest2.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/compositefactory/Activator.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/factory/Activator.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/future/README
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/hello/Activator.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/rx/observable/ObservableComponent.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAdapterBuilder.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAspectBuilder.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/AdapterBase.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceAdapterBuilderImpl.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceAspectBuilderImpl.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceCallbacksBuilderImpl.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceDependencyBuilderImpl.java

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterNoAutoConfigIfInstanceCallbackIsUsed.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterNoAutoConfigIfInstanceCallbackIsUsed.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterNoAutoConfigIfInstanceCallbackIsUsed.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterNoAutoConfigIfInstanceCallbackIsUsed.java Thu Jan 28 17:23:30 2016
@@ -40,7 +40,7 @@ public class AdapterNoAutoConfigIfInstan
         
         // Declare S1 adapter
         S1AdapterCallback s1AdapterCB = new S1AdapterCallback();
-        adapter(m, S1.class, a -> a.impl(S1Adapter.class).cbi(s1AdapterCB, "set"));
+        adapter(m, S1.class, a -> a.impl(S1Adapter.class).adapterCb(builder->builder.cbi(s1AdapterCB, "set")));
         
         // At this point, the s1AdapterCB.set(S1 s1) method should be called, and s1Adapter.start() method should then be called.
         // but s1 should not be injected on s1Adapter class fields.
@@ -58,7 +58,7 @@ public class AdapterNoAutoConfigIfInstan
         
         // Declare S1 adapter
         S1AdapterCallback s1AdapterCB = new S1AdapterCallback();
-        adapter(m, S1.class, a -> a.impl(S1Adapter.class).cbi(s1AdapterCB::set));
+        adapter(m, S1.class, a -> a.impl(S1Adapter.class).adapterCb(builder->builder.cbi(s1AdapterCB::set)));
         
         // At this point, the s1AdapterCB.set(S1 s1) method should be called, and s1Adapter.start() method should then be called.
         // but s1 should not be injected on s1Adapter class fields.

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithCallbackInstanceTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithCallbackInstanceTest.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithCallbackInstanceTest.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithCallbackInstanceTest.java Thu Jan 28 17:23:30 2016
@@ -47,7 +47,7 @@ public class AdapterWithCallbackInstance
         Component adapter = adapter(m, OriginalService.class)
             .provides(AdaptedService.class).impl(new ServiceAdapter(e)).propagate(true)
             .autoConfig("m_originalService")
-            .cbi(callbackInstance, "set", "changed", "unset")
+            .adapterCb(builder->builder.cbi(callbackInstance, "set", "changed", "unset"))
             .build();
        
         // add the provider and the adapter
@@ -89,7 +89,7 @@ public class AdapterWithCallbackInstance
             .provides(AdaptedService.class).impl(new ServiceAdapter(e))
             .autoAdd(false).propagate(true)
             .autoConfig("m_originalService")
-            .cbi(callbackInstance::set, callbackInstance::changed, callbackInstance::unset));
+            .adapterCb(builder->builder.cbi(callbackInstance::set, callbackInstance::changed, callbackInstance::unset)));
        
         // add the provider and the adapter
         m.add(provider);

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithModifiedInstanceBoundDependencyTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithModifiedInstanceBoundDependencyTest.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithModifiedInstanceBoundDependencyTest.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithModifiedInstanceBoundDependencyTest.java Thu Jan 28 17:23:30 2016
@@ -116,7 +116,7 @@ public class AdapterWithModifiedInstance
         Ensure e = new Ensure();
 
         Component a = component(m).impl(new AImpl(e)).provides(A.class).properties(foo -> "bar").build();
-        Component b = adapter(m, A.class).cb("addA", "changeA", "removeA").provides(B.class).impl(new BImpl(e)).build();
+        Component b = adapter(m, A.class).provides(B.class).impl(new BImpl(e)).adapterCb(builder->builder.cb("addA", "changeA", "removeA")).build();
         Component c = component(m).impl(new CImpl()).provides(C.class).withSrv(A.class, "(foo=bar)").build();
                       
         m.add(a);
@@ -144,7 +144,8 @@ public class AdapterWithModifiedInstance
         Ensure e = new Ensure();
 
         Component a = component(m).impl(new AImpl(e)).provides(A.class).properties(foo -> "bar").build();        
-        Component b = adapter(m, A.class).impl(new BImpl(e)).provides(B.class).cb(BImpl::addA, BImpl::changeA, BImpl::removeA).build();        
+        Component b = adapter(m, A.class).impl(new BImpl(e)).provides(B.class)
+            .adapterCb(builder->builder.cb(BImpl::addA, BImpl::changeA, BImpl::removeA)).build();        
         Component c = component(m).impl(new CImpl()).provides(C.class).withSrv(A.class, s -> s.filter("(foo=bar)")).build();
                       
         m.add(a);

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithPropagationTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithPropagationTest.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithPropagationTest.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithPropagationTest.java Thu Jan 28 17:23:30 2016
@@ -102,7 +102,7 @@ public class AdapterWithPropagationTest
         Ensure e = new Ensure(); 
         
         Component s1 = component(m).impl(new S1Impl(e)).provides(S1.class).properties(p1 -> "v1", p2 -> "v2overriden").build();
-        Component s1Adapter = adapter(m, S1.class).cb("add", "change", null).impl(new S1Adapter(e)).provides(S2.class).properties(p2 -> "v2").build();   
+        Component s1Adapter = adapter(m, S1.class).adapterCb(builder->builder.cb("add", "change", null)).impl(new S1Adapter(e)).provides(S2.class).properties(p2 -> "v2").build();   
         Component s3 = component(m).impl(new S3(e)).withSrv(S2.class, s -> s.cb("add", "change", null)).build();
                                           
         m.add(s1);

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithoutPropagationTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithoutPropagationTest.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithoutPropagationTest.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AdapterWithoutPropagationTest.java Thu Jan 28 17:23:30 2016
@@ -45,7 +45,7 @@ public class AdapterWithoutPropagationTe
 
         // The Adapter will see the "foo=bar" property from the adaptee
         Component adapter = adapter(m, OriginalService.class)
-            .propagate(false).cb("set", "change", null).provides(AdaptedService.class).impl(new ServiceAdapter(e)).build();
+            .propagate(false).adapterCb(builder->builder.cb("set", "change", null)).provides(AdaptedService.class).impl(new ServiceAdapter(e)).build();
 
         // The consumer depends on the AdaptedService, but won't see foo=bar property from the adaptee 
         Component consumer = component(m) 
@@ -80,7 +80,7 @@ public class AdapterWithoutPropagationTe
 
         // The Adapter will see the "foo=bar" property from the adaptee
         ServiceAdapter saimpl = new ServiceAdapter(e);
-        Component adapter = adapter(m, OriginalService.class).propagate(false).impl(saimpl).provides(AdaptedService.class).cbi(saimpl::set, saimpl::change, null).build();           
+        Component adapter = adapter(m, OriginalService.class).propagate(false).impl(saimpl).provides(AdaptedService.class).adapterCb(builder->builder.cbi(saimpl::set, saimpl::change, null)).build();           
 
         // The consumer depends on the AdaptedService, but won't see foo=bar property from the adaptee 
         ServiceConsumer scimpl = new ServiceConsumer(e);

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AspectWithCallbacksServiceDependencyTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AspectWithCallbacksServiceDependencyTest.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AspectWithCallbacksServiceDependencyTest.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AspectWithCallbacksServiceDependencyTest.java Thu Jan 28 17:23:30 2016
@@ -36,7 +36,9 @@ public class AspectWithCallbacksServiceD
         // create a service provider and consumer
         Component sp = component(m).impl(new ServiceProvider(e)).provides(ServiceInterface.class.getName()).build();
         Component sc = component(m).impl(new ServiceConsumer(e)).withSrv(ServiceInterface.class, s->s.cb("add", "remove")).build();
-        Component asp = aspect(m, ServiceInterface.class).rank(100).cb("add", null, "remove", "swap").impl(ServiceProviderAspect.class).build();
+        Component asp = aspect(m, ServiceInterface.class)
+            .rank(100)
+            .aspectCb(builder -> builder.cb("add", null, "remove", "swap")).impl(ServiceProviderAspect.class).build();
         		
         m.add(sp);
         m.add(sc);
@@ -58,7 +60,7 @@ public class AspectWithCallbacksServiceD
         Component sc = component(m).impl(new ServiceConsumer(e)).withSrv(ServiceInterface.class, s->s.cb(ServiceConsumer::add, ServiceConsumer::remove)).build();            
         Component asp = aspect(m, ServiceInterface.class)
             .impl(ServiceProviderAspect.class).rank(100)
-            .cb(ServiceProviderAspect::add, ServiceProviderAspect::remove).sw(ServiceProviderAspect::swap)
+            .aspectCb(builder->builder.cb(ServiceProviderAspect::add, ServiceProviderAspect::remove).sw(ServiceProviderAspect::swap))
             .build();
                 
         m.add(sp);
@@ -84,7 +86,7 @@ public class AspectWithCallbacksServiceD
         ServiceProviderAspectCallbackInstance aspectCb = new ServiceProviderAspectCallbackInstance(providerAspect);
         Component asp = aspect(m, ServiceInterface.class)
             .rank(100).impl(providerAspect)
-            .cbi(aspectCb::add, aspectCb::remove).swi(aspectCb::swap)
+            .aspectCb(builder->builder.cbi(aspectCb::add, aspectCb::remove).swi(aspectCb::swap))
             .build();
             
         m.add(sp);

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AspectWithPropagationTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AspectWithPropagationTest.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AspectWithPropagationTest.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/AspectWithPropagationTest.java Thu Jan 28 17:23:30 2016
@@ -156,7 +156,10 @@ public class AspectWithPropagationTest e
         // Create some "S" aspects
         Component[] aspects = new Component[ASPECTS];
         for (int rank = 1; rank <= ASPECTS; rank ++) {
-            aspects[rank-1] = aspect(m, S.class).rank(rank).cb("add", "change", "remove", "swap").impl(new A("A" + rank, rank)).build();
+            aspects[rank-1] = aspect(m, S.class).rank(rank)
+                .impl(new A("A" + rank, rank))
+                .aspectCb(builder->builder.cb("add", "change", "remove", "swap"))
+                .build();
             props = new Hashtable();
             props.put("a" + rank, "v" + rank);
             aspects[rank-1].setServiceProperties(props);
@@ -354,14 +357,18 @@ public class AspectWithPropagationTest e
         // Create some "S" aspects
         Component[] aspects = new Component[ASPECTS];
         for (int rank = 1; rank <= ASPECTS; rank ++) {
-            aspects[rank-1] = aspect(m, S.class).rank(rank).cb("add", "change", "remove", "swap").impl(new A("A" + rank, rank)).build();
+            aspects[rank-1] = aspect(m, S.class)
+                .rank(rank).impl(new A("A" + rank, rank))
+                .aspectCb(builder->builder.cb("add", "change", "remove", "swap")).build();
             props = new Hashtable();
             props.put("a" + rank, "v" + rank);
             aspects[rank-1].setServiceProperties(props);
         } 
         
         // Create S2 adapter (which adapts S1 to S2 interface)
-        Component adapter = adapter(m, S.class).cb("add", "change", "remove", "swap").provides(S2.class).impl(new S2Impl()).build();
+        Component adapter = adapter(m, S.class)
+            .adapterCb(build->build.cb("add", "change", "remove", "swap"))
+            .provides(S2.class).impl(new S2Impl()).build();
         
         // Create Client2, which depends on "S2" service.
         Client2 client2Impl;

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/MultipleExtraDependencyTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/MultipleExtraDependencyTest.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/MultipleExtraDependencyTest.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/MultipleExtraDependencyTest.java Thu Jan 28 17:23:30 2016
@@ -18,8 +18,6 @@
  */
 package org.apache.felix.dm.builder.lambda.itest;
 
-import static org.apache.felix.dm.lambda.ComponentCallback.START;
-import static org.apache.felix.dm.lambda.ComponentCallback.STOP;
 import static org.apache.felix.dm.lambda.DependencyActivatorBase.component;
 
 import org.apache.felix.dm.Component;
@@ -47,14 +45,14 @@ public class MultipleExtraDependencyTest
         Component sp = component(m)
               .impl(ServiceProvider.class)
               .provides(ServiceInterface.class, foo -> "bar")
-              .cb(START, "start").cb(STOP, "stop")
+              .start("start").stop("stop")
               .withSrv(Sequencer.class, srv->srv.autoConfig("m_sequencer"))
               .withSrv(ServiceProvider2.class, srv->srv.cb("bind", "unbind"))
               .build();
         
         Component sc = component(m)
               .impl(ServiceConsumer.class)
-              .cb(START, "start").cb(STOP, "stop")
+              .start("start").stop("stop")
               .withSrv(Sequencer.class, srv->srv.autoConfig("m_sequencer"))
               .withSrv(ServiceInterface.class, srv->srv.filter("(foo=bar)").autoConfig("m_service"))
               .build();

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/MultipleExtraDependencyTest2.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/MultipleExtraDependencyTest2.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/MultipleExtraDependencyTest2.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/MultipleExtraDependencyTest2.java Thu Jan 28 17:23:30 2016
@@ -18,9 +18,6 @@
  */
 package org.apache.felix.dm.builder.lambda.itest;
 
-import static org.apache.felix.dm.lambda.ComponentCallback.INIT;
-import static org.apache.felix.dm.lambda.ComponentCallback.START;
-import static org.apache.felix.dm.lambda.ComponentCallback.STOP;
 import static org.apache.felix.dm.lambda.DependencyActivatorBase.component;
 
 import org.apache.felix.dm.Component;
@@ -41,18 +38,18 @@ public class MultipleExtraDependencyTest
         Component sp2 = component(m)
             .impl(ServiceProvider2.class)
             .provides(ServiceProvider2.class)
-            .cb(INIT, "init").cb(START, "start").cb(STOP, "stop")
+            .init("init").start("start").stop("stop")
             .composition("getComposition").build();
         
         Component sp = component(m)
             .impl(ServiceProvider.class)
             .provides(ServiceInterface.class, "foo", "bar")                            
-            .cb(INIT, ServiceProvider::init).cb(START, ServiceProvider::start).cb(STOP, ServiceProvider::stop)
+            .init(ServiceProvider::init).start(ServiceProvider::start).stop(ServiceProvider::stop)
             .build();
         
         Component sc = component(m)
             .impl(ServiceConsumer.class)
-            .cb(INIT, "init").cb(START, "start").cb(STOP, "stop")
+            .init("init").start("start").stop("stop")
             .build();
         
         // Provide the Sequencer service to the MultipleAnnotationsTest class.

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/compositefactory/Activator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/compositefactory/Activator.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/compositefactory/Activator.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/compositefactory/Activator.java Thu Jan 28 17:23:30 2016
@@ -19,7 +19,6 @@
 package org.apache.felix.dependencymanager.lambda.samples.compositefactory;
 
 import static java.lang.System.out;
-import static org.apache.felix.dm.lambda.ComponentCallback.START;
 
 import org.apache.felix.dm.lambda.DependencyActivatorBase;
 import org.osgi.service.cm.ConfigurationAdmin;
@@ -52,7 +51,7 @@ public class Activator extends Dependenc
         // before creating the composition of classes.
         component(comp -> comp
             .factory(factory::create, factory::getComposition)
-            .cb(START, ProviderImpl::start) // only call start on ProviderImpl          
+            .start(ProviderImpl::start) // only call start on ProviderImpl          
             .withSrv(LogService.class, srv -> srv.cb(ProviderImpl::bind).cb(ProviderComposite1::bind))
             .withCnf(conf -> conf.pid(ProviderFactory.class).cbi(factory::updated)));
                 

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/factory/Activator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/factory/Activator.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/factory/Activator.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/factory/Activator.java Thu Jan 28 17:23:30 2016
@@ -19,7 +19,6 @@
 package org.apache.felix.dependencymanager.lambda.samples.factory;
 
 import static java.lang.System.out;
-import static org.apache.felix.dm.lambda.ComponentCallback.START;
 
 import org.apache.felix.dm.lambda.DependencyActivatorBase;
 import org.osgi.service.log.LogService;
@@ -35,7 +34,7 @@ public class Activator extends Dependenc
         component(comp -> comp
             .factory(ProviderFactory::new, ProviderFactory::create)       
             .provides(Provider.class)
-            .cb(START, ProviderImpl::start)                      
+            .start(ProviderImpl::start)                      
             .withSrv(LogService.class, log -> log.required().cb(ProviderImpl::set)));
     }
 }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/future/README
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/future/README?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/future/README (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/future/README Thu Jan 28 17:23:30 2016
@@ -1,7 +1,7 @@
 The purpose of this sample is to show an example usage of the new "CompletableFuture" dependency that has been
 added in the dm-lambda library. CompletableFuture java8 class provides functional operations and promotes an asynchronous event-driven model.
 
-But when you go for asynchronous model, then in some situation you have to take care. For instance assuming you want to 
+when you go for asynchronous model, then in some situation you have to take care. For instance assuming you want to 
 initialize a component from the init method using some asynchronous stuff, then the init method may return before the async operations
 have completed; and the component.start() callback may then be called too early. And what about if you want to add dependencies from the init() method 
 and you want to wait for the async operations before adding the dependency ? In this case you would have to block on the CompletableFuture

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/hello/Activator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/hello/Activator.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/hello/Activator.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/hello/Activator.java Thu Jan 28 17:23:30 2016
@@ -19,7 +19,6 @@
 package org.apache.felix.dependencymanager.lambda.samples.hello;
 
 import static java.lang.System.out;
-import static org.apache.felix.dm.lambda.ComponentCallback.START;
 
 import org.apache.felix.dm.lambda.DependencyActivatorBase;
 import org.osgi.service.cm.ConfigurationAdmin;
@@ -36,7 +35,7 @@ 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
-            .cb(START, ServiceProviderImpl::activate)
+            .start(ServiceProviderImpl::activate)
             .withSrv(LogService.class, log -> log.cb(ServiceProviderImpl::bind)));
 
         component(comp -> comp

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/rx/observable/ObservableComponent.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/rx/observable/ObservableComponent.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/rx/observable/ObservableComponent.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/rx/observable/ObservableComponent.java Thu Jan 28 17:23:30 2016
@@ -18,14 +18,12 @@
  */
 package org.apache.felix.dependencymanager.lambda.samples.rx.observable;
 
-import static org.apache.felix.dm.lambda.ComponentCallback.START;
 import static org.apache.felix.dm.lambda.DependencyActivatorBase.component;
 
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.felix.dependencymanager.lambda.samples.rx.observable.ObservableComponent.DocumentViewer;
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
 import org.osgi.service.log.LogService;
@@ -81,7 +79,7 @@ public class ObservableComponent {
 	        publisher.onSubscribe(EmptySubscription.INSTANCE);
 			component(m_dm, builder -> builder
 					.factory(() -> new DocumentViewer(title))
-					.cbi(START, publisher::onNext));
+					.startInstance(publisher::onNext));
 		});
 	}
 }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java Thu Jan 28 17:23:30 2016
@@ -356,74 +356,54 @@ public interface ComponentBuilder<B exte
     <U> B withFuture(CompletableFuture<U> future, Consumer<FutureDependencyBuilder<U>> consumer);
     
     /**
-     * Sets the name of a method used as a component <code>callback</code>. The method, when found from one of the classes that is part of the component 
-     * implementation classes (composition), is invoked as part of the life cycle management of the component. 
-     * The dependency manager will look for a method of this name with the following signatures,
-     * in this order:<p>
-     * <ol>
-     * <li>method(Component component)</li>
-     * <li>method()</li>
-     * </ol>
-     * 
-     * @param callbackType the type of the lifecycle callback (init/start/stop/destroy)
-     * @param callback the callback method to call on the component composition instances.
+     * TODO
      * @return this builder.
      */
-    B cb(ComponentCallback callbackType, String callback);
+    B init(String callback);
+    B start(String callback);
+    B stop(String callback);
+    B destroy(String callback);
     
-    /**
-     * Sets the name of a method used as a component <code>callback instance</code>. The method, when found from a given object instance 
-     * (not necessarily the same as the component implementation), is invoked as part of the life cycle management of the component. 
-     * The dependency manager will look for a method of this name with the following signatures,
-     * in this order:<p>
-     * <ol>
-     * <li>method(Component component)</li>
-     * <li>method()</li>
-     * </ol>
-     * 
-     * @param callbackType the type of the lifecycle callback (init/start/stop/destroy)
-     * @param callbackInstance the object instance where the method will be called.
-     * @param callback the callback method to call on the callbackInstance object.
-     * @return this builder.
-     */
-    B cbi(ComponentCallback callbackType, Object callbackInstance, String callback);
+    B init(Object callbackInstance, String callback);
+    B start(Object callbackInstance, String callback);
+    B stop(Object callbackInstance, String callback);
+    B destroy(Object callbackInstance, String callback);
 
     /**
-     * Sets a method reference on one of the component implementation classes used as callback.
-     * @param callbackType the type of the lifecycle callback (init/start/stop/destroy)
-     * @param callback a method reference on one of the classes that are part of the component instances composition.
-     * The signature for the method does not take any parameters.
+     * TODO
      * @return this builder
      */
-    <U> B cb(ComponentCallback callbackType, CbConsumer<U> callback);
-    
+    <U> B init(CbConsumer<U> callback);
+    <U> B start(CbConsumer<U> callback);
+    <U> B stop(CbConsumer<U> callback);
+    <U> B destroy(CbConsumer<U> callback);
+
     /**
-     * Sets a method reference on one of the component implementation classes used as callback.
-     * @param callbackType the type of the lifecycle callback (init/start/stop/destroy)
-     * @param callback a method reference on one of the classes that are part of the component instances composition.
-     * The signature for the method accepts a single <code>Component</code> parameter.
+     * TODO
      * @return this builder
      */
-    <U> B cb(ComponentCallback callbackType, CbTypeComponent<U> callback);
-    
+    <U> B init(CbTypeComponent<U> callback);
+    <U> B start(CbTypeComponent<U> callback);
+    <U> B stop(CbTypeComponent<U> callback);
+    <U> B destroy(CbTypeComponent<U> callback);
+
     /**
-     * Sets a method reference that is used as component <code>callback instance</code>. The method reference is part of any object instance and is invoked 
-     * as part of the life cycle management of the component. 
-     * @param callbackType the type of the lifecycle callback (init/start/stop/destroy)
-     * @param callback a runnable called when the component lifecycle state is updated.
+     * TODO
      * @return this builder
      */
-    B cbi(ComponentCallback callbackType, Runnable callback);
-    
+    B initInstance(Runnable callback);
+    B startInstance(Runnable callback);
+    B stopInstance(Runnable callback);
+    B destroyInstance(Runnable callback);
+
     /**
-     * Sets a method reference that is used as a component <code>callback instance</code>. The method is part of any object instance and is invoked as part of the life cycle management 
-     * of the component.
-     * @param callbackType the type of the lifecycle callback (init/start/stop/destroy)
-     * @param callback the callback method to call when he component lifecycle state is updated.
-     * The signature for the method accepts a single <code>Component</code> parameter.
+     * TODO
      * @return this builder.
      */
-    B cbi(ComponentCallback callbackType, CbComponent callback);
+    B initInstance(CbComponent callback);
+    B startInstance(CbComponent callback);
+    B stopInstance(CbComponent callback);
+    B destroyInstance(CbComponent callback);
 
     /**
      * Configures OSGi object (BundleContext, Component, etc ...) that will be injected in any field having the same OSGi object type.

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAdapterBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAdapterBuilder.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAdapterBuilder.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAdapterBuilder.java Thu Jan 28 17:23:30 2016
@@ -1,5 +1,7 @@
 package org.apache.felix.dm.lambda;
 
+import java.util.function.Consumer;
+
 /**
  * Defines the interface for a DependencyManager adapter builder.
  * The adapter will be applied to any service that matches the specified interface and filter. For each matching service an adapter will be created 
@@ -17,7 +19,7 @@ package org.apache.felix.dm.lambda;
  * 
  * @param <T> the adaptee service
  */
-public interface ServiceAdapterBuilder<T> extends ComponentBuilder<ServiceAdapterBuilder<T>>, ServiceCallbacksBuilder<T, ServiceAdapterBuilder<T>> {
+public interface ServiceAdapterBuilder<T> extends ComponentBuilder<ServiceAdapterBuilder<T>> {
     /**
      * Specifies the filter used to match a given adapted service.
      * @param adapteeFilter the filter used to match a given adapted service
@@ -50,5 +52,34 @@ public interface ServiceAdapterBuilder<T
      * @param field the field name where the adapted service must be injected to.
      * @return this builder
      */
-    ServiceAdapterBuilder<T> autoConfig(String field);            
+    ServiceAdapterBuilder<T> autoConfig(String field);        
+    
+    /**
+     * Allows to configure the aspect callback method.
+     * @param consumer a block of code that can configure the specific aspect callback to call when injecting the aspect service.
+     * @return this builder
+     */
+    ServiceAdapterBuilder<T> adapterCb(Consumer<ServiceCallbacksBuilder<T, ?>> consumer);
+    
+    /**
+     * Convenient method used to build reflection based callbacks.
+     * TODO add comments
+     * 
+     * @param callbacks
+     * @return
+     */
+    default ServiceAdapterBuilder<T> adapterCb(String ... callbacks) {
+        return adapterCb(builder -> builder.cb(callbacks));
+    }
+    
+    /**
+     * Convenient method used to build reflection based callbacks.
+     * TODO add comments
+     * 
+     * @param callbacks
+     * @return
+     */
+    default ServiceAdapterBuilder<T> adapterCb(Object callbackInstance, String ... callbacks) {
+        return adapterCb(builder -> builder.cbi(callbackInstance, callbacks));
+    }
 }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAspectBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAspectBuilder.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAspectBuilder.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAspectBuilder.java Thu Jan 28 17:23:30 2016
@@ -1,5 +1,7 @@
 package org.apache.felix.dm.lambda;
 
+import java.util.function.Consumer;
+
 /**
  * Defines the interface for a DependencyManager aspect builder.
  * The aspect will be applied to any service that matches the specified interface and filter. For each matching service an aspect will be created based 
@@ -22,7 +24,7 @@ package org.apache.felix.dm.lambda;
  *
  * @param <T> the aspect service
  */
-public interface ServiceAspectBuilder<T> extends ComponentBuilder<ServiceAspectBuilder<T>>, ServiceCallbacksBuilder<T, ServiceAspectBuilder<T>>  {
+public interface ServiceAspectBuilder<T> extends ComponentBuilder<ServiceAspectBuilder<T>>  {
     /**
      * Specifies the aspect service filter. 
      * @param filter
@@ -55,5 +57,34 @@ public interface ServiceAspectBuilder<T>
      * @param field the field name where the aspect service must be injected
      * @return this builder
      */
-    ServiceAspectBuilder<T> autoConfig(String field);      
+    ServiceAspectBuilder<T> autoConfig(String field); 
+    
+    /**
+     * Allows to configure the adapter callback method.
+     * @param consumer a block of code that can configure the specific adapter callback to call when injecting the adapted service.
+     * @return this builder
+     */
+    ServiceAspectBuilder<T> aspectCb(Consumer<ServiceCallbacksBuilder<T, ?>> consumer);
+    
+    /**
+     * Convenient method used to build reflection based callbacks.
+     * TODO add comments
+     * 
+     * @param callbacks
+     * @return
+     */
+    default ServiceAspectBuilder<T> aspectCb(String ... callbacks) {
+        return aspectCb(builder -> builder.cb(callbacks));
+    }
+    
+    /**
+     * Convenient method used to build reflection based callbacks.
+     * TODO add comments
+     * 
+     * @param callbacks
+     * @return
+     */
+    default ServiceAspectBuilder<T> aspectCbi(Object callbackInstance, String ... callbacks) {
+        return aspectCb(builder -> builder.cbi(callbackInstance, callbacks));
+    }
 }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java Thu Jan 28 17:23:30 2016
@@ -105,7 +105,7 @@ import org.apache.felix.dm.lambda.callba
  * 
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
-public interface ServiceCallbacksBuilder<S, B> {
+public interface ServiceCallbacksBuilder<S, B extends ServiceCallbacksBuilder<S, B>> {
     B cb(String ... callbacks);
     B cbi(Object callbackInstance, String ... callbacks);
 

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/AdapterBase.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/AdapterBase.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/AdapterBase.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/AdapterBase.java Thu Jan 28 17:23:30 2016
@@ -8,7 +8,6 @@ import java.util.function.Supplier;
 
 import org.apache.felix.dm.lambda.BundleDependencyBuilder;
 import org.apache.felix.dm.lambda.ComponentBuilder;
-import org.apache.felix.dm.lambda.ComponentCallback;
 import org.apache.felix.dm.lambda.ConfigurationDependencyBuilder;
 import org.apache.felix.dm.lambda.FutureDependencyBuilder;
 import org.apache.felix.dm.lambda.ServiceDependencyBuilder;
@@ -187,37 +186,127 @@ public interface AdapterBase<B extends C
         return (B) this;
     }
     
-    default B cb(ComponentCallback callbackType, String callback) {
-        andThenBuild(compBuilder -> compBuilder.cb(callbackType, callback));
+    default B init(String callback) {
+        andThenBuild(compBuilder -> compBuilder.init(callback));
         return (B) this;
     }
     
-    default B cbi(ComponentCallback callbackType, Object callbackInstance, String callback) {
-        andThenBuild(compBuilder -> compBuilder.cbi(callbackType, callbackInstance, callback));
+    default B start(String callback) {
+        andThenBuild(compBuilder -> compBuilder.start(callback));
         return (B) this;
     }
 
-    default <U> B cb(ComponentCallback callbackType, CbConsumer<U> callback) {
-        andThenBuild(compBuilder -> compBuilder.cb(callbackType, callback));
+    default B stop(String callback) {
+        andThenBuild(compBuilder -> compBuilder.stop(callback));
+        return (B) this;
+    }
+
+    default B destroy(String callback) {
+        andThenBuild(compBuilder -> compBuilder.destroy(callback));
+        return (B) this;
+    }
+    
+    default B init(Object callbackInstance, String callback) {
+        andThenBuild(compBuilder -> compBuilder.init(callbackInstance, callback));
+        return (B) this;
+    }
+    
+    default B start(Object callbackInstance, String callback) {
+        andThenBuild(compBuilder -> compBuilder.start(callbackInstance, callback));
+        return (B) this;
+    }
+
+    default B stop(Object callbackInstance, String callback) {
+        andThenBuild(compBuilder -> compBuilder.stop(callbackInstance, callback));
+        return (B) this;
+    }
+
+    default B destroy(Object callbackInstance, String callback) {
+        andThenBuild(compBuilder -> compBuilder.destroy(callbackInstance, callback));
+        return (B) this;
+    }
+    
+    default <U> B init(CbConsumer<U> callback) {
+        andThenBuild(compBuilder -> compBuilder.init(callback));
+        return (B) this;
+    }
+    
+    default <U> B start(CbConsumer<U> callback) {
+        andThenBuild(compBuilder -> compBuilder.start(callback));
+        return (B) this;
+    }
+
+    default <U> B stop(CbConsumer<U> callback) {
+        andThenBuild(compBuilder -> compBuilder.stop(callback));
+        return (B) this;
+    }
+
+    default <U> B destroy(CbConsumer<U> callback) {
+        andThenBuild(compBuilder -> compBuilder.destroy(callback));
         return (B) this;
     }
         
-    default <U> B cb(ComponentCallback callbackType, CbTypeComponent<U> callback) {
-        andThenBuild(compBuilder -> compBuilder.cb(callbackType, callback));
+    default <U> B init(CbTypeComponent<U> callback) {
+        andThenBuild(compBuilder -> compBuilder.init(callback));
         return (B) this;
     }
         
-    default B cbi(ComponentCallback callbackType, Runnable callback) {
-        andThenBuild(compBuilder -> compBuilder.cbi(callbackType, callback));
+    default <U> B start(CbTypeComponent<U> callback) {
+        andThenBuild(compBuilder -> compBuilder.start(callback));
         return (B) this;
     }
         
-    default B cbi(ComponentCallback callbackType, CbComponent callback) {
-        andThenBuild(compBuilder -> compBuilder.cbi(callbackType, callback));
+    default <U> B stop(CbTypeComponent<U> callback) {
+        andThenBuild(compBuilder -> compBuilder.stop(callback));
+        return (B) this;
+    }
+        
+    default <U> B destroy(CbTypeComponent<U> callback) {
+        andThenBuild(compBuilder -> compBuilder.destroy(callback));
+        return (B) this;
+    }
+        
+    default B initInstance(Runnable callback) {
+        andThenBuild(compBuilder -> compBuilder.initInstance(callback));
+        return (B) this;
+    }
+        
+    default B startInstance(Runnable callback) {
+        andThenBuild(compBuilder -> compBuilder.startInstance(callback));
+        return (B) this;
+    }
+        
+    default B stopInstance(Runnable callback) {
+        andThenBuild(compBuilder -> compBuilder.stopInstance(callback));
+        return (B) this;
+    }
+        
+    default B destroyInstance(Runnable callback) {
+        andThenBuild(compBuilder -> compBuilder.destroyInstance(callback));
+        return (B) this;
+    }
+        
+    default B initInstance(CbComponent callback) {
+        andThenBuild(compBuilder -> compBuilder.initInstance(callback));
+        return (B) this;
+    }
+
+    default B startInstance(CbComponent callback) {
+        andThenBuild(compBuilder -> compBuilder.startInstance(callback));
+        return (B) this;
+    }
+
+    default B stopInstance(CbComponent callback) {
+        andThenBuild(compBuilder -> compBuilder.stopInstance(callback));
+        return (B) this;
+    }
+
+    default B destroyInstance(CbComponent callback) {
+        andThenBuild(compBuilder -> compBuilder.destroyInstance(callback));
         return (B) this;
     }
 
-    default <U> B autoConfig(Class<U> clazz, boolean autoConfig) {
+   default <U> B autoConfig(Class<U> clazz, boolean autoConfig) {
         andThenBuild(compBuilder -> compBuilder.autoConfig(clazz, autoConfig));
         return (B) this;
     }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java Thu Jan 28 17:23:30 2016
@@ -19,7 +19,6 @@ import org.apache.felix.dm.Dependency;
 import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.dm.lambda.BundleDependencyBuilder;
 import org.apache.felix.dm.lambda.ComponentBuilder;
-import org.apache.felix.dm.lambda.ComponentCallback;
 import org.apache.felix.dm.lambda.ConfigurationDependencyBuilder;
 import org.apache.felix.dm.lambda.DependencyBuilder;
 import org.apache.felix.dm.lambda.FutureDependencyBuilder;
@@ -28,6 +27,7 @@ import org.apache.felix.dm.lambda.callba
 import org.apache.felix.dm.lambda.callbacks.CbConsumer;
 import org.apache.felix.dm.lambda.callbacks.CbTypeComponent;
 import org.apache.felix.dm.lambda.callbacks.FluentProperties;
+import static org.apache.felix.dm.lambda.impl.ComponentBuilderImpl.ComponentCallback.*;
 
 public class ComponentBuilderImpl implements ComponentBuilder<ComponentBuilderImpl> {
     private final List<DependencyBuilder<?>> m_dependencyBuilders = new ArrayList<>();
@@ -51,6 +51,8 @@ public class ComponentBuilderImpl implem
     private boolean m_hasFactoryRef;   
     private boolean m_hasFactory;   
     
+    enum ComponentCallback { INIT, START, STOP, DESTROY };
+    
     @FunctionalInterface
     interface MethodRef<I> {
         public void accept(I instance, Component c);
@@ -418,65 +420,182 @@ public class ComponentBuilderImpl implem
         return this;
     }
     
-    public ComponentBuilderImpl cb(ComponentCallback callbackType, String callback) {
+    public ComponentBuilderImpl init(String callback) {
         ensureHasNoLifecycleMethodRefs();
-        switch (callbackType) {
-            case INIT:
-                m_init = callback;
-                break;
-                
-            case START:
-                m_start = callback;
-                break;
-                
-            case STOP:
-                m_stop = callback;
-                break;
-                
-            case DESTROY:
-                m_destroy = callback;
-                break;
-                
-            default:
-                throw new IllegalArgumentException("life method may take at max four parameters (first one for \"init\" callback, second for \"start\", third for \"stop\", and fourth for \"destroy\" callback");
-        }
+        m_init = callback;
         return this;
     }
     
-    public ComponentBuilderImpl cbi(ComponentCallback callbackType, Object callbackInstance, String callback) {
+    public ComponentBuilderImpl start(String callback) {
+        ensureHasNoLifecycleMethodRefs();
+        m_start = callback;
+        return this;
+    }
+
+    public ComponentBuilderImpl stop(String callback) {
+        ensureHasNoLifecycleMethodRefs();
+        m_stop = callback;
+        return this;
+    }
+    
+    public ComponentBuilderImpl destroy(String callback) {
+        ensureHasNoLifecycleMethodRefs();
+        m_destroy = callback;
+        return this;
+    }
+    
+    public ComponentBuilderImpl init(Object callbackInstance, String callback) {
+        m_callbackInstance = callbackInstance;
+        return init(callback);
+    }    
+
+    public ComponentBuilderImpl start(Object callbackInstance, String callback) {
+        m_callbackInstance = callbackInstance;
+        return start(callback);
+    }    
+
+    public ComponentBuilderImpl stop(Object callbackInstance, String callback) {
         m_callbackInstance = callbackInstance;
-        return cb(callbackType, callback);
+        return stop(callback);
     }    
 
+    public ComponentBuilderImpl destroy(Object callbackInstance, String callback) {
+        m_callbackInstance = callbackInstance;
+        return destroy(callback);
+    }    
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <U> ComponentBuilderImpl init(CbConsumer<U> callback) {
+        if (callback != null) {
+            setComponentCallbackRef(INIT, Helpers.getLambdaArgType(callback, 0), (inst, component) -> callback.accept((U) inst));
+        }
+        return this;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <U> ComponentBuilderImpl start(CbConsumer<U> callback) {
+        if (callback != null) {
+            setComponentCallbackRef(START, Helpers.getLambdaArgType(callback, 0), (inst, component) -> callback.accept((U) inst));
+        }
+        return this;
+    }
+
     @SuppressWarnings("unchecked")
     @Override
-    public <U> ComponentBuilderImpl cb(ComponentCallback callbackType, CbConsumer<U> callback) {
+    public <U> ComponentBuilderImpl stop(CbConsumer<U> callback) {
         if (callback != null) {
-            setComponentCallbackRef(callbackType, Helpers.getLambdaArgType(callback, 0), (inst, component) -> callback.accept((U) inst));
+            setComponentCallbackRef(STOP, Helpers.getLambdaArgType(callback, 0), (inst, component) -> callback.accept((U) inst));
         }
         return this;
     }
 
+    @SuppressWarnings("unchecked")
     @Override
-    public <U> ComponentBuilderImpl cb(ComponentCallback callbackType, CbTypeComponent<U> callback) {
+    public <U> ComponentBuilderImpl destroy(CbConsumer<U> callback) {
+        if (callback != null) {
+            setComponentCallbackRef(DESTROY, Helpers.getLambdaArgType(callback, 0), (inst, component) -> callback.accept((U) inst));
+        }
+        return this;
+    }
+
+   @SuppressWarnings("unchecked")
+   @Override
+    public <U> ComponentBuilderImpl init(CbTypeComponent<U> callback) {
+        if (callback != null) {
+            setComponentCallbackRef(INIT, Helpers.getLambdaArgType(callback, 0), (inst, component) -> callback.accept((U) inst, component));
+        }
+        return this;
+    }
+            
+   @SuppressWarnings("unchecked")
+   @Override
+    public <U> ComponentBuilderImpl start(CbTypeComponent<U> callback) {
+        if (callback != null) {
+            setComponentCallbackRef(START, Helpers.getLambdaArgType(callback, 0), (inst, component) -> callback.accept((U) inst, component));
+        }
+        return this;
+    }
+            
+   @SuppressWarnings("unchecked")
+   @Override
+    public <U> ComponentBuilderImpl stop(CbTypeComponent<U> callback) {
+        if (callback != null) {
+            setComponentCallbackRef(STOP, Helpers.getLambdaArgType(callback, 0), (inst, component) -> callback.accept((U) inst, component));
+        }
+        return this;
+    }
+            
+   @SuppressWarnings("unchecked")
+   @Override
+    public <U> ComponentBuilderImpl destroy(CbTypeComponent<U> callback) {
         if (callback != null) {
-            setComponentCallbackRef(callbackType, Helpers.getLambdaArgType(callback, 0), (inst, component) -> callback.accept((U) inst, component));
+            setComponentCallbackRef(DESTROY, Helpers.getLambdaArgType(callback, 0), (inst, component) -> callback.accept((U) inst, component));
         }
         return this;
     }
             
     @Override
-    public ComponentBuilderImpl cbi(ComponentCallback callbackType, Runnable callback) {
+    public ComponentBuilderImpl initInstance(Runnable callback) {
+        if (callback != null) {
+            setInstanceCallbackRef(INIT, (inst, component) -> callback.run());
+        }
+        return this;
+    }
+    
+    @Override
+    public ComponentBuilderImpl startInstance(Runnable callback) {
+        if (callback != null) {
+            setInstanceCallbackRef(START, (inst, component) -> callback.run());
+        }
+        return this;
+    }
+
+    @Override
+    public ComponentBuilderImpl stopInstance(Runnable callback) {
         if (callback != null) {
-            setInstanceCallbackRef(callbackType, (inst, component) -> callback.run());
+            setInstanceCallbackRef(STOP, (inst, component) -> callback.run());
+        }
+        return this;
+    }
+
+    @Override
+    public ComponentBuilderImpl destroyInstance(Runnable callback) {
+        if (callback != null) {
+            setInstanceCallbackRef(DESTROY, (inst, component) -> callback.run());
         }
         return this;
     }
         
     @Override
-    public ComponentBuilderImpl cbi(ComponentCallback callbackType, CbComponent callback) {
+    public ComponentBuilderImpl initInstance(CbComponent callback) {
+        if (callback != null) {
+            setInstanceCallbackRef(INIT, (inst, component) -> callback.accept(component));
+        }
+        return this;
+    }
+  
+    @Override
+    public ComponentBuilderImpl startInstance(CbComponent callback) {
+        if (callback != null) {
+            setInstanceCallbackRef(START, (inst, component) -> callback.accept(component));
+        }
+        return this;
+    }
+
+    @Override
+    public ComponentBuilderImpl stopInstance(CbComponent callback) {
+        if (callback != null) {
+            setInstanceCallbackRef(STOP, (inst, component) -> callback.accept(component));
+        }
+        return this;
+    }
+
+    @Override
+    public ComponentBuilderImpl destroyInstance(CbComponent callback) {
         if (callback != null) {
-            setInstanceCallbackRef(callbackType, (inst, component) -> callback.accept(component));
+            setInstanceCallbackRef(DESTROY, (inst, component) -> callback.accept(component));
         }
         return this;
     }
@@ -554,6 +673,9 @@ public class ComponentBuilderImpl implem
     @SuppressWarnings("unchecked")
     private <U> ComponentBuilderImpl setComponentCallbackRef(ComponentCallback cbType, Class<U> type, MethodRef<U> callback) {
         ensureHasNoLifecycleMethods();
+        if (type.equals(Object.class)) {
+            throw new IllegalStateException("callback does not seam to be one from the possible component implementation classes");
+        }
         List<MethodRef<Object>> list = m_refs.computeIfAbsent(cbType, l -> new ArrayList<>());
         list.add((instance, component) -> {
             Stream.of(component.getInstances()).forEach(inst -> {

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceAdapterBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceAdapterBuilderImpl.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceAdapterBuilderImpl.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceAdapterBuilderImpl.java Thu Jan 28 17:23:30 2016
@@ -7,22 +7,21 @@ import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.dm.lambda.ComponentBuilder;
 import org.apache.felix.dm.lambda.ServiceAdapterBuilder;
+import org.apache.felix.dm.lambda.ServiceCallbacksBuilder;
 
-public class ServiceAdapterBuilderImpl<T> extends ServiceCallbacksBuilderImpl<T, ServiceAdapterBuilderImpl<T>> implements
-    AdapterBase<ServiceAdapterBuilder<T>>, 
-    ServiceAdapterBuilder<T> 
-{	
+public class ServiceAdapterBuilderImpl<T> implements AdapterBase<ServiceAdapterBuilder<T>>, ServiceAdapterBuilder<T> {	
     private final Class<T> m_adapteeType;
     private String m_adapteeFilter;
     private boolean m_propagate = true;
     private final DependencyManager m_dm;
     private boolean m_autoAdd = true;
     private Consumer<ComponentBuilder<?>> m_compBuilder = (componentBuilder -> {});
+    private final ServiceCallbacksBuilderImpl<T, ?> m_cbBuilder;
 
     public ServiceAdapterBuilderImpl(DependencyManager dm, Class<T> type) {
-        super(type);
         m_dm = dm;
         m_adapteeType = type;
+        m_cbBuilder = new ServiceCallbacksBuilderImpl<>(m_adapteeType);
     }    
 
     @Override
@@ -58,23 +57,47 @@ public class ServiceAdapterBuilderImpl<T
     }
 
     @Override
+    public ServiceAdapterBuilder<T> autoConfig() {
+        m_cbBuilder.autoConfig();
+        return this;
+    }
+    
+    @Override
+    public ServiceAdapterBuilder<T> autoConfig(boolean autoConfig) {
+        m_cbBuilder.autoConfig(autoConfig);
+        return this;
+    }
+    
+    @Override
+    public ServiceAdapterBuilder<T> autoConfig(String field) {
+        m_cbBuilder.autoConfig(field);
+        return this;
+    }
+
+    @Override
+    public ServiceAdapterBuilder<T> adapterCb(Consumer<ServiceCallbacksBuilder<T, ?>> consumer) {
+        consumer.accept(m_cbBuilder);
+        return this;
+    }
+
+    @Override
     public Component build() {
         Objects.nonNull(m_adapteeFilter);
         
-        String add = m_added, change = m_changed, remove = m_removed, swap = m_swapped;
-        Object cbInstance = m_callbackInstance;
+        String add = m_cbBuilder.getAdded(), change = m_cbBuilder.getChanged(), remove = m_cbBuilder.getRemoved(), swap = m_cbBuilder.getSwapped();
+        Object cbInstance = m_cbBuilder.getCallbackInstance();
         
-        if (hasRefs()) {
+        if (m_cbBuilder.hasRefs()) {
             // if some method references have been set, use our own callback proxy to redispatch events to method refs.        
-        	cbInstance = createCallbackInstance();
+        	cbInstance = m_cbBuilder.createCallbackInstance();
             add = "add";
             change = "change";
             remove = "remove";
-            swap = m_swapRefs.size() > 0 ? "swap" : null;
+            swap = m_cbBuilder.m_swapRefs.size() > 0 ? "swap" : null;
         } 
 
         Component c = m_dm.createAdapterService
-        		(m_adapteeType, m_adapteeFilter, m_autoConfigField, cbInstance, add, change, remove, swap, m_propagate);
+        		(m_adapteeType, m_adapteeFilter, m_cbBuilder.getAutoConfigField(), cbInstance, add, change, remove, swap, m_propagate);
         
         ComponentBuilderImpl cb = new ComponentBuilderImpl(c, false);
         // m_compBuilder is a composed consumer that calls in sequence all necessary component builder methods. 

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceAspectBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceAspectBuilderImpl.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceAspectBuilderImpl.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceAspectBuilderImpl.java Thu Jan 28 17:23:30 2016
@@ -7,22 +7,21 @@ import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.dm.lambda.ComponentBuilder;
 import org.apache.felix.dm.lambda.ServiceAspectBuilder;
+import org.apache.felix.dm.lambda.ServiceCallbacksBuilder;
 
-public class ServiceAspectBuilderImpl<T> extends ServiceCallbacksBuilderImpl<T, ServiceAspectBuilderImpl<T>> implements
-    AdapterBase<ServiceAspectBuilder<T>>, 
-    ServiceAspectBuilder<T> 
-{    
+public class ServiceAspectBuilderImpl<T> implements AdapterBase<ServiceAspectBuilder<T>>, ServiceAspectBuilder<T> {    
     private final DependencyManager m_dm;
     private final Class<T> m_aspectType;
     private String m_aspectFilter;
     private int m_aspectRanking;
     private boolean m_autoAdd = true;
     private Consumer<ComponentBuilder<?>> m_compBuilder = (componentBuilder -> {});
+    private final ServiceCallbacksBuilderImpl<T, ?> m_cbBuilder;
 
     public ServiceAspectBuilderImpl(DependencyManager dm, Class<T> type) {
-        super(type);
         m_dm = dm;
         m_aspectType = type;
+        m_cbBuilder = new ServiceCallbacksBuilderImpl<>(m_aspectType);
     }
 
     @Override
@@ -57,27 +56,55 @@ public class ServiceAspectBuilderImpl<T>
         m_aspectRanking = ranking;
         return this;
     }
+    
+    @Override
+    public ServiceAspectBuilder<T> autoConfig() {
+        m_cbBuilder.autoConfig();
+        return this;
+    }
+    
+    @Override
+    public ServiceAspectBuilder<T> autoConfig(boolean autoConfig) {
+        m_cbBuilder.autoConfig(autoConfig);
+        return this;
+    }
+    
+    @Override
+    public ServiceAspectBuilder<T> autoConfig(String field) {
+        m_cbBuilder.autoConfig(field);
+        return this;
+    }
+
+    @Override
+    public ServiceAspectBuilder<T> aspectCb(Consumer<ServiceCallbacksBuilder<T, ?>> consumer) {
+        consumer.accept(m_cbBuilder);
+        return this;
+    }
 
     @Override
     public Component build() {
         Objects.nonNull(m_aspectType);
         
-        if (m_autoConfigField != null && (hasRefs()|| hasCallbacks())) {
+        if (m_cbBuilder.getAutoConfigField() != null && (m_cbBuilder.hasRefs()|| m_cbBuilder.hasCallbacks())) {
             throw new IllegalStateException("Can't mix autoConfig fields and aspect callbacks.");
         }
         
         Component c = null;
-        if (m_autoConfigField != null) {
-            c = m_dm.createAspectService(m_aspectType, m_aspectFilter, m_aspectRanking, m_autoConfigField);
-        } else if (hasRefs()) {        
-            Object cbInstance = createCallbackInstance();
+        if (m_cbBuilder.getAutoConfigField() != null) {
+            c = m_dm.createAspectService(m_aspectType, m_aspectFilter, m_aspectRanking, m_cbBuilder.getAutoConfigField());
+        } else if (m_cbBuilder.hasRefs()) {        
+            Object cbInstance = m_cbBuilder.createCallbackInstance();
             String add = "add";
             String change = "change";
             String remove = "remove";
-            String swap = m_swapRefs.size() > 0 ? "swap" : null;        
+            String swap = m_cbBuilder.m_swapRefs.size() > 0 ? "swap" : null;        
             c = m_dm.createAspectService(m_aspectType, m_aspectFilter, m_aspectRanking, cbInstance, add, change, remove, swap);
-        } else if (hasCallbacks()) {
-            c = m_dm.createAspectService(m_aspectType, m_aspectFilter, m_aspectRanking, m_added, m_changed, m_removed, m_swapped);
+        } else if (m_cbBuilder.hasCallbacks()) {
+            String add = m_cbBuilder.getAdded();
+            String change = m_cbBuilder.getChanged();
+            String remove = m_cbBuilder.getRemoved();
+            String swap = m_cbBuilder.getSwapped();
+            c = m_dm.createAspectService(m_aspectType, m_aspectFilter, m_aspectRanking, add, change, remove, swap);
         } else {
             c = m_dm.createAspectService(m_aspectType, m_aspectFilter, m_aspectRanking);
         }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceCallbacksBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceCallbacksBuilderImpl.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceCallbacksBuilderImpl.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceCallbacksBuilderImpl.java Thu Jan 28 17:23:30 2016
@@ -8,6 +8,7 @@ import java.util.Objects;
 import java.util.stream.Stream;
 
 import org.apache.felix.dm.Component;
+import org.apache.felix.dm.lambda.ServiceCallbacksBuilder;
 import org.apache.felix.dm.lambda.callbacks.CbComponent;
 import org.apache.felix.dm.lambda.callbacks.CbComponentRef;
 import org.apache.felix.dm.lambda.callbacks.CbComponentRefService;
@@ -44,7 +45,7 @@ import org.osgi.framework.ServiceReferen
  * @param <B> the type of the sub-classes which may extend this class
  */
 @SuppressWarnings({"unchecked", "unused"})
-public abstract class ServiceCallbacksBuilderImpl<S, B extends ServiceCallbacksBuilderImpl<S, B>> {
+public class ServiceCallbacksBuilderImpl<S, B extends ServiceCallbacksBuilder<S, B>> implements ServiceCallbacksBuilder<S, B> {
     protected boolean m_autoConfig = true;
     protected boolean m_autoConfigInvoked = false;
     protected String m_autoConfigField;
@@ -569,7 +570,7 @@ public abstract class ServiceCallbacksBu
         return (B) this;
      }
     
-    protected Object createCallbackInstance() {
+    Object createCallbackInstance() {
        Object cb = null;
        
        cb = new Object() {
@@ -593,14 +594,38 @@ public abstract class ServiceCallbacksBu
        return cb;
     }
     
-    protected boolean hasRefs() {
+    boolean hasRefs() {
        return m_refs.size() > 0 || m_swapRefs.size() > 0;
     }
     
-    protected boolean hasCallbacks() {
+    boolean hasCallbacks() {
        return m_callbackInstance != null || m_added != null || m_changed != null || m_removed != null || m_swapped != null;
     }
-      
+    
+    String getAutoConfigField() {
+        return m_autoConfigField;
+    }
+    
+    Object getCallbackInstance() {
+        return m_callbackInstance;
+    }
+    
+    String getAdded() {
+        return m_added;
+    }
+    
+    String getChanged() {
+        return m_changed;
+    }
+    
+    String getRemoved() {
+        return m_removed;
+    }
+    
+    String getSwapped() {
+        return m_swapped;
+    }
+     
     private void invokeMethodRefs(Cb cbType, Component comp, ServiceReference<S> ref, S service) {
 	   m_refs.computeIfPresent(cbType, (k, mrefs) -> {
 		   mrefs.forEach(mref -> mref.accept(null, comp, ref, service));

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceDependencyBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceDependencyBuilderImpl.java?rev=1727410&r1=1727409&r2=1727410&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceDependencyBuilderImpl.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceDependencyBuilderImpl.java Thu Jan 28 17:23:30 2016
@@ -10,7 +10,7 @@ import org.apache.felix.dm.ServiceDepend
 import org.apache.felix.dm.lambda.ServiceDependencyBuilder;
 import org.osgi.framework.ServiceReference;
 
-public class ServiceDependencyBuilderImpl<S> extends ServiceCallbacksBuilderImpl<S, ServiceDependencyBuilderImpl<S>> implements ServiceDependencyBuilder<S> {
+public class ServiceDependencyBuilderImpl<S> extends ServiceCallbacksBuilderImpl<S, ServiceDependencyBuilder<S>> implements ServiceDependencyBuilder<S> {
     private final Class<S> m_serviceIface;
     private final Component m_component;
     private String m_filter;



Mime
View raw message