felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1731147 [3/7] - in /felix/trunk/dependencymanager: org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/ org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/compositefact...
Date Thu, 18 Feb 2016 21:07:18 GMT
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Configuration.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Configuration.java?rev=1731147&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Configuration.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Configuration.java Thu Feb 18 21:07:16 2016
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dm.lambda.samples.hello;
+
+/**
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public interface Configuration {
+    /**
+     * Returns the value of the "foo" property.
+     * @return the value of the "foo" property.
+     */
+    String getFoo();
+}

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Configurator.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Configurator.java?rev=1731147&r1=1731146&r2=1731147&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Configurator.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Configurator.java Thu Feb 18 21:07:16 2016
@@ -8,7 +8,12 @@ import org.osgi.service.cm.Configuration
 import org.osgi.service.cm.ConfigurationAdmin;
 
 public class Configurator {
-    ConfigurationAdmin m_cm; 
+    ConfigurationAdmin m_cm;
+    final String m_pid;
+    
+    Configurator(String pid) {
+        m_pid = pid;
+    }
     
     void bind(ConfigurationAdmin cm) {
         m_cm = cm;
@@ -16,7 +21,7 @@ public class Configurator {
     
     void start() throws IOException {
         // Configure the ServiceConsumer component
-        Configuration c = m_cm.getConfiguration(ServiceConsumer.class.getName(), null);
+        Configuration c = m_cm.getConfiguration(m_pid, null);
         Dictionary<String, Object> props = new Hashtable<>();
         props.put("foo", "bar");
         c.update(props);

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=1731147&r1=1731146&r2=1731147&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 Thu Feb 18 21:07:16 2016
@@ -18,8 +18,6 @@
  */
 package org.apache.felix.dm.lambda.samples.hello;
 
-import java.util.Dictionary;
-
 import org.osgi.service.event.EventAdmin;
 import org.osgi.service.log.LogService;
 
@@ -33,11 +31,12 @@ public class ServiceConsumer {
     volatile LogService log;
     volatile EventAdmin eventAdmin;
 
-    public void updated(Dictionary<String, Object> conf) {
+    public void updated(Configuration conf) {
+        // conf.getFoo() returns "bar"
     }
     
     public void start() {
-        log.log(LogService.LOG_INFO, "ServiceConsumer.start: calling service.hello()");
+        log.log(LogService.LOG_WARNING, "ServiceConsumer.start: calling service.hello()");
         this.service.hello();
     }
 }

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=1731147&r1=1731146&r2=1731147&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 Thu Feb 18 21:07:16 2016
@@ -48,6 +48,6 @@ public class ServiceProviderImpl impleme
     
     @Override
     public void hello() {
-        log.log(LogService.LOG_INFO, "ServiceProviderImpl.hello");
+        log.log(LogService.LOG_WARNING, "ServiceProviderImpl.hello");
     }
 }

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleAdapterBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleAdapterBuilder.java?rev=1731147&r1=1731146&r2=1731147&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleAdapterBuilder.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleAdapterBuilder.java Thu Feb 18 21:07:16 2016
@@ -1,9 +1,9 @@
 package org.apache.felix.dm.lambda;
 
 import org.apache.felix.dm.lambda.callbacks.CbBundle;
-import org.apache.felix.dm.lambda.callbacks.CbComponentBundle;
-import org.apache.felix.dm.lambda.callbacks.CbTypeBundle;
-import org.apache.felix.dm.lambda.callbacks.CbTypeComponentBundle;
+import org.apache.felix.dm.lambda.callbacks.CbBundleComponent;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbBundle;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbBundleComponent;
 
 /**
  * Builds a Dependency Manager bundle adapter. The adapter created by this builder will be applied to any bundle that matches the specified 
@@ -12,12 +12,14 @@ import org.apache.felix.dm.lambda.callba
  * you supply here. The bundle is injected by reflection in adapter class fields having a Bundle type, or using a callback method that you can 
  * specify.
  * 
+ * You can specify reflection based (using method names), or java8 method references for callbacks.
+ * 
  * <p> Example which creates a BundleAdapter service for each started bundle (the bundle is added by reflection on
  * a class field that has a "Bundle" type):
  * 
  * <pre> {@code
  * public class Activator extends DependencyManagerActivator {
- *     public void activate() throws Exception { 
+ *     public void init(BundleContext ctx, DependencyManager dm) throws Exception { 
  *       bundleAdapter(adapt -> adapt
  *           .impl(BundleAdapterImpl.class)
  *           .provides(BundleAdapter.class)
@@ -30,12 +32,12 @@ import org.apache.felix.dm.lambda.callba
  * 
  * <pre> {@code
  * public class Activator extends DependencyManagerActivator {
- *     public void activate() throws Exception { 
+ *     public void init(BundleContext ctx, DependencyManager dm) throws Exception { 
  *       bundleAdapter(adapt -> adapt
  *           .impl(BundleAdapterImpl.class)
  *           .provides(BundleAdapter.class)
  *           .mask(Bundle.INSTALLED | Bundle.RESOLVED | Bundle.ACTIVE)
- *           .cb(BundleAdapterImpl::setBundle));
+ *           .add(BundleAdapterImpl::setBundle));
  *    }
  * }
  * }</pre>
@@ -44,12 +46,12 @@ import org.apache.felix.dm.lambda.callba
  * 
  * <pre> {@code
  * public class Activator extends DependencyManagerActivator {
- *     public void activate() throws Exception { 
+ *     public void init(BundleContext ctx, DependencyManager dm) throws Exception { 
  *       bundleAdapter(adapt -> adapt
  *           .impl(BundleAdapterImpl.class)
  *           .provides(BundleAdapter.class)
  *           .mask(Bundle.INSTALLED | Bundle.RESOLVED | Bundle.ACTIVE)
- *           .cb("setBundle"));
+ *           .add("setBundle"));
  *    }
  * }
  * }</pre>
@@ -92,152 +94,187 @@ public interface BundleAdapterBuilder ex
     BundleAdapterBuilder propagate();
     
     /**
-     * Sets some <code>callbacks</code> invoked on the component implementation instances. When a bundle state matches the bundle 
-     * adapter filter, then the bundle is injected using the specified callback methods. When you specify one callback, it stands for the "add" callback.
-     * When you specify two callbacks, the first one corresponds to the "add" callback, and the second one to the "remove" callback. When you specify three
-     * callbacks, the first one stands for the "add" callback, the second one for the "change" callback, and the third one for the "remove" callback.
-     * 
-     * @param callbacks a list of callbacks (1 param : "add", 2 params : "add"/remove", 3 params : "add"/"change"/"remove").
-     * @return this builder
-     */
-    BundleAdapterBuilder cb(String ... callbacks);
-    
-    /**
-     * Sets some <code>callback instance</code> methods invoked on a given Object instance. When a bundle state matches the bundle 
-     * adapter filter, then the bundle is injected using the specified callback methods. When you specify one callback, it stands for the "add" callback.
-     * When you specify two callbacks, the first one corresponds to the "add" callback, and the second one to the "remove" callback. 
-     * When you specify three callbacks, the first one stands for the "add" callback, the second one for the "change" callback, and the third one for 
-     * the "remove" callback.
-     * 
-     * @param callbackInstance the Object instance where the callbacks are invoked on
-     * @param callbacks a list of callbacks (1 param : "add", 2 params : "add"/remove", 3 params : "add"/"change"/"remove").
-     * @return this builder
-     */
-    BundleAdapterBuilder cbi(Object callbackInstance, String ... callbacks);
+     * Sets a "add" callback name invoked on the component implementation instance(s).
+     * The callback can be used as hooks whenever the dependency is added. When you specify a callback, 
+     * the auto configuration feature is automatically turned off, because we're assuming you don't need it in this case.
+     * 
+     * @param callback the method to call when a bundle was added
+     * 
+     * The following method signature are supported:
+     * <pre>{@code
+     * callback(Bundle b)
+     * callback(Component c, Bundle b)
+     * }</pre>
+     * 
+     * @param callback the callback name
+     * @return this builder.
+     */
+    BundleAdapterBuilder add(String callback);
+    
+    /**
+     * Sets a "change" callback name invoked on the component implementation instance(s).
+     * The callback can be used as hooks whenever the dependency is changed. When you specify a callback, 
+     * the auto configuration feature is automatically turned off, because we're assuming you don't need it in this case.
+     * 
+     * @param callback the method to call when a bundle was changed
+     * 
+     * The following method signature are supported:
+     * <pre>{@code
+     * callback(Bundle b)
+     * callback(Component c, Bundle b)
+     * }</pre>
+     * 
+     * @param callback the callback name
+     * @return this builder.
+     */
+     BundleAdapterBuilder change(String callback);
+ 
+     /**
+      * Sets a "remove" callback name invoked on the component implementation instance(s).
+      * The callback can be used as hooks whenever the dependency is removed. When you specify a callback, 
+      * the auto configuration feature is automatically turned off, because we're assuming you don't need it in this case.
+      * 
+      * @param callback the method to call when a bundle was removed
+      * 
+      * The following method signature are supported:
+      * <pre>{@code
+      * callback(Bundle b)
+      * callback(Component c, Bundle b)
+      * }</pre>
+      * 
+      * @param callback the callback name
+      * @return this builder.
+      */
+     BundleAdapterBuilder remove(String callback);
+     
+     /**
+      * Sets a callback instance to use when invoking reflection based callbacks.
+      * 
+      * @param callbackInstance the instance to call the reflection based callbacks on
+      * @return this builder.
+      * @see #add(String)
+      * @see #change(String)
+      * @see #remove(String)
+      */
+     BundleAdapterBuilder callbackInstance(Object callbackInstance);
 
     /**
-     * Sets a <code>callback</code> invoked on a component implementation instance when a bundle is added.
-     * The method reference must point to a Component implementation class method, and take as argument a Bundle.
+     * Sets a reference to a callback method invoked on one of the component implementation classes.
+     * The method reference must point to a Component implementation class method, it is called when the bundle is added
+     * and takes as argument a Bundle.
      * 
      * @param <T> the type of the component instance class on which the callback is invoked.
      * @param add the method reference invoked when a bundle is added.
      * @return this builder
      */
-    <T> BundleAdapterBuilder cb(CbTypeBundle<T> add);
+    <T> BundleAdapterBuilder add(CbBundle<T> add);
     
     /**
-     * Sets some <code>callbacks</code> invoked on a component implementation instance when a bundle is added/removed.
-     * The method references must point to a Component implementation class method, and take as argument a Bundle.
+     * Sets a reference to a callback method invoked on one of the component implementation classes.
+     * The method reference must point to a Component implementation class method, it is called when the bundle is changed
+     * and takes as argument a Bundle.
      * 
      * @param <T> the type of the component instance class on which the callback is invoked.
-     * @param add the method reference invoked when a bundle is added.
-     * @param remove the method reference invoked when a bundle is removed.
+     * @param change the method reference invoked when a bundle has changed.
      * @return this builder
      */
-    <T> BundleAdapterBuilder cb(CbTypeBundle<T> add, CbTypeBundle<T> remove);
+    <T> BundleAdapterBuilder change(CbBundle<T> change);
     
     /**
-     * Sets some <code>callbacks</code> invoked on a component implementation instance when a bundle is added, changed or removed.
-     * The method references must point to a Component implementation class method, and take as argument a Bundle.
+     * Sets a reference to a callback method invoked on one of the component implementation classes.
+     * The method reference must point to a Component implementation class method, it is called when the bundle is removed
+     * and takes as argument a Bundle.
      * 
      * @param <T> the type of the component instance class on which the callback is invoked.
-     * @param add the method reference invoked when a bundle is added.
-     * @param change the method reference invoked when a bundle has changed.
      * @param remove the method reference invoked when a bundle is removed.
      * @return this builder
      */
-    <T> BundleAdapterBuilder cb(CbTypeBundle<T> add, CbTypeBundle<T> change, CbTypeBundle<T> remove);
+    <T> BundleAdapterBuilder remove(CbBundle<T> remove);
     
     /**
-     * Sets a <code>callback</code> invoked on a component implementation instance when a bundle is added.
-     * The method reference must point to a Component implementation class method, and take as argument a Component and a Bundle.
+     * Sets a reference to a callback method invoked on one of the component implementation classes.
+     * The method reference must point to a Component implementation class method, it is called when the bundle is added
+     * and takes as argument a Bundle and a Component.
      * 
      * @param <T> the type of the component instance class on which the callback is invoked.
      * @param add the method reference invoked when a bundle is added.
      * @return this builder
      */
-    <T> BundleAdapterBuilder cb(CbTypeComponentBundle<T> add);    
+    <T> BundleAdapterBuilder add(CbBundleComponent<T> add);    
     
     /**
-     * Sets some <code>callbacks</code> invoked on a component implementation instance when a bundle is added, or removed.
-     * The method references must point to a Component implementation class method, and take as argument a Component and a Bundle.
+     * Sets a reference to a callback method invoked on one of the component implementation classes.
+     * The method reference must point to a Component implementation class method, it is called when the bundle is changed
+     * and takes as argument a Bundle and a Component.
      * 
      * @param <T> the type of the component instance class on which the callback is invoked.
-     * @param add the method reference invoked when a bundle is added.
-     * @param remove the method reference invoked when a bundle is removed.
+     * @param change the method reference invoked when a bundle has changed.
      * @return this builder
      */
-    <T> BundleAdapterBuilder cb(CbTypeComponentBundle<T> add, CbTypeComponentBundle<T> remove);   
+    <T> BundleAdapterBuilder change(CbBundleComponent<T> change);    
     
     /**
-     * Sets some <code>callbacks</code> invoked on a component implementation instance when a bundle is added, changed or removed.
-     * The method references must point to a Component implementation class method, and take as argument a Component and a Bundle.
+     * Sets a reference to a callback method invoked on one of the component implementation classes.
+     * The method reference must point to a Component implementation class method, it is called when the bundle is removed
+     * and takes as argument a Bundle and a Component.
      * 
      * @param <T> the type of the component instance class on which the callback is invoked.
-     * @param add the method reference invoked when a bundle is added.
-     * @param change the method reference invoked when a bundle has changed.
      * @param remove the method reference invoked when a bundle is removed.
      * @return this builder
      */
-    <T> BundleAdapterBuilder cb(CbTypeComponentBundle<T> add, CbTypeComponentBundle<T> change, CbTypeComponentBundle<T> remove);         
+    <T> BundleAdapterBuilder remove(CbBundleComponent<T> remove);    
 
     /**
-     * Sets a <code>callback instance</code> invoked on a given Object instance when a bundle is added. 
-     * The method reference must point to an Object instance method, and takes as argument a Bundle parameter.
+     * Sets a reference to a callback method invoked on a given Object instance.
+     * The method reference is invoked when the bundle is added and takes as argument a Bundle.
      * 
      * @param add the method reference invoked when a bundle is added.
      * @return this builder
      */
-    BundleAdapterBuilder cbi(CbBundle add);
+    BundleAdapterBuilder add(InstanceCbBundle add);
     
     /**
-     * Sets some <code>callback instance</code> invoked on a given Object instance when a bundle is added or removed. 
-     * The method references must point to an Object instance method, and take as argument a Bundle parameter.
+     * Sets a reference to a callback method invoked on a given Object instance.
+     * The method reference is invoked when the bundle has changed and takes as argument a Bundle.
      * 
-     * @param add the method reference invoked when a bundle is added.
-     * @param remove the method reference invoked when a bundle is removed.
+     * @param change the method reference invoked when a bundle has changed.
      * @return this builder
      */
-    BundleAdapterBuilder cbi(CbBundle add, CbBundle remove);
+    BundleAdapterBuilder change(InstanceCbBundle change);
     
     /**
-     * Sets some <code>callback instance</code> invoked on a given Object instance when a bundle is added, changed or removed.
-     * The method references must point to an Object instance method, and take as argument a Bundle parameter.
+     * Sets a reference to a callback method invoked on a given Object instance.
+     * The method reference is invoked when the bundle is removed and takes as argument a Bundle.
      * 
-     * @param add the method reference invoked when a bundle is added.
-     * @param change the method reference invoked when a bundle has changed.
      * @param remove the method reference invoked when a bundle is removed.
      * @return this builder
      */
-    BundleAdapterBuilder cbi(CbBundle add, CbBundle change, CbBundle remove);
+    BundleAdapterBuilder remove(InstanceCbBundle remove);
 
     /**
-     * Sets a <code>callback instance</code> invoked on a given Object instance when a bundle is added. 
-     * The method reference must point to an Object instance method, and takes as arguments a Component and a Bundle.
+     * Sets a reference to a callback method invoked on a given Object instance.
+     * The method reference is invoked when the bundle is added and takes as argument a Bundle and a Component.
      * 
      * @param add the method reference invoked when a bundle is added.
      * @return this builder
      */
-    BundleAdapterBuilder cbi(CbComponentBundle add);
+    BundleAdapterBuilder add(InstanceCbBundleComponent add);
     
     /**
-     * Sets some <code>callback instance</code> invoked on a given Object instance when a bundle is added or removed. 
-     * The method references must point to an Object instance method, and take as argument a Component and a Bundle.
+     * Sets a reference to a callback method invoked on a given Object instance.
+     * The method reference is invoked when the bundle has changed and takes as argument a Bundle and a Component.
      * 
-     * @param add the method reference invoked when a bundle is added.
-     * @param remove the method reference invoked when a bundle is removed.
+     * @param change the method reference invoked when a bundle has changed.
      * @return this builder
      */
-    BundleAdapterBuilder cbi(CbComponentBundle add, CbComponentBundle remove);
+    BundleAdapterBuilder change(InstanceCbBundleComponent change);
     
     /**
-     * Sets some <code>callback instance</code> invoked on a given Object instance when a bundle is added, changed or removed.
-     * The method references must point to an Object instance method, and take as argument a Component and a Bundle.
+     * Sets a reference to a callback method invoked on a given Object instance.
+     * The method reference is invoked when the bundle is removed and takes as argument a Bundle and a Component.
      * 
-     * @param add the method reference invoked when a bundle is added.
-     * @param change the method reference invoked when a bundle has changed.
      * @param remove the method reference invoked when a bundle is removed.
      * @return this builder
      */
-    BundleAdapterBuilder cbi(CbComponentBundle add, CbComponentBundle change, CbComponentBundle remove);
+    BundleAdapterBuilder remove(InstanceCbBundleComponent remove);
 }

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleDependencyBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleDependencyBuilder.java?rev=1731147&r1=1731146&r2=1731147&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleDependencyBuilder.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleDependencyBuilder.java Thu Feb 18 21:07:16 2016
@@ -1,27 +1,30 @@
 package org.apache.felix.dm.lambda;
 
 import java.util.Dictionary;
-import java.util.function.Supplier;
+import java.util.function.Function;
 
 import org.apache.felix.dm.BundleDependency;
 import org.apache.felix.dm.lambda.callbacks.CbBundle;
-import org.apache.felix.dm.lambda.callbacks.CbComponentBundle;
-import org.apache.felix.dm.lambda.callbacks.CbTypeBundle;
-import org.apache.felix.dm.lambda.callbacks.CbTypeComponentBundle;
+import org.apache.felix.dm.lambda.callbacks.CbBundleComponent;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbBundle;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbBundleComponent;
 import org.osgi.framework.Bundle;
 
 /**
- * Builds a Dependency Manager Bundle Dependency. The Dependency is required by default (unlike in the original Dependency Manager API).
+ * Builds a Dependency Manager Bundle Dependency. 
+ * The Dependency is required by default, but you can
+ * control the default mode (required or optional) using the "org.apache.felix.dependencymanager.lambda.dependencymode"
+ * system property which can be set to either "required" or "optional" ("required" by default).
  * 
- * <p> Example of a Component which tracks a started bundle having a given bundle symbolic name:
+ * <p> Example of a Pojo Component which tracks a started bundle having a given bundle symbolic name:
  * 
  * <pre> {@code
  * public class Activator extends DependencyManagerActivator {
- *     public void activate() throws Exception { 
+ *     public void init(BundleContext ctx, DependencyManager dm) throws Exception { 
  *         String BSN = "org.apache.felix.dependencymanager";
  *         component(comp -> comp
- *             .impl(MyComponent.class)
- *             .withBundle(b -> b.mask(Bundle.ACTIVE).filter("(Bundle-SymbolicName=" + BSN + ")").cb(MyComponent::add, MyComponent::remove)));
+ *             .impl(Pojo.class)
+ *             .withBundle(b -> b.mask(Bundle.ACTIVE).filter("(Bundle-SymbolicName=" + BSN + ")").add(Pojo::add).remove(Pojo::remove)));
  *                  
  *    }
  * }
@@ -31,7 +34,7 @@ import org.osgi.framework.Bundle;
  */
 public interface BundleDependencyBuilder extends DependencyBuilder<BundleDependency> {
     /**
-     * Enables auto configuration for this dependency. This means the component implementation (composition) will be
+     * Enables auto configuration for this dependency. This means the component implementation class fields will be
      * injected with this bundle dependency automatically.
      * 
      * @param autoConfig <code>true</code> to enable auto configuration
@@ -40,7 +43,7 @@ public interface BundleDependencyBuilder
     public BundleDependencyBuilder autoConfig(boolean autoConfig);
 
     /**
-     * Enables auto configuration for this dependency. This means the component implementation (composition) will be
+     * Enables auto configuration for this dependency. This means the component implementation class fields will be
      * injected with this bundle dependency automatically.
      * 
      * @return the bundle dependency builder
@@ -48,7 +51,8 @@ public interface BundleDependencyBuilder
     public BundleDependencyBuilder autoConfig();
 
     /**
-     * Sets the dependency to be required. By default, the dependency is required.
+     * Sets the dependency to be required. By default, the dependency is required, but you can specify the default mode
+     * using the "org.apache.felix.dependencymanager.lambda.dependencymode" system property.
      * 
      * @param required <code>true</code> if this bundle dependency is required (true by default).
      * @return the bundle dependency builder
@@ -56,7 +60,8 @@ public interface BundleDependencyBuilder
     public BundleDependencyBuilder required(boolean required);
 
     /**
-     * Sets the dependency to be required.
+     * Sets the dependency to be required.  By default, the dependency is required, but you can specify the default mode
+     * using the "org.apache.felix.dependencymanager.lambda.dependencymode" system property.
      * 
      * @return the bundle dependency builder
      */
@@ -107,9 +112,9 @@ public interface BundleDependencyBuilder
     /**
      * Sets an Object instance and a callback method used to propagate some properties to the provided service properties.
      * The method will be invoked on the specified object instance and must have one of the following signatures:
-     * <ul><li>Dictionary callback(ServiceReference, Object service) 
-     * <li>Dictionary callback(ServiceReference)
-     * </ul>
+     * 
+     * <p><ul><li>Dictionary callback(Bundle bundle)</ul>
+     * 
      * @param instance the Object instance which is used to retrieve propagated service properties 
      * @param method the method to invoke for retrieving the properties to be propagated to the service properties.
      * @return this service dependency. builder
@@ -117,163 +122,176 @@ public interface BundleDependencyBuilder
     public BundleDependencyBuilder propagate(Object instance, String method);
     
     /**
-     * Sets an Object instance and a callback method used to propagate some properties to the provided service properties.
-     * The method will be invoked on the specified object instance and must have one of the following signatures:
-     * <ul><li>Dictionary callback(ServiceReference, Object service) 
-     * <li>Dictionary callback(ServiceReference)
-     * </ul>
-     * @param instance the Object instance which is used to retrieve propagated service properties 
+     * Sets a reference to a method on an Object instance used to propagate some bundle properties to the provided service properties.
+     * 
+     * @param propagate a function which accepts a Bundle argument and which returns some properties that will be
+     * propagated to the provided component service properties. 
      * @return this service dependency. builder
      */
-    public BundleDependencyBuilder propagate(Supplier<Dictionary<?, ?>> instance);
+    public BundleDependencyBuilder propagate(Function<Bundle, Dictionary<?, ?>> propagate);
 
     /**
-     * Sets some <code>callback</code> methods to invoke on the component instance(s). When a bundle state matches the bundle 
-     * filter, then the bundle is injected using the specified callback methods. When you specify one callback, it stands for the "add" callback.
-     * When you specify two callbacks, the first one corresponds to the "add" callback, and the second one to the "remove" callback. When you specify three
-     * callbacks, the first one stands for the "add" callback, the second one for the "change" callback, and the third one for the "remove" callback.
+     * Sets a "add" <code>callback</code> method to invoke on the component implementation instance(s).
+     * The callback is invoked when the bundle is added, and the following signatures are supported:
      * 
-     * @param callbacks a list of callbacks (1 param: "add", 2 params: "add"/remove", 3 params: "add"/"change"/"remove" callbacks).
+     * <p><ol>
+     * <li>method(Bundle)</li>
+     * <li>method(Component, Bundle)</li>
+     * </ol>
+     * 
+     * @param callback the add callback
      * @return this builder
      */
-    BundleDependencyBuilder cb(String ... callbacks);
+    BundleDependencyBuilder add(String callback);
     
     /**
-     * Sets some <code>callback instance</code> methods to invoke on a given Object instance. When a bundle state matches the bundle 
-     * filter, then the bundle is injected using the specified callback methods. When you specify one callback, it stands for the "add" callback.
-     * When you specify two callbacks, the first one corresponds to the "add" callback, and the second one to the "remove" callback. 
-     * When you specify three callbacks, the first one stands for the "add" callback, the second one for the "change" callback, and the third one for 
-     * the "remove" callback.
+     * Sets a "change" <code>callback</code> method to invoke on the component implementation instance(s). 
+     * The callback is invoked when the bundle state has changed, and the following signatures are supported:
+     * 
+     * <p><ol>
+     * <li>method(Bundle)</li>
+     * <li>method(Component, Bundle)</li>
+     * </ol>
      * 
-     * @param callbackInstance the Object instance where the callbacks are invoked on
-     * @param callbacks a list of callbacks (1 param: "add", 2 params: "add/remove", 3 params: "add/change/remove" callbacks).
+     * @param callback the change callback
      * @return this builder
      */
-    BundleDependencyBuilder cb(Object callbackInstance, String ... callbacks);
+    BundleDependencyBuilder change(String callback);
+    
+    /**
+     * Sets a "remove" <code>callback</code> method to invoke on the component implementation instance(s). 
+     * The callback is invoked when the bundle is removed, and the following signatures are supported:
+     * <p><ol>
+     * <li>method(Bundle)</li>
+     * <li>method(Component, Bundle)</li>
+     * </ol>
+     * 
+     * @param callback the remove callback
+     * @return this builder
+     */
+    BundleDependencyBuilder remove(String callback);
+    
+    /**
+     * Specifies a callback instance used to invoke the reflection based callbacks on it.
+     * @param callbackInstance the instance to invoke the callbacks on
+     * @return this builder
+     * @see #add(String)
+     * @see #change(String)
+     * @see #remove(String)
+     */
+    BundleDependencyBuilder callbackInstance(Object callbackInstance);
 
     /**
      * Sets a <code>callback</code> method reference which is invoked when a bundle is added.
-     * The method reference must point to a Component implementation class method, and take as argument a Bundle.
+     * The method reference must point to a Component implementation class method, and takes as argument a Bundle.
      * 
      * @param <T> the type of the component implementation class on which the callback is invoked on.
      * @param add the method reference invoked when a bundle is added.
      * @return this builder
      */
-    <T> BundleDependencyBuilder cb(CbTypeBundle<T> add);
-    
+    <T> BundleDependencyBuilder add(CbBundle<T> add);
+        
     /**
-     * Sets some <code>callback</code> method references which are invoked when a bundle is added, or removed.
-     * The method references must point to a Component implementation class method, and take as argument a Bundle.
+     * Sets a <code>callback</code> method reference which is invoked when a bundle is changed.
+     * The method reference must point to a Component implementation class method, and takes as argument a Bundle.
      * 
      * @param <T> the type of the component implementation class on which the callback is invoked on.
-     * @param add the method reference invoked when a bundle is added.
-     * @param remove the method reference invoked when a bundle is removed.
+     * @param change the method reference invoked when a bundle has changed.
      * @return this builder
      */
-    <T> BundleDependencyBuilder cb(CbTypeBundle<T> add, CbTypeBundle<T> remove);
+    <T> BundleDependencyBuilder change(CbBundle<T> change);
     
     /**
-     * Sets some <code>callback</code> method references which are invoked when a bundle is added, changed or removed.
-     * The method references must point to a Component implementation class method, and take as argument a Bundle.
+     * Sets a <code>callback</code> method reference which is invoked when a bundle is removed.
+     * The method reference must point to a Component implementation class method, and takes as argument a Bundle.
      * 
      * @param <T> the type of the component implementation class on which the callback is invoked on.
-     * @param add the method reference invoked when a bundle is added.
-     * @param change the method reference invoked when a bundle has changed.
      * @param remove the method reference invoked when a bundle is removed.
      * @return this builder
      */
-    <T> BundleDependencyBuilder cb(CbTypeBundle<T> add, CbTypeBundle<T> change, CbTypeBundle<T> remove);
-    
+    <T> BundleDependencyBuilder remove(CbBundle<T> remove);
+
     /**
      * Sets a <code>callback</code> method reference which is invoked when a bundle is added.
-     * The method reference must point to a Component implementation class method, and take as argument a Component and a Bundle.
+     * The method reference must point to a Component implementation class method, and takes as argument a Bundle and a Component.
      * 
      * @param <T> the type of the component implementation class on which the callback is invoked on.
      * @param add the method reference invoked when a bundle is added.
      * @return this builder
      */
-    <T> BundleDependencyBuilder cb(CbTypeComponentBundle<T> add); 
+    <T> BundleDependencyBuilder add(CbBundleComponent<T> add); 
     
     /**
-     * Sets some <code>callback</code> method references which are invoked when a bundle is added, or removed.
-     * The method references must point to a Component implementation class method, and take as argument a Component and a Bundle.
+     * Sets a <code>callback</code> method reference which is invoked when a bundle is changed.
+     * The method reference must point to a Component implementation class method, and takes as argument a Bundle and a Component.
      * 
      * @param <T> the type of the component implementation class on which the callback is invoked on.
-     * @param add the method reference invoked when a bundle is added.
-     * @param remove the method reference invoked when a bundle is removed.
+     * @param change the method reference invoked when a bundle has changed.
      * @return this builder
      */
-    <T> BundleDependencyBuilder cb(CbTypeComponentBundle<T> add, CbTypeComponentBundle<T> remove); 
-    
+    <T> BundleDependencyBuilder change(CbBundleComponent<T> change); 
+ 
     /**
-     * Sets some <code>callback</code> method references which are invoked when a bundle is added, changed or removed.
-     * The method references must point to a Component implementation class method, and take as argument a Component and a Bundle.
+     * Sets a <code>callback</code> method reference which is invoked when a bundle is removed.
+     * The method reference must point to a Component implementation class method, and takes as argument a Bundle and a Component.
      * 
      * @param <T> the type of the component implementation class on which the callback is invoked on.
-     * @param add the method reference invoked when a bundle is added.
-     * @param change the method reference invoked when a bundle has changed.
      * @param remove the method reference invoked when a bundle is removed.
      * @return this builder
      */
-    <T> BundleDependencyBuilder cb(CbTypeComponentBundle<T> add, CbTypeComponentBundle<T> change, CbTypeComponentBundle<T> remove); 
- 
+    <T> BundleDependencyBuilder remove(CbBundleComponent<T> remove); 
+    
     /**
-     * Sets a <code>callback instance</code> method reference which is invoked when a bundle is added. 
+     * Sets a method reference on an Object instance which is invoked when a bundle is added. 
      * The method reference must point to an Object instance method, and takes as argument a Bundle parameter.
      * 
      * @param add the method reference invoked when a bundle is added.
      * @return this builder
      */
-    BundleDependencyBuilder cbi(CbBundle add);
+    BundleDependencyBuilder add(InstanceCbBundle add);
     
     /**
-     * Sets some <code>callback instance</code> method references which are invoked when a bundle is added or removed. 
-     * The method references must point to an Object instance method, and take as argument a Bundle parameter.
+     * Sets a method reference on an Object instance which is invoked when a bundle is changed. 
+     * The method reference must point to an Object instance method, and takes as argument a Bundle parameter.
      * 
-     * @param add the method reference invoked when a bundle is added.
-     * @param remove the method reference invoked when a bundle is removed.
+     * @param change the method reference invoked when a bundle is changed.
      * @return this builder
      */
-    BundleDependencyBuilder cbi(CbBundle add, CbBundle remove);
+    BundleDependencyBuilder change(InstanceCbBundle change);
     
     /**
-     * Sets some <code>callback instance</code> method references which are invoked when a bundle is added, changed or removed.
-     * The method references must point to an Object instance method, and take as argument a Bundle parameter.
+     * Sets a method reference on an Object instance which is invoked when a bundle is removed. 
+     * The method reference must point to an Object instance method, and takes as argument a Bundle parameter.
      * 
-     * @param add the method reference invoked when a bundle is added.
-     * @param change the method reference invoked when a bundle has changed.
      * @param remove the method reference invoked when a bundle is removed.
      * @return this builder
      */
-    BundleDependencyBuilder cbi(CbBundle add, CbBundle change, CbBundle remove);
+    BundleDependencyBuilder remove(InstanceCbBundle remove);
 
     /**
      * Sets a <code>callback instance</code> method reference which is invoked when a bundle is added. 
-     * The method reference must point to an Object instance method, and takes as arguments a Component and a Bundle.
+     * The method reference must point to an Object instance method, and takes as arguments a Bundle and a Component.
      * 
      * @param add the method reference invoked when a bundle is added.
      * @return this builder
      */
-    BundleDependencyBuilder cbi(CbComponentBundle add);
+    BundleDependencyBuilder add(InstanceCbBundleComponent add);
     
     /**
-     * Sets some <code>callback instance</code> method references which are invoked when a bundle is added or removed. 
-     * The method references must point to an Object instance method, and take as argument a Component and a Bundle.
+     * Sets a <code>callback instance</code> method reference which is invoked when a bundle is changed. 
+     * The method reference must point to an Object instance method, and takes as argument a Bundle and a Component.
      * 
-     * @param add the method reference invoked when a bundle is added.
-     * @param remove the method reference invoked when a bundle is removed.
+     * @param change the method reference invoked when a bundle is changed.
      * @return this builder
      */
-    BundleDependencyBuilder cbi(CbComponentBundle add, CbComponentBundle remove);
+    BundleDependencyBuilder change(InstanceCbBundleComponent change);
     
     /**
-     * Sets some <code>callback instance</code> method references which are invoked when a bundle is added, changed or removed.
-     * The method references must point to an Object instance method, and take as argument a Component and a Bundle.
+     * Sets a <code>callback instance</code> method reference which is invoked when a bundle is removed. 
+     * The method reference must point to an Object instance method, and takes as argument a Bundle and a Component.
      * 
-     * @param add the method reference invoked when a bundle is added.
-     * @param change the method reference invoked when a bundle has changed.
      * @param remove the method reference invoked when a bundle is removed.
      * @return this builder
      */
-    BundleDependencyBuilder cbi(CbComponentBundle add, CbComponentBundle change, CbComponentBundle remove);    
+    BundleDependencyBuilder remove(InstanceCbBundleComponent remove);    
 }

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java?rev=1731147&r1=1731146&r2=1731147&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java Thu Feb 18 21:07:16 2016
@@ -8,9 +8,10 @@ import java.util.function.Supplier;
 import java.util.stream.Stream;
 
 import org.apache.felix.dm.Component;
+import org.apache.felix.dm.lambda.callbacks.Cb;
 import org.apache.felix.dm.lambda.callbacks.CbComponent;
-import org.apache.felix.dm.lambda.callbacks.CbConsumer;
-import org.apache.felix.dm.lambda.callbacks.CbTypeComponent;
+import org.apache.felix.dm.lambda.callbacks.InstanceCb;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbComponent;
 
 /**
  * Builds a Dependency Manager Component. Components are the main building blocks for OSGi applications. 
@@ -25,8 +26,8 @@ import org.apache.felix.dm.lambda.callba
  * 
  * <pre>{@code
  * public class Activator extends DependencyManagerActivator {
- *   public void activate() throws Exception {
- *       component(comp -> comp.impl(Configurator.class).withSrv(ConfigurationAdmin.class));
+ *   public void init(BundleContext ctx, DependencyManager dm) throws Exception {
+ *       component(comp -> comp.impl(Configurator.class).withSvc(ConfigurationAdmin.class));
  *   }
  * }
  * } </pre>
@@ -35,6 +36,7 @@ import org.apache.felix.dm.lambda.callba
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
 public interface ComponentBuilder<B extends ComponentBuilder<B>> {
+    
     /**
      * Configures the component implementation. Can be a class name, or a component implementation object.
      * 
@@ -84,8 +86,9 @@ public interface ComponentBuilder<B exte
     <U, V> B factory(Supplier<U> factory, Function<U, V> create);
         
     /**
-     * Configures a factory used to create this component implementation using a Factory object and a "getComponent" factory method.
-     * the Factory method may then return multiple objects that will be part of this component implementation.
+     * Configures a factory used to create this component implementation using a Factory object and a "getComposition" factory method.
+     * the Factory method may then return multiple objects that will be part of this component implementation, and 
+     * all of them will be searched for injecting any of the dependencies.
      * 
      * Example:
      * 
@@ -110,8 +113,9 @@ public interface ComponentBuilder<B exte
      * factory(CompositionManager::new, CompositionManager::create, CompositionManager::getComposition).
      * }</pre>
      * 
-     * Here, the CompositionManager will act as a factory (the create method will return the component implementation object), and the
-     * CompositionManager.getComposition() method will return all the objects that are also part of the component implementation.
+     * Here, the CompositionManager will act as a factory (the create method will return the component implementation object), the
+     * CompositionManager.getComposition() method will return all the objects that are also part of the component implementation, 
+     * and all of them will be searched for injecting any of the dependencies.
      * 
      * @param <U> the type of the object returned by the supplier factory
      * @param factory the function used to create the Factory itself
@@ -122,9 +126,9 @@ public interface ComponentBuilder<B exte
     <U> B factory(Supplier<U> factory, Function<U, ?> create, Function<U, Object[]> getComposition);
 
     /**
-     * Sets the public interfaces under which this component should be registered in the OSGi service registry.
+     * Sets the public interface under which this component should be registered in the OSGi service registry.
      * 
-     * @param iface the public interfaces to register in the OSGI service registry.
+     * @param iface the public interface to register in the OSGI service registry.
      * @return this builder
      */
 	B provides(Class<?>  iface);
@@ -132,7 +136,7 @@ public interface ComponentBuilder<B exte
 	/**
      * Sets the public interface under which this component should be registered in the OSGi service registry.
      * 
-     * @param iface the public interfaces to register in the OSGI service registry.
+     * @param iface the public interface to register in the OSGI service registry.
 	 * @param name a property name for the provided service
 	 * @param value a property value for the provided service
 	 * @param rest the rest of property name/value pairs.
@@ -150,7 +154,7 @@ public interface ComponentBuilder<B exte
      *  provides(MyService.class, property1 -> "value1", property2 -> 123);
      * }</pre>
      *
-     * @param iface the public interfaces to register in the OSGI service registry.
+     * @param iface the public interface to register in the OSGI service registry.
 	 * @param properties a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the
 	 * {@link FluentProperty} interface that allows to define a property name using a lambda parameter.
      * @return this builder.
@@ -159,7 +163,7 @@ public interface ComponentBuilder<B exte
 	
 	/**
      * Sets the public interface under which this component should be registered in the OSGi service registry.
-     * @param iface the public interfaces to register in the OSGI service registry.
+     * @param iface the public interface to register in the OSGI service registry.
 	 * @param properties the properties for the provided service
      * @return this builder.
 	 */
@@ -202,6 +206,7 @@ public interface ComponentBuilder<B exte
     
     /**
      * Sets the public interfaces under which this component should be registered in the OSGi service registry.
+     * 
      * @param ifaces the public interfaces to register in the OSGI service registry.
      * @param properties the properties for the provided service
      * @return this builder.
@@ -219,7 +224,7 @@ public interface ComponentBuilder<B exte
     /**
      * Sets the public interface under which this component should be registered in the OSGi service registry.
      * 
-     * @param iface the public interfaces to register in the OSGI service registry.
+     * @param iface the public interface to register in the OSGI service registry.
      * @param name a property name for the provided service
      * @param value a property value for the provided service
      * @param rest the rest of property name/value pairs.
@@ -236,7 +241,7 @@ public interface ComponentBuilder<B exte
      * provides(MyService.class, property1 -> "value1", property2 -> 123);
      * }</pre>
      *
-     * @param iface the public interfaces to register in the OSGI service registry.
+     * @param iface the public interface to register in the OSGI service registry.
      * @param properties a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the
      * {@link FluentProperty} interface that allows to define a property name using a lambda parameter.
      * @return this builder.
@@ -245,7 +250,7 @@ public interface ComponentBuilder<B exte
     
     /**
      * Sets the public interface under which this component should be registered in the OSGi service registry.
-     * @param iface the public interfaces to register in the OSGI service registry.
+     * @param iface the public interface to register in the OSGI service registry.
      * @param properties the properties for the provided service
      * @return this builder.
      */
@@ -288,6 +293,7 @@ public interface ComponentBuilder<B exte
     
     /**
      * Sets the public interfaces under which this component should be registered in the OSGi service registry.
+     * 
      * @param ifaces the public interfaces to register in the OSGI service registry.
      * @param properties the properties for the provided service
      * @return this builder.
@@ -339,14 +345,14 @@ public interface ComponentBuilder<B exte
      * @param filter the service filter
      * @return this builder
      */
-    B withSrv(Class<?> service, String filter);
+    B withSvc(Class<?> service, String filter);
 
     /**
      * Adds in one shot multiple required/autoconfig service dependencies.
      * @param services the dependencies that are required and that will be injected in any field with the same dependency type.
      * @return this builder
      */
-    B withSrv(Class<?> ... services);
+    B withSvc(Class<?> ... services);
            
     /**
      * Adds a service dependency built using a Consumer lambda that is provided with a ServiceDependencyBuilder. 
@@ -356,7 +362,7 @@ public interface ComponentBuilder<B exte
      * @param consumer the lambda for building the service dependency
      * @return this builder.
      */
-    <U> B withSrv(Class<U> service, Consumer<ServiceDependencyBuilder<U>> consumer);
+    <U> B withSvc(Class<U> service, Consumer<ServiceDependencyBuilder<U>> consumer);
     
     /**
      * Adds a configuration dependency.
@@ -377,17 +383,6 @@ public interface ComponentBuilder<B exte
     }
     
     /**
-     * Adds multiple configuration dependencies in one single call. 
-     * @param pids list of configuration pids
-     * @return this builder
-     */
-    @SuppressWarnings("unchecked")
-    default B withCnf(Class<?> ... pids) {
-        Stream.of(pids).forEach(pid -> withCnf(cnf -> cnf.pid(pid)));
-        return (B) this;
-    }
-
-    /**
      * Adds a bundle dependency.
      * @param consumer the lambda used to build the bundle dependency.
      * @return this builder.
@@ -405,6 +400,25 @@ public interface ComponentBuilder<B exte
     <U> B withFuture(CompletableFuture<U> future, Consumer<FutureDependencyBuilder<U>> consumer);
     
     /**
+     * Sets the instance to invoke with the reflection based lifecycle callbacks. By default, reflection based 
+     * lifecycle callbacks (init/start/stop/destroy) methods are invoked on the component implementation instance(s).
+     * But you can set a specific callback instance using this method.
+     * <p>
+     * Specifying an instance means you can create a manager
+     * that will be invoked whenever the life cycle of a component changes and this manager
+     * can then decide how to expose this life cycle to the actual component, offering an
+     * important indirection when developing your own component models.
+     * 
+     * @see #init(String) 
+     * @see #start(String)
+     * @see #stop(String)
+     * @see #destroy(String)
+     * @param lifecycleCallbackInstance the instance the lifecycle callback will be invoked on.
+     * @return this builder.
+     */
+    B lifecycleCallbackInstance(Object lifecycleCallbackInstance);
+    
+    /**
      * Sets the name of the method used as the "init" callback. This method, when found, is
      * invoked as part of the life cycle management of the component implementation. 
      * This method is useful because when it is invoked, all required dependencies defines in the Activator
@@ -466,165 +480,100 @@ public interface ComponentBuilder<B exte
      * @return this builder.
      */
     B destroy(String callback);
-    
+         
     /**
-     * Sets the name of the methods used as init callback that is invoked on a given Object instance. 
-     * These methods, when found, are invoked on the specified instance as part of the life cycle management 
-     * of the component implementation.
-     * <p>
-     * Specifying an instance means you can create a manager
-     * that will be invoked whenever the life cycle of a component changes and this manager
-     * can then decide how to expose this life cycle to the actual component, offering an
-     * important indirection when developing your own component models.
-     * 
-     * @see #init(String)
-     * @param callbackInstance the instance the callback will be invoked on.
-     * @param callback the callback name
-     * @return this builder.
-     */
-    B init(Object callbackInstance, String callback);
-    
-    /**
-     * Sets the name of the methods used as start callback that is invoked on a given Object instance. 
-     * These methods, when found, are invoked on the specified instance as part of the life cycle management 
-     * of the component implementation.
-     * <p>
-     * Specifying an instance means you can create a manager
-     * that will be invoked whenever the life cycle of a component changes and this manager
-     * can then decide how to expose this life cycle to the actual component, offering an
-     * important indirection when developing your own component models.
-     * 
-     * @see #start(String)
-     * @param callbackInstance the instance the callback will be invoked on.
-     * @param callback the name of the start method
-     * @return this builder.
-     */
-    B start(Object callbackInstance, String callback);
-   
-    /**
-     * Sets the name of the methods used as stop callback that is invoked on a given Object instance. 
-     * These methods, when found, are invoked on the specified instance as part of the life cycle management 
-     * of the component implementation.
-     * <p>
-     * Specifying an instance means you can create a manager
-     * that will be invoked whenever the life cycle of a component changes and this manager
-     * can then decide how to expose this life cycle to the actual component, offering an
-     * important indirection when developing your own component models.
-     * 
-     * @see #stop(String)
-     * @param callbackInstance the instance the callback will be invoked on.
-     * @param callback the name of the stop method
-     * @return this builder.
-     */
-    B stop(Object callbackInstance, String callback);
-  
-    /**
-     * Sets the name of the methods used as destroy callback that is invoked on a given Object instance. 
-     * These methods, when found, are invoked on the specified instance as part of the life cycle management 
-     * of the component implementation.
-     * <p>
-     * Specifying an instance means you can create a manager
-     * that will be invoked whenever the life cycle of a component changes and this manager
-     * can then decide how to expose this life cycle to the actual component, offering an
-     * important indirection when developing your own component models.
-     * 
-     * @see #destroy(String)
-     * @param callbackInstance the instance the callback will be invoked on.
-     * @param callback the name of the destroy method
-     * @return this builder.
-     */
-    B destroy(Object callbackInstance, String callback);
-
-    /**
-     * Sets a method reference used as the "init" callback. This method reference must point to method from one 
-     * of the component instance classes. It is invoked as part of the life cycle management of the component implementation. 
+     * Sets a reference to a component implementation class "init" callback method. 
+     * This method does not take any arguments and is 
+     * invoked as part of the life cycle management of the component implementation. 
      * This method is useful because when it is invoked, all required dependencies defines in the Activator
      * are already injected, and you can then add more extra dependencies from the init() method.
      * And once all extra dependencies will be available and injected, then the "start" callback will be invoked.
-     * The method does not take any parameters.
      * 
-     * @param <U> the type of the component class on which the callback is invoked on.
-     * @param callback a method reference must point to method from one of the component instance classes.
+     * @param <T> the type of the component class on which the callback is invoked on.
+     * @param callback a method reference must point to method from the component instance class(es).
      * @return this builder
      */
-    <U> B init(CbConsumer<U> callback);
+    <T> B init(Cb<T> callback);
   
     /**
-     * Sets a method reference used as the "start" callback. This method reference must point to method from one 
-     * of the component instance classes. This method is invoked as part of the life cycle management of the component implementation. 
+     * Sets a reference to a component implementation class "start" callback method. 
+     * This method does not take any arguments and is 
+     * invoked as part of the life cycle management of the component implementation.
      * 
-     * @param <U> the type of the component class on which the callback is invoked on.
+     * @param <T> the type of the component class on which the callback is invoked on.
      * @param callback  a method reference must point to method from one of the component instance classes.
      * @return this builder.
      */
-    <U> B start(CbConsumer<U> callback);
+    <T> B start(Cb<T> callback);
    
     /**
-     * Sets a method reference used as the "stop" callback. This method reference must point to method from one 
-     * of the component instance classes. This method is invoked as part of the life cycle management of the component implementation. 
+     * Sets a reference to a component implementation class "stop" callback method. 
+     * This method does not take any arguments and is 
+     * invoked as part of the life cycle management of the component implementation.
      * 
-     * @param <U> the type of the component class on which the callback is invoked on.
+     * @param <T> the type of the component class on which the callback is invoked on.
      * @param callback  a method reference must point to method from one of the component instance classes.
      * @return this builder.
      */
-    <U> B stop(CbConsumer<U> callback);
+    <T> B stop(Cb<T> callback);
   
     /**
-     * Sets a method reference used as the "destroy" callback. This method reference must point to method from one 
-     * of the component instance classes. This method is invoked as part of the life cycle management of the component implementation. 
+     * Sets a reference to a component implementation class "destroy" callback method. 
+     * This method does not take any arguments and is 
+     * invoked as part of the life cycle management of the component implementation.
      * 
-     * @param <U> the type of the component class on which the callback is invoked on.
+     * @param <T> the type of the component class on which the callback is invoked on.
      * @param callback  a method reference must point to method from one of the component instance classes.
      * @return this builder.
      */
-    <U> B destroy(CbConsumer<U> callback);
+    <T> B destroy(Cb<T> callback);
 
     /**
-     * Sets a method reference used as the "init" callback. This method reference must point to method from one 
-     * of the component instance classes. It is invoked as part of the life cycle management of the component implementation. 
+     * Sets a reference to a component implementation class "init" callback method. 
+     * This method takes a Component argument and is  
+     * invoked as part of the life cycle management of the component implementation. 
      * This method is useful because when it is invoked, all required dependencies defines in the Activator
      * are already injected, and you can then add more extra dependencies from the init() method.
      * And once all extra dependencies will be available and injected, then the "start" callback will be invoked.
-     * The method takes as argument a Component parameter.
      * 
-     * @param <U> the type of the component class on which the callback is invoked on.
+     * @param <T> the type of the component class on which the callback is invoked on.
      * @param callback a method reference must point to method from one of the component instance classes. The method takes as argument a Component parameter.
      * @return this builder
      */
-    <U> B init(CbTypeComponent<U> callback);
+    <T> B init(CbComponent<T> callback);
     
     /**
-     * Sets a method reference used as the "start" callback. This method reference must point to method from one 
-     * of the component instance classes. This method is invoked as part of the life cycle management of the component implementation. 
-     * The method takes as argument a Component parameter.
+     * Sets a reference to a component implementation class "start" callback method. 
+     * This method takes a Component argument and is  
+     * invoked as part of the life cycle management of the component implementation.
      * 
-     * @param <U> the type of the component class on which the callback is invoked on.
+     * @param <T> the type of the component class on which the callback is invoked on.
      * @param callback a method reference must point to method from one of the component instance classes. The method takes as argument a Component parameter.
      * @return this builder.
      */
-    <U> B start(CbTypeComponent<U> callback);
+    <T> B start(CbComponent<T> callback);
   
     /**
-     * Sets a method reference used as the "stop" callback. This method reference must point to method from one 
-     * of the component instance classes. This method is invoked as part of the life cycle management of the component implementation. 
-     * The method takes as argument a Component parameter.
+     * Sets a reference to a component implementation class "stop" callback method. 
+     * This method takes a Component argument and is  
+     * invoked as part of the life cycle management of the component implementation.
      * 
-     * @param <U> the type of the component class on which the callback is invoked on.
+     * @param <T> the type of the component class on which the callback is invoked on.
      * @param callback a method reference must point to method from one of the component instance classes. The method takes as argument a Component parameter.
      * @return this builder.
      */
-    <U> B stop(CbTypeComponent<U> callback);
+    <T> B stop(CbComponent<T> callback);
   
     /**
-     * Sets a method reference used as the "destroy" callback. This method reference must point to method from one 
-     * of the component instance classes. This method is invoked as part of the life cycle management of the component implementation. 
-     * The method takes as argument a Component parameter.
+     * Sets a reference to a component implementation class "destroy" callback method. 
+     * This method takes a Component argument and is  
+     * invoked as part of the life cycle management of the component implementation.
      * 
-     * @param <U> the type of the component class on which the callback is invoked on.
+     * @param <T> the type of the component class on which the callback is invoked on.
      * @param callback a method reference must point to method from one of the component instance classes. The method takes as argument a Component parameter.
      * @return this builder.
      */
-    <U> B destroy(CbTypeComponent<U> callback);
+    <T> B destroy(CbComponent<T> callback);
 
     /**
      * Sets an Object instance method reference used as the "init" callback. It is invoked as part of the life cycle management of the component 
@@ -637,7 +586,7 @@ public interface ComponentBuilder<B exte
      * @param callback an Object instance method reference. The method does not take any parameters.
      * @return this builder
      */
-    B initInstance(Runnable callback);
+    B initInstance(InstanceCb callback);
  
     /**
      * Sets an Object instance method reference used as the "start" callback. This method reference must point to method from one 
@@ -647,7 +596,7 @@ public interface ComponentBuilder<B exte
      * @param callback an Object instance method reference. The method does not take any parameters.
      * @return this builder.
      */
-    B startInstance(Runnable callback);
+    B startInstance(InstanceCb callback);
   
     /**
      * Sets an Object instance method reference used as the "stop" callback. It is invoked as part of the life cycle management of the component 
@@ -660,7 +609,7 @@ public interface ComponentBuilder<B exte
      * @param callback an Object instance method reference. The method does not take any parameters.
      * @return this builder
      */
-    B stopInstance(Runnable callback);
+    B stopInstance(InstanceCb callback);
   
     /**
      * Sets an Object instance method reference used as the "destroy" callback. It is invoked as part of the life cycle management of the component 
@@ -673,7 +622,7 @@ public interface ComponentBuilder<B exte
      * @param callback an Object instance method reference. The method does not take any parameters.
      * @return this builder
      */
-    B destroyInstance(Runnable callback);
+    B destroyInstance(InstanceCb callback);
 
     /**
      * Sets an Object instance method reference used as the "init" callback. It is invoked as part of the life cycle management of the component 
@@ -683,10 +632,10 @@ public interface ComponentBuilder<B exte
      * And once all extra dependencies will be available and injected, then the "start" callback will be invoked.
      * The method takes as argument a Component parameter.
      * 
-     * @param callback an Object instance method reference.
+     * @param callback an Object instance method reference. The method takes as argument a Component parameter.
      * @return this builder
      */
-    B initInstance(CbComponent callback);
+    B initInstance(InstanceCbComponent callback);
    
     /**
      * Sets an Object instance method reference used as the "start" callback. This method reference must point to method from one 
@@ -696,7 +645,7 @@ public interface ComponentBuilder<B exte
      * @param callback an Object instance method reference. The method takes as argument a Component parameter.
      * @return this builder.
      */
-    B startInstance(CbComponent callback);
+    B startInstance(InstanceCbComponent callback);
     
     /**
      * Sets an Object instance method reference used as the "stop" callback. This method reference must point to method from one 
@@ -706,7 +655,7 @@ public interface ComponentBuilder<B exte
      * @param callback an Object instance method reference. The method takes as argument a Component parameter.
      * @return this builder.
      */
-    B stopInstance(CbComponent callback);
+    B stopInstance(InstanceCbComponent callback);
   
     /**
      * Sets an Object instance method reference used as the "destroy" callback. This method reference must point to method from one 
@@ -716,7 +665,7 @@ public interface ComponentBuilder<B exte
      * @param callback an Object instance method reference. The method takes as argument a Component parameter.
      * @return this builder.
      */
-    B destroyInstance(CbComponent callback);
+    B destroyInstance(InstanceCbComponent callback);
 
     /**
      * Configures OSGi object (BundleContext, Component, etc ...) that will be injected in any field having the same OSGi object type.
@@ -753,7 +702,7 @@ public interface ComponentBuilder<B exte
     /**
      * Sets the method to invoke on the service implementation to get back all
      * instances that are part of a composition and need dependencies injected.
-     * All of them will be searched for any of the dependencies. The method that
+     * All of them will be searched to inject any of the dependencies. The method that
      * is invoked must return an <code>Object[]</code>.
      * 
      * @param getCompositionMethod the method to invoke
@@ -764,7 +713,7 @@ public interface ComponentBuilder<B exte
     /**
      * Sets the instance and method to invoke to get back all instances that
      * are part of a composition and need dependencies injected. All of them
-     * will be searched for any of the dependencies. The method that is
+     * will be searched to inject any of the dependencies. The method that is
      * invoked must return an <code>Object[]</code>.
      * 
      * @param instance the instance that has the method



Mime
View raw message