You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by pd...@apache.org on 2016/01/28 00:27:36 UTC

svn commit: r1727214 [3/6] - 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/depende...

Added: 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=1727214&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java (added)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java Wed Jan 27 23:27:34 2016
@@ -0,0 +1,491 @@
+package org.apache.felix.dm.lambda;
+
+import java.util.Dictionary;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import java.util.stream.Stream;
+
+import org.apache.felix.dm.Component;
+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.FluentProperties;
+
+/**
+ * Component builder. This interface is also the base interface for extended components like aspects, adapters, etc ...
+ *
+ * @param <B> the concrete builder that may extends this class (aspect, adapter, etc ...).
+ */
+public interface ComponentBuilder<B extends ComponentBuilder<B>> {
+    /**
+     * Configures the component implementation. Can be a class name, or a component implementation object.
+     * @param impl the component implementation (a class, or an Object).
+     * @return this builder
+     */
+    <U> B impl(U impl);   
+    
+    /**
+     * Configures the component implementation.
+     * @param impl the component implementation class name, used when instantiating the component.
+     * @return this builder
+     */
+    <U> B impl(Class<U> implClass);   
+
+    /**
+     * Sets the factory to use to create the implementation. You can specify both the factory class and method to invoke. The method should return the implementation, 
+     * and can use any method to create it. Actually, this can be used together with setComposition to create a composition of instances that work together to implement 
+     * a component. The factory itself can also be instantiated lazily by not specifying an instance, but a Class. 
+     * 
+     * @param factory the factory instance, or the factory class.
+     * @param createMethod the create method called on the factory in order to instantiate the component instance.
+     * @return this builder
+     */
+    B factory(Object factory, String createMethod);
+        
+    /**
+     * Configures a factory that can be used to create this component implementation.
+     * Example: "factory(ComponentImpl::new)", or "factory(() -> new ComponentImpl())".
+     * 
+     * @param create the factory used to create the component implementation.
+     * @return this builder
+     */
+    <U> B factory(Supplier<U> create);
+    
+    /**
+     * Configures a factory used to create this component implementation using a Factory object and a method in the Factory object.
+     * Example:
+     * 
+     * factory(Factory::new, Factory::create)
+     * 
+     * @param factory the function used to create the Factory itself
+     * @param create the method reference on the Factory method that is used to create the Component implementation
+     * @return this builder
+     */
+    <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.
+     * 
+     * Example:
+     * 
+     * CompositionManager mngr = new CompositionManager();
+     * ...
+     * factory(mngr::create, mngr::getComposition)
+     * 
+     * @param factory
+     * @param getComposition
+     * @return this builder
+     */
+    <U> B factory(Supplier<U> factory, Supplier<Object[]> getComposition);
+
+    /**
+     * Configures a factory that also returns a composition of objects for this component implemenation.
+     * 
+     * Example:
+     * 
+     * factory(CompositionManager::new, CompositionManager::create, CompositionManager::getComposition).
+     * 
+     * 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.
+     * 
+     * @param factory the function used to create the Factory itself
+     * @param create the Factory method used to create the main component implementation object
+     * @param getComposition the Factory method used to return the list of objects that are also part of the component implementation.
+     * @return this builder
+     */
+    <U, V> B factory(Supplier<U> factory, Function<U, V> create, Function<U, Object[]> getComposition);
+
+    /**
+     * Sets the public interfaces under which this component should be registered in the OSGi service registry.
+     * @param iface the public interfaces to register in the OSGI service registry.
+     * @return this builder
+     */
+	B provides(Class<?>  iface);
+	
+	/**
+     * 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 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.
+	 * @return this builder.
+	 */
+	B provides(Class<?>  iface, String name, Object value, Object ... rest);
+	
+	/**
+     * 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 properties a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the
+	 * {@link FluentProperties} interface that allows to define a property name using a lambda parameter.
+	 * 
+	 * Warning: you can only use this method if you compile your application using the "-parameters" javac option.
+	 * 
+	 * code example:
+	 * 
+	 * provides(MyService.class, property1 -> "value1", property2 -> 123);
+     *
+     * @return this builder.
+	 */
+	B provides(Class<?>  iface, FluentProperties ... properties);
+	
+	/**
+     * 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 properties the properties for the provided service
+     * @return this builder.
+	 */
+    B provides(Class<?>  iface, Dictionary<?,?> properties);
+    
+    /**
+     * Sets the public interfaces under which this component should be registered in the OSGi service registry.
+     * @return this builder.
+     */
+    B provides(Class<?>[] ifaces);
+    
+    /**
+     * Sets the public interfaces 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 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.
+     * @return this builder.
+     */
+    B provides(Class<?>[] ifaces, String name, Object value, Object ... rest);
+    
+    /**
+     * Sets the public interfaces 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 properties a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the
+     * {@link FluentProperties} interface that allows to define a property name using a lambda parameter.
+     * 
+     * Warning: you can only use this method if you compile your application using the "-parameters" javac option.
+     * 
+     * code example:
+     * 
+     * provides(new Class[] { MyService.class, MyService2.class }, property1 -> "value1", property2 -> 123);
+     *
+     * @return this builder.
+     */
+    B provides(Class<?>[] ifaces, FluentProperties ... properties);
+    
+    /**
+     * Sets the public interfaces 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 properties the properties for the provided service
+     * @return this builder.
+     */
+    B provides(Class<?>[] ifaces, Dictionary<?,?> properties);
+
+    /**
+     * Sets the public interface under which this component should be registered in the OSGi service registry.
+     * @return this builder.
+     */
+    B provides(String iface);
+    
+    /**
+     * 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 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.
+     * @return this builder.
+     */
+    B provides(String iface, String name, Object value, Object ... rest);
+    
+    /**
+     * 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 properties a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the
+     * {@link FluentProperties} interface that allows to define a property name using a lambda parameter.
+     * 
+     * Warning: you can only use this method if you compile your application using the "-parameters" javac option.
+     * 
+     * code example:
+     * 
+     * provides(MyService.class, property1 -> "value1", property2 -> 123);
+     *
+     * @return this builder.
+     */
+    B provides(String iface, FluentProperties ... properties);
+    
+    /**
+     * 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 properties the properties for the provided service
+     * @return this builder.
+     */
+    B provides(String iface, Dictionary<?,?> properties);
+    
+    /**
+     * Sets the public interfaces under which this component should be registered in the OSGi service registry.
+     * @return this builder.
+     */
+    B provides(String[] ifaces);
+    
+    /**
+     * Sets the public interfaces 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 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.
+     * @return this builder.
+     */
+    B provides(String[] ifaces, String name, Object value, Object ... rest);
+    
+    /**
+     * Sets the public interfaces 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 properties a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the
+     * {@link FluentProperties} interface that allows to define a property name using a lambda parameter.
+     * 
+     * Warning: you can only use this method if you compile your application using the "-parameters" javac option.
+     * 
+     * code example:
+     * 
+     * provides(new Class[] { MyService.class, MyService2.class }, property1 -> "value1", property2 -> 123);
+     *
+     * @return this builder.
+     */
+    B provides(String[] ifaces, FluentProperties ... properties);
+    
+    /**
+     * Sets the public interfaces 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 properties the properties for the provided service
+     * @return this builder.
+     */
+    B provides(String[] ifaces, Dictionary<?,?> properties);
+
+    /**
+     * Sets the component's service properties
+     * @param properties the component's service properties
+     * @return this builder
+     */
+    B properties(Dictionary<?,?> properties);     
+    
+    /**
+     * Sets the components's service properties using varargs. The number of parameters must be even, representing a list of pair property key-value.
+     * @param properties a varargs representing a list of key-value pairs.
+     * 
+     * Example: properties("param1", "value1", "service.ranking", 3)
+     * @return this builder
+     */
+    B properties(String name, Object value, Object ... rest);  
+    
+    /**
+     * Sets the components's service properties using List of lamda properties. 
+     * When you use this method, you must compile your source code using the "-parameters" option, and the "arg0" parameter
+     * name is now allowed.
+     *  
+     * Example: properties(param1 -> "value1, param2 -> 2);
+     * @return this builder
+     */
+    B properties(FluentProperties ... properties);  
+
+    /**
+     * Adds a required/autoconfig service dependency.
+     * @param service the service dependency filter
+     * @return this builder
+     */
+    B withSrv(Class<?> service, String filter);
+
+    /**
+     * Adds a required/autoconfig service dependency.
+     * @param service the dependency that is required and that will be injected in any field with the same dependency type.
+     * @return this builder
+     */
+    B withSrv(Class<?> ... services);
+           
+    /**
+     * Adds a service dependency.
+     * @param service the service
+     * @param consumer the lambda for building the service dependency
+     * @return this builder.
+     */
+    <U> B withSrv(Class<U> service, Consumer<ServiceDependencyBuilder<U>> consumer);
+    
+    /**
+     * Adds a configuration dependency.
+     * @param consumer the lambda used to build the configuration dependency.
+     * @return this builder.
+     */
+    B withCnf(Consumer<ConfigurationDependencyBuilder> consumer);     
+    
+    /**
+     * Adds multiple configuration dependencies in one single call. 
+     * @param pids list of configuration pids
+     * @return this builder
+     */
+    @SuppressWarnings("unchecked")
+    default B withCnf(String ... pids) {
+        Stream.of(pids).forEach(pid -> withCnf(cnf -> cnf.pid(pid)));
+        return (B) this;
+    }
+    
+    /**
+     * 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.
+     */
+    B withBundle(Consumer<BundleDependencyBuilder> consumer);        
+
+    /**
+     * Adds a CompletableFuture dependency.
+     * @param future a CompletableFuture on which the dependency will wait for
+     * @param consumer the builder used to build the dependency
+     * @return this builder.
+     */
+    <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.
+     * @return this builder.
+     */
+    B cb(ComponentCallback callbackType, 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);
+
+    /**
+     * 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.
+     * @return this builder
+     */
+    <U> B cb(ComponentCallback callbackType, 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.
+     * @return this builder
+     */
+    <U> B cb(ComponentCallback callbackType, 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.
+     * @return this builder
+     */
+    B cbi(ComponentCallback callbackType, 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.
+     * @return this builder.
+     */
+    B cbi(ComponentCallback callbackType, CbComponent callback);
+
+    /**
+     * Configures OSGi object (BundleContext, Component, etc ...) that will be injected in any field having the same OSGi object type.
+     * @param clazz the OSGi object type (BundleContext, Component, DependencyManager).
+     * @param autoConfig true if the OSGi object has to be injected, false if not
+     * @return this builder
+     */
+    <U> B autoConfig(Class<U> clazz, boolean autoConfig); 
+    
+    /**
+     * Configures OSGi object (BundleContext, Component, etc ...) that will be injected in a given field.
+     * @param clazz the OSGi object type (BundleContext, Component, DependencyManager).
+     * @param field the field that will be injected with the OSGI object
+     * @return this builder
+     */
+    <U> B autoConfig(Class<U> clazz, String field);
+    
+    /**
+     * Activates debug mode
+     * @param label the debug label
+     * @return this builder
+     */
+    B debug(String label);
+    
+    /**
+     * Automatically adds this component to its DependencyManager object
+     * @param autoAdd true for automatically adding this component to the DependencyManager object, false if not
+     * @return this builder
+     */
+    B autoAdd(boolean autoAdd);
+    
+    /**
+     * Is this component automatically added to its DependencyManager object ?
+     * @return this builder
+     */
+    B autoAdd();
+    
+    /**
+     * TODO
+     * @param method
+     * @return
+     */
+    B composition(String getCompositionMethod);
+    
+    /**
+     * TODO
+     * @param instance
+     * @param method
+     * @return
+     */
+    B composition(Object instance, String getCompositionMethod);
+
+    /**
+     * TODO
+     * @param getCompositionMethod
+     * @return
+     */
+    B composition(Supplier<Object[]> getCompositionMethod);
+
+    /**
+     * Builds the real DependencyManager Component.
+     * @return the real DependencyManager Component.
+     */
+    Component build();
+}

Added: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentCallback.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentCallback.java?rev=1727214&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentCallback.java (added)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentCallback.java Wed Jan 27 23:27:34 2016
@@ -0,0 +1,29 @@
+package org.apache.felix.dm.lambda;
+
+/**
+ * Defines the various types of possible component lifecycle callbacks
+ */
+public enum ComponentCallback {
+    /**
+     * The component has been injected with all required dependencies defined in the Activator, and the component init method
+     * is then called, where some extra runtime service dependencies can be dynamically added.
+     */
+    INIT, 
+    
+    /**
+     * All required dependency callbacks have been called, all optional service dependencies have been injected in class fields,
+     * and the component start callback is called. When the method returns, any services provided by the component will be registered
+     * in the OSGi service registry.
+     */
+    START,
+    
+    /**
+     * The component must stop because it has lost some required dependencies or the component bundle has been stopped.
+     */
+    STOP,
+    
+    /**
+     * The Component is destroyed.
+     */
+    DESTROY
+}

Added: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ConfigurationDependencyBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ConfigurationDependencyBuilder.java?rev=1727214&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ConfigurationDependencyBuilder.java (added)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ConfigurationDependencyBuilder.java Wed Jan 27 23:27:34 2016
@@ -0,0 +1,103 @@
+package org.apache.felix.dm.lambda;
+
+import org.apache.felix.dm.ConfigurationDependency;
+import org.apache.felix.dm.lambda.callbacks.CbComponentDictionary;
+import org.apache.felix.dm.lambda.callbacks.CbDictionary;
+import org.apache.felix.dm.lambda.callbacks.CbTypeComponentDictionary;
+import org.apache.felix.dm.lambda.callbacks.CbTypeDictionary;
+
+/**
+ * Defines a builder for a DM Configuration Dependency.
+ * By default, the updated callback is "updated", like in original DM API.
+ * 
+ * Code example with a component that defines a Configuration Dependency:
+ * 
+ * <pre> {@code
+ * public class Activator extends DependencyActivatorBase {
+ *     public void init() throws Exception { 
+ *         component(comp -> comp
+ *           .impl(ServiceImpl.class)
+ *           .withConf(conf -> conf.pid(ServiceConsumer.class).cb(ServiceImpl::modified)));  
+ *    }
+ * }</pre>
+ */
+public interface ConfigurationDependencyBuilder extends DependencyBuilder<ConfigurationDependency> { 
+    /**
+     * Specifies the pid for this configuration dependency.
+     * @param pid the configuration dependendency pid.
+     * @return this builder
+     */
+    ConfigurationDependencyBuilder pid(String pid);
+    
+    /**
+     * Specifies the class which fqdn represents the pid for this configuration dependency.
+     * @param pidClass the class which fqdn represents the pid for this configuration dependency.
+     * @return this builder
+     */
+    ConfigurationDependencyBuilder pid(Class<?> pidClass);
+    
+    /**
+     * Specifies that all public configuration properties are propagated to the component service properties (false by default).
+     * @return this builder
+     */
+    ConfigurationDependencyBuilder propagate();
+    
+    /**
+     * Specifies that all public configuration properties are propagated to the component service properties (false by default).
+     * @param propagate true if all public configuration properties must be propagated to the component service properties (false by default)
+     * @return this builder
+     */
+    ConfigurationDependencyBuilder propagate(boolean propagate);
+    
+    /**
+     * Specifies if the component instance should be instantiated at the time the updated callback is invoked. 
+     * By default, when the callback is applied on an external object instance, the component is not instantiated, but in this case
+     * you can force the creation of the component instances by calling this method.
+     * @param needsInstance true if the component instance should be instantiated at the time the updated callback is invoked on an external object instance.
+     * @return this builder
+     */
+    ConfigurationDependencyBuilder needsInstance(boolean needsInstance);
+    
+    /**
+     * Specifies the callback to call on the component instance(s) when the configuration is updated.
+     * @param updateMethod the callback to call on the component instance(s) when the configuration is updated.
+     * @return this builder
+     */
+    ConfigurationDependencyBuilder cb(String updateMethod);
+    
+    /**
+     * Specifies the callback instance to call on a given object instance when the configuration is updated.
+     * @param callbackInstance the object instance on which the updatedMethod is invoked
+     * @param updateMethod the callback to call on the callbackInstance when the configuration is updated.
+     * @return this builder
+     */
+    ConfigurationDependencyBuilder cbi(Object callbackInstance, String updateMethod);
+
+    /**
+     * Specifies the callback method reference used to invoke an update method on the component instance(s) when the configuration is updated.
+     * @param updateMethod the callback method reference used to invoke an update method on the component instance(s) when the configuration is updated.
+     * @return this builder
+     */
+    <T> ConfigurationDependencyBuilder cb(CbTypeDictionary<T> callback);
+    
+    /**
+     * Specifies the callback instance method reference used to invoke an update method on a given object instance when the configuration is updated.
+     * @param updateMethod the callback instance method reference used to invoke an update method on a given object instance when the configuration is updated.
+     * @return this builder
+     */
+    ConfigurationDependencyBuilder cbi(CbDictionary updated);   
+
+    /**
+     * Specifies the callback method reference used to invoke an update method on the component instance(s) when the configuration is updated.
+     * @param updateMethod the callback method reference used to invoke an update method on the component instance(s) when the configuration is updated.
+     * @return this builder
+     */
+    <T> ConfigurationDependencyBuilder cb(CbTypeComponentDictionary<T> callback);
+  
+    /**
+     * Specifies the callback instance method reference used to invoke an update method on a given object instance when the configuration is updated.
+     * @param updateMethod the callback instance method reference used to invoke an update method on a given object instance when the configuration is updated.
+     * @return this builder
+     */
+    ConfigurationDependencyBuilder cbi(CbComponentDictionary updated);   
+}

Added: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyActivatorBase.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyActivatorBase.java?rev=1727214&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyActivatorBase.java (added)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyActivatorBase.java Wed Jan 27 23:27:34 2016
@@ -0,0 +1,395 @@
+package org.apache.felix.dm.lambda;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.function.Consumer;
+
+import org.apache.felix.dm.Component;
+import org.apache.felix.dm.DependencyManager;
+import org.apache.felix.dm.lambda.impl.BundleAdapterBuilderImpl;
+import org.apache.felix.dm.lambda.impl.BundleDependencyBuilderImpl;
+import org.apache.felix.dm.lambda.impl.CompletableFutureDependencyImpl;
+import org.apache.felix.dm.lambda.impl.ComponentBuilderImpl;
+import org.apache.felix.dm.lambda.impl.ConfigurationDependencyBuilderImpl;
+import org.apache.felix.dm.lambda.impl.FactoryPidAdapterBuilderImpl;
+import org.apache.felix.dm.lambda.impl.ServiceAdapterBuilderImpl;
+import org.apache.felix.dm.lambda.impl.ServiceAspectBuilderImpl;
+import org.apache.felix.dm.lambda.impl.ServiceDependencyBuilderImpl;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Defines a base for Activators in order to build DependencyManager Components using a java8 style.<p>
+ * 
+ * Code example using auto configured fields:
+ * <pre> {@code
+ * 
+ * import static org.apache.felix.dm.builder.lambda.DependencyActivatorBase.*;
+ *
+ * public class Activator extends DependencyActivatorBase {    
+ *     public void init() throws Exception {
+ *         component(comp -> comp
+ *             .provides(Service.class, property -> "value")
+ *             .impl(ServiceImpl.class)            
+ *             .withSrv(LogService.class, ConfigurationAdmni.class) // both services are required and injected in class fields with compatible types.           
+ *     }
+ * }
+ * }</pre>
+ *
+ * Code example using reflection callbacks:<p>
+ * <pre> {@code
+ * 
+ * import static org.apache.felix.dm.builder.lambda.DependencyActivatorBase.*;
+ *
+ * public class Activator extends DependencyActivatorBase {    
+ *     public void init() throws Exception {
+ *         component(comp -> comp
+ *             .provides(Service.class, property -> "value")
+ *             .impl(ServiceImpl.class)            
+ *             .withSrv(LogService.class, log -> log.cb("setLog"))              
+ *             .withSrv(ConfigurationAdmni.class, cm -> cm.cb("setConfigAdmin")))                
+ *     }
+ * }
+ * }</pre>
+ *
+ * Code example using method references:<p>
+ * 
+ * <pre> {@code
+ * 
+ * import static org.apache.felix.dm.builder.lambda.DependencyActivatorBase.*;
+ *
+ * public class Activator extends DependencyActivatorBase {    
+ *     public void init() throws Exception {
+ *         component(comp -> comp
+ *             .provides(Service.class, property -> "value")
+ *             .impl(ServiceImpl.class)            
+ *             .withSrv(LogService.class, log -> log.cb(ServiceImpl::setLog))              
+ *             .withSrv(ConfigurationAdmni.class, cm -> cm.cb(ServiceImpl::setConfigAdmin)))                
+ *     }
+ * }
+ * }</pre>
+ */
+public abstract class DependencyActivatorBase implements BundleActivator {    
+	/**
+	 * DependencyManager object used to create/register real DM Components that are built by this activator.
+	 */
+    protected DependencyManager m_manager;
+    
+    /**
+     * Bundle Context asociated to the activator bundle.
+     */
+    protected BundleContext m_ctx;
+
+    /**
+     * Our Activator is starting.
+     */
+    @Override
+    public void start(BundleContext context) throws Exception {
+        m_manager = new DependencyManager(context);
+        m_ctx = context;
+        init();
+    }
+
+    /**
+     * Our Activator is stopped.
+     */
+    @Override
+    public void stop(BundleContext context) throws Exception {
+        destroy();
+    }
+
+    /**
+     * Sub classes must override this method in order to build some DM components.
+     * @throws Exception
+     */
+    protected abstract void init() throws Exception;
+
+    /**
+     * Sub classes may override this method that is called when the Activator is stopped.
+     * @param manager
+     * @throws Exception
+     */
+    protected void destroy() throws Exception {
+    }
+    
+    /**
+     * Returns the DependencyManager used to create/managed DM Components
+     * @return the DependencyManager associated to this Activator
+     */
+    protected DependencyManager getDependencyManager() {
+        return m_manager;
+    }
+    
+    /**
+     * Returns the bundle context.
+     */
+    protected BundleContext getBundleContext() {
+        return m_ctx;
+    }
+    
+    /**
+     * Creates a Component builder that can be used to create a DM Component. 
+     * @return a Component builder that can be used to create a DM Component.
+     */
+    protected ComponentBuilder<?> component() {
+        return new ComponentBuilderImpl(m_manager);
+    }
+    
+    /**
+     * Creates a service Aspect builder that can be used to create a DM Aspect Component. 
+     * @return a service Aspect builder that can be used to create a DM Aspect Component.
+     */
+    protected <T> ServiceAspectBuilder<T> aspect(Class<T> aspectType) {
+        ServiceAspectBuilderImpl<T> aspectBuilder = new ServiceAspectBuilderImpl<>(m_manager, aspectType);
+        return aspectBuilder;
+    }
+    
+    /**
+     * Creates a service Adapter builder that can be used to create a DM Adapter Component. 
+     * @return a service Adapter builder that can be used to create a DM Adapter Component.
+     */
+    protected <T> ServiceAdapterBuilder<T> adapter(Class<T> adapteeType) {
+        ServiceAdapterBuilderImpl<T> adapterBuilder = new ServiceAdapterBuilderImpl<>(m_manager, adapteeType);
+        return adapterBuilder;
+    }
+    
+    /**
+     * Builds a DM Component using a Java8 style ComponentBuilder.
+     * @param consumer the lambda that will use the ComponentBuilder for building the DM component. 
+     * The component is auto-added to the DependencyManager, unless the lambda calls the ComponentBuilder.autoAdd(false) method.
+     * @return a newly built DM component.
+     */
+    protected Component component(Consumer<ComponentBuilder<?>> consumer) {
+        return component(m_manager, consumer);
+    }
+        
+    /**
+     * Builds a DM Aspect Component using a Java8 style AspectBuilder.
+     * @param consumer the lambda that will use the AspectBuilder for building the DM aspect component. 
+     * The component is auto-added to the DependencyManager, unless the lambda calls the AspectBuilder.autoAdd(false) method.
+     * @return a newly built DM component.
+     */
+    protected <T> Component aspect(Class<T> aspect, Consumer<ServiceAspectBuilder<T>> consumer) {
+        return aspect(m_manager, aspect, consumer);
+    }
+
+    /**
+     * Builds a DM Adapter Component using a Java8 style AdapterBuilder.
+     * @param consumer the lambda that will use the AdapterBuilder for building the DM adapter component. 
+     * The component is auto-added to the DependencyManager, unless the lambda calls the AdapterBuilder.autoAdd(false) method.
+     * @return a newly built DM component.
+     */
+    protected <T> Component adapter(Class<T> adaptee, Consumer<ServiceAdapterBuilder<T>> consumer) {
+        return adapter(m_manager, adaptee, consumer);
+    }
+    
+    /**
+     * Builds a DM Factory Configuration Adapter Component using a Java8 style FactoryPidAdapterBuilder.
+     * @param consumer the lambda that will use the FactoryPidAdapterBuilder for building the DM factory configuration adapter component. 
+     * The component is auto-added to the DependencyManager, unless the lambda calls the FactoryPidAdapterBuilder.autoAdd(false) method.
+     * @return a newly built DM component.
+     */
+    protected Component factoryPidAdapter(Consumer<FactoryPidAdapterBuilder> consumer) {
+        return factoryPidAdapter(m_manager, consumer);
+    }
+
+    /**
+     * Builds a DM Bundle Adapter Component.
+     * @param consumer the lambda used to build the actual bundle adapter. 
+     * The component is auto-added to the DependencyManager, unless the lambda calls the BundleAdapter.autoAdd(false) method.
+     * @return a newly built DM component.
+     */
+    protected Component bundleAdapter(Consumer<BundleAdapterBuilder> consumer) {
+        return bundleAdapter(m_manager, consumer);
+    }
+       
+    // These static methods can be used when building DM components outside of an activator.
+	
+    /**
+     * Creates a Component builder that can be used to create a Component. 
+     * @return a Component builder that can be used to create a Component.
+     */
+    public static ComponentBuilder<?> component(DependencyManager dm) {
+        return new ComponentBuilderImpl(dm);
+    }
+    
+    /**
+     * Creates a service Aspect builder that can be used to create an Aspect Component. 
+     * @param dm the DependencyManager object used to register the built component
+     * @param aspect the type of the aspect service
+     * @return a service Aspect builder that can be used to create an Aspect Component.
+     */
+    public static <T> ServiceAspectBuilder<T> aspect(DependencyManager dm, Class<T> aspect) {
+        ServiceAspectBuilderImpl<T> aspectBuilder = new ServiceAspectBuilderImpl<>(dm, aspect);
+        return aspectBuilder;
+    }
+    
+    /**
+     * Creates a service Adapter builder that can be used to create an Adapter Component. 
+     * @param dm the DependencyManager object used to register the built component
+     * @param adaptee the type of the adaptee service
+     * @return a service Adapter builder that can be used to create an Adapter Component.
+     */
+    public static <T> ServiceAdapterBuilder<T> adapter(DependencyManager dm, Class<T> adaptee) {
+        ServiceAdapterBuilderImpl<T> adapterBuilder = new ServiceAdapterBuilderImpl<>(dm, adaptee);
+        return adapterBuilder;
+    }
+
+    /**
+     * Creates a factory pid adapter that can be used to create a factory adapter Component. 
+     * @param dm the DependencyManager object used to register the built component
+     * @return a factory pid adapter that can be used to create a factory adapter Component. 
+     */
+    public static FactoryPidAdapterBuilder factoryPidAdapter(DependencyManager dm) {
+        return new FactoryPidAdapterBuilderImpl(dm);
+    }
+   
+    /**
+     * Creates a bundle adapter builder that can be used to create a DM bundle adapter Component. 
+     * @param dm
+     * @return a bundle adapter builder that can be used to create a DM bundle adapter Component.
+     */
+    public static BundleAdapterBuilder bundleAdapter(DependencyManager dm) {
+        return new BundleAdapterBuilderImpl(dm);
+    }
+   
+    /**
+     * Creates a DM ServiceDependency builder.
+     * 
+     * @param component the component on which you want to build a new service dependency using the returned builder
+     * @param service the service dependency type.
+     * @return a DM ServiceDependency builder.
+     */
+    public static <T> ServiceDependencyBuilder<T> serviceDependency(Component component, Class<T> service) {
+        return new ServiceDependencyBuilderImpl<>(component, service);
+    }
+    
+    /**
+     * Creates a DM Configuration Dependency builder.
+     * 
+     * @param component the component on which you want to build a new configuration dependency using the returned builder
+     * @return a DM Configuration Dependency builder.
+     */
+    public static ConfigurationDependencyBuilder confDependency(Component component) {
+        return new ConfigurationDependencyBuilderImpl(component);
+    }
+    
+    /**
+     * Creates a DM Bundle Dependency builder.
+     * 
+     * @param component the component on which you want to build a new bundle dependency using the returned builder
+     * @return a DM Configuration Dependency builder.
+     */
+    public static BundleDependencyBuilder bundleDependency(Component component) {
+        return new BundleDependencyBuilderImpl(component);
+    }
+
+    /**
+     * Creates a DM CompletableFuture Dependency builder.
+     * 
+     * @param component the component on which you want to build a new completable future dependency using the returned builder.
+     * @param future the future the dependency built using the returned builder will depend on.
+     * @return a CompletableFuture dependency builder.
+     */
+    public static <F> FutureDependencyBuilder<F> futureDependency(Component component, CompletableFuture<F> future) {
+        return new CompletableFutureDependencyImpl<>(component, future);
+    }
+
+    /**
+     * Builds a component using a lambda and a component builder
+     * @param dm the DependencyManager where the component is auto-added (unless the component.autoAdd(false) is called)
+     * @param consumer a lambda that is called to build the component. When the lambda is called, it will be provided with a 
+     * ComponentBuilder object that is used to build the actual DM component.
+     * 
+     * @return the built DM component.
+     */
+    public static Component component(DependencyManager dm, Consumer<ComponentBuilder<?>> consumer) {
+        ComponentBuilder<?> componentBuilder = new ComponentBuilderImpl(dm);
+        consumer.accept(componentBuilder);
+        Component comp = componentBuilder.build();
+        if (((ComponentBuilderImpl) componentBuilder).isAutoAdd()) {
+        	dm.add(comp);
+        }
+        return comp;
+    }
+
+    /**
+     * Update an existing component. Typically, this method can be used from a Component.init method, where more dependencies has to be added.
+     * @param comp an existing DM component
+     * @param consumer the lambda that will be used to update the component
+     */
+    public static void component(Component comp, Consumer<ComponentBuilder<?>> consumer) {
+        ComponentBuilder<?> componentBuilder = new ComponentBuilderImpl(comp, true /* update component */);
+        consumer.accept(componentBuilder);
+        componentBuilder.build();
+    }
+    
+    /**
+     * Builds an aspect DM Component.
+     * @param dm the DependencyManager object used to register the built component
+     * @param aspect the type of the aspect service
+     * @param consumer a lambda used to build the DM aspect component
+     * @return a new DM aspect component. The aspect component is auto-added into the dm object, unless the lambda calls
+     * the AspectBuilder.autoAdd(false) method.
+     */
+    public static <T> Component aspect(DependencyManager dm, Class<T> aspect, Consumer<ServiceAspectBuilder<T>> consumer) {
+        ServiceAspectBuilderImpl<T> aspectBuilder = new ServiceAspectBuilderImpl<>(dm, aspect);
+        consumer.accept(aspectBuilder);
+        Component comp = aspectBuilder.build();
+        if (aspectBuilder.isAutoAdd()) {
+        	dm.add(comp);
+        }
+        return comp;
+    }    
+        
+    /**
+     * Builds an adapter DM Component.
+     * @param dm the DependencyManager object used to register the built component
+     * @param adaptee the type of the adapted service
+     * @param consumer a lambda used to build the DM adapter component
+     * @return a new DM adapter component. The adapter component is auto-added into the dm object, unless the lambda calls
+     * the AspectBuilder.autoAdd(false) method is called.
+     */
+    public static <T> Component adapter(DependencyManager dm, Class<T> adaptee, Consumer<ServiceAdapterBuilder<T>> consumer) {
+        ServiceAdapterBuilderImpl<T> adapterBuilder = new ServiceAdapterBuilderImpl<>(dm, adaptee);
+        consumer.accept(adapterBuilder);
+        Component comp = adapterBuilder.build();
+        if (adapterBuilder.isAutoAdd()) {
+        	dm.add(comp);
+        }
+        return comp;
+    }
+      
+    /**
+     * Builds a bundle adapter DM Component.
+     * @param dm the DependencyManager object used to register the built component
+     * @param consumer a lambda used to build the bundle adapter component
+     * @return a new bundle adapter component. The adapter component is auto-added into the dm object, unless the lambda calls
+     * the AspectBuilder.autoAdd(false) method is called.
+     */
+    public static <T> Component bundleAdapter(DependencyManager dm, Consumer<BundleAdapterBuilder> consumer) {
+        BundleAdapterBuilderImpl adapterBuilder = new BundleAdapterBuilderImpl(dm);
+        consumer.accept(adapterBuilder);
+        Component comp = adapterBuilder.build();
+        if (adapterBuilder.isAutoAdd()) {
+            dm.add(comp);
+        }
+        return comp;
+    }
+
+    /**
+     * Builds a DM factory configuration adapter.
+     * @param dm the DependencyManager object used to create DM components.
+     * @param consumer a lambda used to build the DM factory configuration adapter component
+     * @return a new DM factory configuration adapter component. The adapter component is auto-added into the dm object, unless the lambda calls
+     * the FactoryPidAdapterBuilder.autoAdd(false) method is called
+     */
+    public static <T> Component factoryPidAdapter(DependencyManager dm, Consumer<FactoryPidAdapterBuilder> consumer) {
+        FactoryPidAdapterBuilderImpl factoryPidAdapter = new FactoryPidAdapterBuilderImpl(dm);
+        consumer.accept(factoryPidAdapter);
+        Component comp = factoryPidAdapter.build();
+        if (factoryPidAdapter.isAutoAdd()) {
+        	dm.add(comp);
+        }
+        return comp;
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyBuilder.java?rev=1727214&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyBuilder.java (added)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyBuilder.java Wed Jan 27 23:27:34 2016
@@ -0,0 +1,15 @@
+package org.apache.felix.dm.lambda;
+
+import org.apache.felix.dm.Dependency;
+
+/**
+ * Base class for all dependency builders
+ * @param <T> the dependency type.
+ */
+public interface DependencyBuilder<T extends Dependency> {
+	/**
+	 * Builds a DependencyManager dependency. 
+	 * @return a real DependencyManager dependency
+	 */
+    T build();
+}

Added: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FactoryPidAdapterBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FactoryPidAdapterBuilder.java?rev=1727214&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FactoryPidAdapterBuilder.java (added)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FactoryPidAdapterBuilder.java Wed Jan 27 23:27:34 2016
@@ -0,0 +1,113 @@
+package org.apache.felix.dm.lambda;
+
+import org.apache.felix.dm.lambda.callbacks.CbComponentDictionary;
+import org.apache.felix.dm.lambda.callbacks.CbDictionary;
+import org.apache.felix.dm.lambda.callbacks.CbTypeComponentDictionary;
+import org.apache.felix.dm.lambda.callbacks.CbTypeDictionary;
+
+/**
+ * Defines the interface for a Dependency Manager Factory Configuration Adapter.
+ * 
+ * Example that defines a factory configuration adapter service for the "foo.bar" factory pid.
+ * 
+ * <pre> {@code
+ * public class Activator extends DependencyActivatorBase {
+ *     public void init() throws Exception { 
+ *         factoryPidAdapter(adapter -> adapter
+ *             .impl(DictionaryImpl.class)
+ *             .factoryPid("foo.bar").cb(ServiceImpl::updated)
+ *             .propagate()
+ *             .withSrv(LogService.class, log -> log.optional()));
+ *    }
+ * }</pre>
+ */
+public interface FactoryPidAdapterBuilder extends ComponentBuilder<FactoryPidAdapterBuilder> {
+    /**
+     * Specifies the factory pid used by the adapter.
+     * @param pid the factory pid.
+     * @return this builder
+     */
+    FactoryPidAdapterBuilder factoryPid(String pid);
+    
+    /**
+     * Specifies a class name which fqdn represents the factory pid. Usually, this class can optionally be annotated with metatypes bnd annotations.
+     * @param pidClass the class that acts as the factory pid
+     * @return this builder
+     */
+    FactoryPidAdapterBuilder factoryPid(Class<?> pidClass);
+    
+    /**
+     * Specifies if the public properties (not starting with a dot) should be propagated in the adapter service properties (false by default).
+     * @return this builder.
+     */
+    FactoryPidAdapterBuilder propagate();
+    
+    /**
+     * Specifies if the public properties (not starting with a dot) should be propagated in the adapter service properties (false by default).
+     * @param propagate true if the public properties should be propagated in the adapter service properties (false by default).
+     * @return this builder.
+     */
+    FactoryPidAdapterBuilder propagate(boolean propagate);
+    
+    /**
+     * Specifies a callback method that will be called on the component instances when the configuration is injected
+     * @param updateMethod the method to call on the component instances when the configuration is available ("updated" by default).
+     * The following method signatures are supported:<p>
+     * 
+     * <pre> {@code
+     *    method(Dictionary properties)
+     *    method(Component component, Dictionary properties)
+     * }</pre>
+     * 
+     * @return this builder
+     */
+    FactoryPidAdapterBuilder cb(String updateMethod);
+    
+    /**
+     * Specifies a callback instance method that will be called on a given object instance when the configuration is injected
+     * @param updateMethod the method to call on the given object instance when the configuration is available ("updated" by default).
+     * The following method signatures are supported:<p>
+     * 
+     * <pre> {@code
+     *    method(Dictionary properties)
+     *    method(Component component, Dictionary properties)
+     * }</pre>
+     * 
+     * @return this builder
+     */
+    FactoryPidAdapterBuilder cb(Object callbackInstance, String updateMethod);
+    
+    /**
+     * Specifies a callback method reference that will be called on one of the component classes when the configuration is injected
+     * @param callback the method to call on one of the component classes when the configuration is available.
+     *
+     * @return this builder
+     */
+    <U> FactoryPidAdapterBuilder cb(CbTypeDictionary<U> callback);
+    
+    /**
+     * Specifies a callback instance method reference that will be called on a given object instance when the configuration is injected
+     * @param callback the method to call on a given object instance when the configuration is available. The callback takes as
+     * a Dictionary<String, Object> parameter. 
+     *
+     * @return this builder
+     */
+    FactoryPidAdapterBuilder cbi(CbDictionary callback);
+
+    /**
+     * Specifies a callback method reference that will be called on one of the component classes when the configuration is injected
+     * @param callback the reference to a method on one of the component classes. The method may takes as parameter a Component and a Dictionary.
+     *
+     * @return this builder
+     */
+    <U> FactoryPidAdapterBuilder cb(CbTypeComponentDictionary<U> callback);
+    
+    /**
+     * Specifies a callback instance method reference that will be called on a given object instance when the configuration is injected
+     * @param callback the method to call on a given object instance when the configuration is available. The callback takes as
+     * a Dictionary<String, Object> parameter. 
+     *
+     * @return this builder
+     */
+    FactoryPidAdapterBuilder cbi(CbComponentDictionary callback);
+}

Added: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FutureDependencyBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FutureDependencyBuilder.java?rev=1727214&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FutureDependencyBuilder.java (added)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FutureDependencyBuilder.java Wed Jan 27 23:27:34 2016
@@ -0,0 +1,109 @@
+package org.apache.felix.dm.lambda;
+
+import java.util.concurrent.Executor;
+
+import org.apache.felix.dm.Dependency;
+import org.apache.felix.dm.lambda.callbacks.CbFuture;
+import org.apache.felix.dm.lambda.callbacks.CbTypeFuture;
+
+/**
+ * Defines a builder for CompletableFuture dependency.
+ * Using such dependency allows your component to wait for the completion of a given asynchronous task
+ * represented by a standard jdk <code>CompletableFuture</code> object.
+ * 
+ * <h3>Usage Examples</h3>
+ * 
+ * <p> Here is an Activator which downloads a page from the web and inject the string result to a component.
+ * When the web page is downloaded, the result is injected in the SiteInfoImpl::bindFelixPage method and
+ * the component is then called in its start method:
+ * 
+ * <blockquote>
+ * <pre>
+ * 
+ * public class Activator extends DependencyActivatorBase {
+ * 
+ *   @Override
+ *   public void init() throws Exception {    	
+ *      String url = "http://felix.apache.org/";
+ *  	CompletableFuture<String> felixFuture = CompletableFuture.supplyAsync(() -> downloadSite(url));				
+ *
+ *  	// The component depends on a log service and on the content of the Felix site.
+ *      component(comp -> comp
+ *      	.impl(MyComponent.class)
+ *          .withService(LogService.class, log -> log.onAdd(SiteInfoImpl::bindLog))
+ *          .withFuture(felixFuture, future -> future.cb(SiteInfoImpl::bindFelixPage)));
+ *     
+ *   }
+ * }
+ * </pre>
+ * </blockquote>
+ * 
+ * @param <F> the type of the CompletableFuture result.
+ */
+public interface FutureDependencyBuilder<F> extends DependencyBuilder<Dependency> { 
+    /**
+     * Specifies the callback method name to invoke on the component instances, once the CompletableFuture on which we depend has completed.
+     * @param callback the callback method name to invoke on the component instances, once the CompletableFuture on which we depend has completed.
+     * @return this dependency.
+     */
+    FutureDependencyBuilder<F> cb(String callback);
+    
+    /**
+     * Specifies the callback instance method name to invoke on the component instances, once the CompletableFuture on which we depend has completed.
+     * @param callbackInstance the object instance on which the callback must be invoked
+     * @param callback the callback method name to invoke on the component instances, once the CompletableFuture on which we depend has completed.
+     * @return this dependency.
+     */
+    FutureDependencyBuilder<F> cbi(Object callbackInstance, String callback);
+    
+    /**
+     * Sets the function to invoke when the future task has completed. The function is one of the Component instances method that accepts the
+     * result of the completed future.
+     * @param action the function to perform when the future task as completed. 
+     * @return this dependency
+     */
+    <T> FutureDependencyBuilder<F> cb(CbTypeFuture<T, ? super F> action);
+    
+    /**
+     * Sets the function to invoke asynchronously when the future task has completed. The function is one of the Component instances method that accepts the
+     * result of the completed future.
+     * @param action the function to perform when the future task as completed. 
+     * @return this dependency
+     */
+    <T> FutureDependencyBuilder<F> cb(CbTypeFuture<T, ? super F> action, boolean async);
+
+    /**
+    /**
+     * Sets the function to invoke asynchronously when the future task has completed. The function is one of the Component instances method that accepts the
+     * result of the completed future.
+     * @param action the function to perform when the future task as completed. 
+     * @param executor the executor used to schedule the action.
+     * @return this dependency
+     */
+    <T> FutureDependencyBuilder<F> cb(CbTypeFuture<T, ? super F> action, Executor executor);   
+        
+    /**
+     * Sets the callback instance to invoke when the future task has completed. The action is a Consumer instance which accepts the
+     * result of the completed future.
+     * @param action a Consumer instance which accepts the result of the completed future.
+     * @return this dependency
+     */
+    FutureDependencyBuilder<F> cbi(CbFuture<? super F> action);
+    
+    /**
+     * Sets the action to perform asynchronously when the future task has completed. The action is a Consumer instance which accepts the
+     * result of the completed future.
+     * @param action a Consumer instance which accepts the result of the completed future.
+     * @return this dependency
+     */
+    FutureDependencyBuilder<F> cbi(CbFuture<? super F> action, boolean async);
+
+    /**
+     * Sets the action to perform asynchronously when the future task has completed. The action is a Consumer instance which accepts the
+     * result of the completed future.
+     * @param action the action to perform when the future task as completed. 
+     * @param executor the executor to use for asynchronous execution of the action.
+     * @return this dependency
+     */
+    FutureDependencyBuilder<F> cbi(CbFuture<? super F> action, Executor executor);   
+}

Added: 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=1727214&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAdapterBuilder.java (added)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAdapterBuilder.java Wed Jan 27 23:27:34 2016
@@ -0,0 +1,54 @@
+package org.apache.felix.dm.lambda;
+
+/**
+ * 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 
+ * based on the adapter implementation class. The adapter will be registered with the specified interface and existing properties from the original 
+ * service plus any extra properties you supply here.<p>
+ * 
+ * Code example that adapts a "Device" service to an HttpServlet service. the adapter accepts a lambda that is provided with an AdapterBuilder
+ * 
+ * <pre> {@code
+ * public class Activator extends DependencyActivatorBase {
+ *    public void init() throws Exception { 
+ *        adapter(Device.class, builder -> builder.impl(DeviceServlet.class).provides(HttpServlet.class).properties(alias -> "/device");      
+ *    }
+ * }}</pre>
+ * 
+ * @param <T> the adaptee service
+ */
+public interface ServiceAdapterBuilder<T> extends ComponentBuilder<ServiceAdapterBuilder<T>>, ServiceCallbacksBuilder<T, ServiceAdapterBuilder<T>> {
+    /**
+     * Specifies the filter used to match a given adapted service.
+     * @param adapteeFilter the filter used to match a given adapted service
+     * @return this builder
+     */
+    ServiceAdapterBuilder<T> filter(String adapteeFilter);
+    
+    /**
+     * Specifies whether or not the adapted service properties must be propagated to the adapter service (true by default). 
+     * @param propagate true if the adapted service properties must be propagated to the adapter service (true by default). 
+     * @return this builder
+     */
+    ServiceAdapterBuilder<T> propagate(boolean propagate);
+    
+    /**
+     * Injects this adapted service in all fields matching the adapted service type.
+     * @return this builder
+     */
+    ServiceAdapterBuilder<T> autoConfig();
+    
+    /**
+     * Configures whether or not the adapted service can be injected in all fields matching the adapted service type. 
+     * @param autoConfig true if the adapted service can be injected in all fields matching the adapted service type
+     * @return this builder
+     */
+    ServiceAdapterBuilder<T> autoConfig(boolean autoConfig);
+    
+    /**
+     * Injects this adapted service on the field matching the given name
+     * @param field the field name where the adapted service must be injected to.
+     * @return this builder
+     */
+    ServiceAdapterBuilder<T> autoConfig(String field);            
+}

Added: 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=1727214&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAspectBuilder.java (added)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAspectBuilder.java Wed Jan 27 23:27:34 2016
@@ -0,0 +1,59 @@
+package org.apache.felix.dm.lambda;
+
+/**
+ * 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 
+ * on the aspect implementation class. 
+ * The aspect will be registered with the same interface and properties as the original service, plus any extra properties you supply here. <p>
+ * 
+ * Code example that provides an aspect service for an English dictionary service (the aspect service is injected in the DictionaryAspect::bind method):
+ * 
+ * <pre> {@code
+ * public class Activator extends DependencyActivatorBase {
+ *    public void init() throws Exception { 
+ *       aspect(DictionaryService.class, builder -> builder
+ *          .filter("(lang=en)")
+ *          .rank(10)
+ *          .impl(DictionaryAspect.class)
+ *          .cb(aspect -> aspect.cb(DictionaryAspect::bind))
+ *          .withSrv(LogService.class, log -> log.required(false)));
+ *    }
+ * }}</pre>
+ *
+ * @param <T> the aspect service
+ */
+public interface ServiceAspectBuilder<T> extends ComponentBuilder<ServiceAspectBuilder<T>>, ServiceCallbacksBuilder<T, ServiceAspectBuilder<T>>  {
+    /**
+     * Specifies the aspect service filter. 
+     * @param filter
+     * @return
+     */
+    ServiceAspectBuilder<T> filter(String filter);
+    
+    /**
+     * Specifies the aspect ranking. Aspects of a given service are ordered by their ranking property.
+     * @param ranking the aspect ranking
+     * @return this builder
+     */
+    ServiceAspectBuilder<T> rank(int ranking);
+    
+    /**
+     * Injects the aspect in all fields matching the aspect type.
+     * @return this builder
+     */
+    ServiceAspectBuilder<T> autoConfig();
+    
+    /**
+     * Configures whether or not the aspect service can be injected in all fields matching the aspect type. 
+     * @param autoConfig true if the aspect service can be injected in all fields matching the dependency type
+     * @return this builder
+     */
+    ServiceAspectBuilder<T> autoConfig(boolean autoConfig);
+    
+    /**
+     * Injects the aspect service on the field with the given name
+     * @param field the field name where the aspect service must be injected
+     * @return this builder
+     */
+    ServiceAspectBuilder<T> autoConfig(String field);      
+}

Added: 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=1727214&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java (added)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java Wed Jan 27 23:27:34 2016
@@ -0,0 +1,186 @@
+package org.apache.felix.dm.lambda;
+
+import org.apache.felix.dm.lambda.callbacks.CbComponent;
+import org.apache.felix.dm.lambda.callbacks.CbComponentRef;
+import org.apache.felix.dm.lambda.callbacks.CbComponentRefService;
+import org.apache.felix.dm.lambda.callbacks.CbComponentRefServiceRefService;
+import org.apache.felix.dm.lambda.callbacks.CbComponentService;
+import org.apache.felix.dm.lambda.callbacks.CbComponentServiceService;
+import org.apache.felix.dm.lambda.callbacks.CbRef;
+import org.apache.felix.dm.lambda.callbacks.CbRefService;
+import org.apache.felix.dm.lambda.callbacks.CbRefServiceRefService;
+import org.apache.felix.dm.lambda.callbacks.CbService;
+import org.apache.felix.dm.lambda.callbacks.CbServiceDict;
+import org.apache.felix.dm.lambda.callbacks.CbServiceMap;
+import org.apache.felix.dm.lambda.callbacks.CbServiceService;
+import org.apache.felix.dm.lambda.callbacks.CbTypeComponent;
+import org.apache.felix.dm.lambda.callbacks.CbTypeComponentRef;
+import org.apache.felix.dm.lambda.callbacks.CbTypeComponentRefService;
+import org.apache.felix.dm.lambda.callbacks.CbTypeComponentRefServiceRefService;
+import org.apache.felix.dm.lambda.callbacks.CbTypeComponentService;
+import org.apache.felix.dm.lambda.callbacks.CbTypeComponentServiceService;
+import org.apache.felix.dm.lambda.callbacks.CbTypeRef;
+import org.apache.felix.dm.lambda.callbacks.CbTypeRefService;
+import org.apache.felix.dm.lambda.callbacks.CbTypeRefServiceRefService;
+import org.apache.felix.dm.lambda.callbacks.CbTypeService;
+import org.apache.felix.dm.lambda.callbacks.CbTypeServiceDict;
+import org.apache.felix.dm.lambda.callbacks.CbTypeServiceMap;
+import org.apache.felix.dm.lambda.callbacks.CbTypeServiceService;
+
+/**
+ * Builds a service dependency callback.
+ * 
+ * A Service may be injected in a bind-method of a component or an object instance using this builder.
+ * The builder supports the following kind of method signatures for bind methods: <p>
+ * 
+ * <pre> {@code
+ * method(S service)
+ * method(S service, Map<String, Object> serviceProperties)
+ * method(S service, Dictionary<String, Object> serviceProperties)
+ * method(ServiceReference<S> serviceRef, S service),
+ * method(ServiceReference<S> serviceRef)
+ * method(Component serviceComponent)
+ * method(Component serviceComponent, ServiceReference<S> serviceRef)
+ * method(Component serviceComponent, S service) 
+ * method(Component serviceComponent, ServiceReference<S> serviceRef, S service)
+ * swapMethod(S oldService, S newService)
+ * swapMethod(ServiceReference<S> oldRef, S old, ServiceReference<S> newRef, S newService)
+ * swapMethod(Component component, S oldService, S newService)
+ * swapMethod(Component component, ServiceReference<S> oldRef, S old, ServiceReference<S> newRef, S newService)
+ * }</pre>
+ *
+ * The following families of callbacks are supported:<p>
+ * 
+ * <ul>
+ * <li> "cb(String ... callback)": stands for "callback" and specifies a list of callbacks from the component instances. When using one arg, it stands for the "add" callback. 
+ * When using two args, it stands for "add/remove" callbacks. When using three args, it stands for "add/change/remove" callbacks. When using four args, it stands for "add/change/remove/swap" callbacks. 
+ * <li> "cbi(Object callbackInstance, String ... callbacks)": stands for "callback instance" and specifies some callbacks on a given object instance.
+ * <li> "cb(lambda) ": stands for "callback" and specifies a method reference of a callback from a given component class.
+ * <li> "cbi(lambda)": stands for "callback instance" and specifies a method reference from a given object instance.
+ * <li> "sw(lambda)":  stands for "swap callback" and specifies a method reference of a swap callback from a given component class.
+ * <li> "swi(lambda)": stands for "swap callback instance" and specifies a method reference of a swap callback from a given object instance.
+ * </ul>
+ *
+ * <p> Here is an example of a Component that defines a dependency of a LogService which is injected in the "bindLogService" method using a ServiceCallbacksBuilder:
+ * The withSrv(...)" declaration defines a method reference on the "ComponentImpl::bindLogService" method (using a lambda):
+ * 
+ * <pre> {@code
+ * public class Activator extends DependencyActivatorBase {
+ *    public void init() throws Exception { 
+ *       component(comp -> comp.impl(ComponentImpl.class).withSrv(LogService.class, log -> log.cb(ComponentImpl::bindLogService)));
+ *    }
+ * }}</pre>
+ *
+ * <p> Same example, but we inject the dependency in an object instance that we already have in hand:
+ * 
+ * <pre> {@code
+ * public class Activator extends DependencyActivatorBase {
+ *    public void init() throws Exception {
+ *       ComponentImpl impl = new ComponentImpl();
+ *       component(comp -> comp.impl(impl).withSrv(LogService.class, log -> log.cbi(impl::bindLogService)));
+ *    }
+ * }}</pre>
+ * 
+ * <p> Here, we inject a service using method reflection (as it is the case in original DM api):
+ * 
+ * <pre> {@code
+ * public class Activator extends DependencyActivatorBase {
+ *    public void init() throws Exception {
+ *       component(comp -> comp.impl(ComponentImpl::class).withSrv(LogService.class, log -> log.cb("bindLogService")));
+ *    }
+ * }}</pre>
+ *
+ * <p> Same example, but we inject the dependency in an object instance that we already have in hand:
+ * 
+ * <pre> {@code
+ * public class Activator extends DependencyActivatorBase {
+ *    public void init() throws Exception {
+ *       ComponentImpl impl = new ComponentImpl();
+ *       component(comp -> comp.impl(impl).withSrv(LogService.class, log -> log.cbi(impl, "bindLogService")));
+ *    }
+ * }}</pre>
+ *
+ * @param <S> the service dependency type
+ * @param <B> the type of a sub interface that may extends this interface.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public interface ServiceCallbacksBuilder<S, B> {
+    B cb(String ... callbacks);
+    B cbi(Object callbackInstance, String ... callbacks);
+
+    <T> B cb(CbTypeService<T, S> add);
+    <T> B cb(CbTypeService<T, S> add, CbTypeService<T, S> remove);
+    <T> B cb(CbTypeService<T, S> add, CbTypeService<T, S> change, CbTypeService<T, S> remove);
+    B cbi(CbService<S> add);
+    B cbi(CbService<S> add, CbService<S> remove);
+    B cbi(CbService<S> add, CbService<S> change, CbService<S> remove);
+
+    <T> B cb(CbTypeServiceMap<T, S> add);
+    <T> B cb(CbTypeServiceMap<T, S> add, CbTypeServiceMap<T, S> remove);
+    <T> B cb(CbTypeServiceMap<T, S> add, CbTypeServiceMap<T, S> change, CbTypeServiceMap<T, S> remove);
+    B cbi(CbServiceMap<S> add);
+    B cbi(CbServiceMap<S> add, CbServiceMap<S> remove);
+    B cbi(CbServiceMap<S> add, CbServiceMap<S> change, CbServiceMap<S> remove);
+
+    <T> B cb(CbTypeServiceDict<T, S> add);
+    <T> B cb(CbTypeServiceDict<T, S> add, CbTypeServiceDict<T, S> remove);
+    <T> B cb(CbTypeServiceDict<T, S> add, CbTypeServiceDict<T, S> change, CbTypeServiceDict<T, S> remove);
+    B cbi(CbServiceDict<S> add);
+    B cbi(CbServiceDict<S> add, CbServiceDict<S> remove);
+    B cbi(CbServiceDict<S> add, CbServiceDict<S> change, CbServiceDict<S> remove);
+
+    <T> B cb(CbTypeRefService<T, S> add);
+    <T> B cb(CbTypeRefService<T, S> add, CbTypeRefService<T, S> remove);
+    <T> B cb(CbTypeRefService<T, S> add, CbTypeRefService<T, S> change, CbTypeRefService<T, S> remove);
+    B cbi(CbRefService<S> add);
+    B cbi(CbRefService<S> add, CbRefService<S> remove);
+    B cbi(CbRefService<S> add, CbRefService<S> change, CbRefService<S> remove);
+
+    <T> B cb(CbTypeRef<T, S> add);
+    <T> B cb(CbTypeRef<T, S> add, CbTypeRef<T, S> remove);
+    <T> B cb(CbTypeRef<T, S> add, CbTypeRef<T, S> change, CbTypeRef<T, S> remove);
+    B cbi(CbRef<S> add);
+    B cbi(CbRef<S> add, CbRef<S> remove);
+    B cbi(CbRef<S> add, CbRef<S> change, CbRef<S> remove);
+
+    <T> B cb(CbTypeComponent<T> add);
+    <T> B cb(CbTypeComponent<T> add, CbTypeComponent<T> remove);
+    <T> B cb(CbTypeComponent<T> add, CbTypeComponent<T> change, CbTypeComponent<T> remove);
+    B cbi(CbComponent add);
+    B cbi(CbComponent add, CbComponent remove);
+    B cbi(CbComponent add, CbComponent change, CbComponent remove);
+
+    <T> B cb(CbTypeComponentRef<T, S> add);
+    <T> B cb(CbTypeComponentRef<T, S> add, CbTypeComponentRef<T, S> remove);
+    <T> B cb(CbTypeComponentRef<T, S> add, CbTypeComponentRef<T, S> change, CbTypeComponentRef<T, S> remove);
+    B cbi(CbComponentRef<S> add);
+    B cbi(CbComponentRef<S> add, CbComponentRef<S> remove);
+    B cbi(CbComponentRef<S> add, CbComponentRef<S> change, CbComponentRef<S> remove);
+
+    <T> B cb(CbTypeComponentService<T, S> add);
+    <T> B cb(CbTypeComponentService<T, S> add, CbTypeComponentService<T, S> remove);
+    <T> B cb(CbTypeComponentService<T, S> add, CbTypeComponentService<T, S> change, CbTypeComponentService<T, S> remove);
+    B cbi(CbComponentService<S> add);    
+    B cbi(CbComponentService<S> add, CbComponentService<S> remove);
+    B cbi(CbComponentService<S> add, CbComponentService<S> change, CbComponentService<S> remove);
+
+    <T> B cb(CbTypeComponentRefService<T, S> add);
+    <T> B cb(CbTypeComponentRefService<T, S> add, CbTypeComponentRefService<T, S> remove);
+    <T> B cb(CbTypeComponentRefService<T, S> add, CbTypeComponentRefService<T, S> change, CbTypeComponentRefService<T, S> remove);
+    B cbi(CbComponentRefService<S> add);
+    B cbi(CbComponentRefService<S> add, CbComponentRefService<S> remove);
+    B cbi(CbComponentRefService<S> add, CbComponentRefService<S> change, CbComponentRefService<S> remove);
+    
+    <T> B sw(CbTypeServiceService<T, S> swap);
+    B swi(CbServiceService<S> swap);
+
+    <T> B sw(CbTypeComponentServiceService<T, S> swap);
+    B swi(CbComponentServiceService<S> swap);
+    
+    <T> B sw(CbTypeRefServiceRefService<T, S> swap);
+    B swi(CbRefServiceRefService<S> swap);
+    
+    <T> B sw(CbTypeComponentRefServiceRefService<T, S> swap);
+    B swi(CbComponentRefServiceRefService<S> swap);        
+}

Added: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceDependencyBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceDependencyBuilder.java?rev=1727214&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceDependencyBuilder.java (added)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceDependencyBuilder.java Wed Jan 27 23:27:34 2016
@@ -0,0 +1,125 @@
+package org.apache.felix.dm.lambda;
+
+import java.util.Dictionary;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+
+import org.apache.felix.dm.ServiceDependency;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Defines a Service dependency. Dependency callbacks can be defined using methods reflection like (like in original DM Api), or using Java8 method references.
+ *
+ * @param <S> the type of the service dependency
+ */
+public interface ServiceDependencyBuilder<S> extends DependencyBuilder<ServiceDependency>, ServiceCallbacksBuilder<S, ServiceDependencyBuilder<S>> {
+    /**
+     * Configures the service dependency filter
+     * @param filter the service filter
+	 * @return this builder
+     */
+    ServiceDependencyBuilder<S> filter(String filter);
+    
+    /**
+     * Configures this dependency with the given ServiceReference.
+     * @param ref the service reference
+	 * @return this builder
+     */
+    ServiceDependencyBuilder<S> ref(ServiceReference<S> ref);
+    
+    /**
+     * Configures this dependency as optional. By default, a dependency is required.
+     * @return this builder
+     */
+    ServiceDependencyBuilder<S> optional();
+
+    /**
+     * Configures this dependency as required. By default, a dependency is required.
+	 * @return this builder
+     */
+    ServiceDependencyBuilder<S> required();
+    
+    /**
+     * Configures whether this dependency is required or not.
+	 * @return this builder
+     */
+    ServiceDependencyBuilder<S> required(boolean required);
+    
+    /**
+     * Configures debug mode
+     * @param label the label used by debug messages
+	 * @return this builder
+     */
+    ServiceDependencyBuilder<S> debug(String label);
+    
+    /**
+     * Propagates the dependency properties to the component service properties.
+	 * @return this builder
+     */
+    ServiceDependencyBuilder<S> propagate();
+  
+    /**
+     * Configures whether the dependency properties must be propagated or not to the component service properties.
+	 * @return this builder
+     */
+    ServiceDependencyBuilder<S> propagate(boolean propagate);
+    
+    /**
+     * Configures a method that can is called in order to get propagated service properties.
+     * 
+     * @param instance an object instance
+     * @param method the method name to call on the object instance. This method returns the propagated service properties.
+	 * @return this builder
+     */
+    ServiceDependencyBuilder<S> propagate(Object instance, String method);
+    
+    /**
+     * Specifies a function that is called to get the propagated service properties for this service dependency. 
+     * @param propagate a function that is called to get the propagated service properties for this service dependency. 
+     * @return this builder
+     */
+    ServiceDependencyBuilder<S> propagate(Function<ServiceReference<S>, Dictionary<String, Object>> propagate);
+
+    /**
+     * Specifies a function that is called to get the propagated service properties for this service dependency. 
+     * @param propagate a function that is called to get the propagated service properties for this service dependency. 
+     * @return this builder
+     */
+    ServiceDependencyBuilder<S> propagate(BiFunction<ServiceReference<S>, S, Dictionary<String, Object>> propagate);
+    
+    /**
+     * Sets the default implementation if the service is not available.
+     * @param defaultImpl the implementation used by default when the service is not available.
+	 * @return this builder
+     */
+    ServiceDependencyBuilder<S> defImpl(Object defaultImpl);
+    
+    /**
+     * Sets a timeout for this dependency. A timed dependency blocks the invoker thread is the required dependency is currently unavailable, until it comes up again.
+     * @param timeout the timeout to wait in milliseconds when the service disappears. If the timeout expires, an IllegalStateException is thrown
+     * when the missing service is invoked.
+     * 
+     * @return this builder
+     */
+    ServiceDependencyBuilder<S> timeout(long timeout);
+    
+    /**
+     * Injects this dependency in all fields matching the dependency type.
+     * @return this builder
+     */
+    ServiceDependencyBuilder<S> autoConfig();
+    
+    /**
+     * Configures whether or not the dependency can be injected in all fields matching the dependency type. 
+     * @param autoConfig true if the dependency can be injected in all fields matching the dependency type
+     * @return this builder
+     */
+    ServiceDependencyBuilder<S> autoConfig(boolean autoConfig);
+    
+    /**
+     * Injects this dependency on the field with the given name
+     * @param field the field name where the dependency must be injected
+     * @return this builder
+     */
+    ServiceDependencyBuilder<S> autoConfig(String field);                
+}
\ No newline at end of file

Added: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbBundle.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbBundle.java?rev=1727214&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbBundle.java (added)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbBundle.java Wed Jan 27 23:27:34 2016
@@ -0,0 +1,18 @@
+package org.apache.felix.dm.lambda.callbacks;
+
+import java.util.Objects;
+
+import org.osgi.framework.Bundle;
+
+@FunctionalInterface
+public interface CbBundle extends SerializableLambda {
+    void accept(Bundle bundle);
+
+    default CbBundle andThen(CbBundle after) {
+        Objects.requireNonNull(after);
+        return (Bundle bundle) -> {
+            accept(bundle);
+            after.accept(bundle);
+        };
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbComponent.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbComponent.java?rev=1727214&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbComponent.java (added)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbComponent.java Wed Jan 27 23:27:34 2016
@@ -0,0 +1,18 @@
+package org.apache.felix.dm.lambda.callbacks;
+
+import java.util.Objects;
+
+import org.apache.felix.dm.Component;
+
+@FunctionalInterface
+public interface CbComponent {
+    void accept(Component component);
+
+    default CbComponent andThen(CbComponent after) {
+        Objects.requireNonNull(after);
+        return (Component component) -> {
+            accept(component);
+            after.accept(component);
+        };
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbComponentBundle.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbComponentBundle.java?rev=1727214&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbComponentBundle.java (added)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbComponentBundle.java Wed Jan 27 23:27:34 2016
@@ -0,0 +1,19 @@
+package org.apache.felix.dm.lambda.callbacks;
+
+import java.util.Objects;
+
+import org.apache.felix.dm.Component;
+import org.osgi.framework.Bundle;
+
+@FunctionalInterface
+public interface CbComponentBundle {
+    void accept(Component component, Bundle bundle);
+
+    default CbComponentBundle andThen(CbComponentBundle after) {
+        Objects.requireNonNull(after);
+        return (Component component, Bundle bundle) -> {
+            accept(component, bundle);
+            after.accept(component, bundle);
+        };
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbComponentDictionary.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbComponentDictionary.java?rev=1727214&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbComponentDictionary.java (added)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbComponentDictionary.java Wed Jan 27 23:27:34 2016
@@ -0,0 +1,19 @@
+package org.apache.felix.dm.lambda.callbacks;
+
+import java.util.Dictionary;
+import java.util.Objects;
+
+import org.apache.felix.dm.Component;
+
+@FunctionalInterface
+public interface CbComponentDictionary {
+    void accept(Component component, Dictionary<String, Object> properties);
+
+    default CbComponentDictionary andThen(CbComponentDictionary after) {
+        Objects.requireNonNull(after);
+        return (Component component, Dictionary<String, Object> properties) -> {
+            accept(component, properties);
+            after.accept(component, properties);
+        };
+    }
+}