felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1724881 [1/2] - 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/depe...
Date Fri, 15 Jan 2016 21:43:31 GMT
Author: pderop
Date: Fri Jan 15 21:43:31 2016
New Revision: 1724881

URL: http://svn.apache.org/viewvc?rev=1724881&view=rev
Log:
Simplified API. ComponentBuilder is not parameterized anymore with component type.

Removed:
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/ComponentBuilderBase.java
Modified:
    felix/sandbox/pderop/dependencymanager-lambda/TODO
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/FactoryConfigurationAdapterTest.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/ModifiedBundleDependencyTest.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/ServiceDependencyTest.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/factory/Activator.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/hello/Activator.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/rx/observable/ObservableComponent.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/Cb.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/ComponentBuilder.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/DependencyActivatorBase.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/FactoryPidAdapterBuilder.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/Functions.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/ServiceAdapterBuilder.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/ServiceAspectBuilder.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/AdapterBase.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/BundleDependencyBuilderImpl.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/ComponentBuilderImpl.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/FactoryPidAdapterBuilderImpl.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/ServiceAdapterBuilderImpl.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/ServiceAspectBuilderImpl.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/ServiceCallbacksBuilderImpl.java

Modified: felix/sandbox/pderop/dependencymanager-lambda/TODO
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/TODO?rev=1724881&r1=1724880&r2=1724881&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/TODO (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/TODO Fri Jan 15 21:43:31 2016
@@ -1,3 +1,5 @@
+- add more signatures in ServiceDependencyBuilder (with Component type)
+
 - add factories methods in ComponentImpl that take object/string params (like in original DM API)
   and update DynamicProxyAspectTest.java
 
@@ -12,7 +14,4 @@
 
 - Javadocs
 
-- rework callbacks for ComponentBuilder
-
-
 

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/FactoryConfigurationAdapterTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/FactoryConfigurationAdapterTest.java?rev=1724881&r1=1724880&r2=1724881&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/FactoryConfigurationAdapterTest.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/FactoryConfigurationAdapterTest.java Fri Jan 15 21:43:31 2016
@@ -18,29 +18,23 @@
  */
 package org.apache.felix.dm.builder.lambda.itest;
 
+import static org.apache.felix.dm.builder.lambda.DependencyActivatorBase.component;
+import static org.apache.felix.dm.builder.lambda.DependencyActivatorBase.factoryPidAdapter;
+
 import java.io.IOException;
 import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.Map;
 
-import org.junit.Assert;
-
-import org.apache.felix.dm.Component;
-import org.apache.felix.dm.DependencyManager;
-import org.osgi.service.cm.ConfigurationAdmin;
-import static org.apache.felix.dm.builder.lambda.DependencyActivatorBase.*;
-
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
-import org.apache.felix.dm.builder.lambda.Cb;
 import org.junit.Assert;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
+import org.osgi.service.cm.ConfigurationAdmin;
 
 /**
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
-@SuppressWarnings({"unchecked", "rawtypes", "serial"})
+@SuppressWarnings({"unchecked", "rawtypes"})
 public class FactoryConfigurationAdapterTest extends TestBase
 {
     private static Ensure m_ensure;

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/ModifiedBundleDependencyTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/ModifiedBundleDependencyTest.java?rev=1724881&r1=1724880&r2=1724881&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/ModifiedBundleDependencyTest.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/ModifiedBundleDependencyTest.java Fri Jan 15 21:43:31 2016
@@ -105,7 +105,8 @@ public class ModifiedBundleDependencyTes
         
         String filter = "(Bundle-SymbolicName=org.apache.felix.metatype)";
         int mask = Bundle.INSTALLED|Bundle.ACTIVE|Bundle.RESOLVED|Bundle.STARTING;
-        Component b = component(m).provides(B.class).impl(new BImpl(e))    .withBundle(bundle -> bundle.filter(filter).mask(mask).cb("add", "change", "remove")).build();     	
+        Component b = component(m)
+            .provides(B.class).impl(new BImpl(e)).withBundle(bd -> bd.filter(filter).mask(mask).cb("add", "change", "remove")).build();     	
         						                    
         Bundle dmtest = getBundle("org.apache.felix.metatype");
         try {
@@ -141,7 +142,7 @@ public class ModifiedBundleDependencyTes
         String filter = "(Bundle-SymbolicName=org.apache.felix.metatype)";
         int mask = Bundle.INSTALLED|Bundle.ACTIVE|Bundle.RESOLVED|Bundle.STARTING;
         Component b = component(m).provides(B.class).impl(impl)
-            .withBundle(bundle -> bundle.filter(filter).mask(mask).cbi(Cb.ADD, impl::add).cbi(Cb.CHG, impl::change).cbi(Cb.REM, impl::remove)).build();        	
+            .withBundle(bd -> bd.filter(filter).mask(mask).cbi(Cb.ADD, impl::add).cbi(Cb.CHG, impl::change).cbi(Cb.REM, impl::remove)).build();        	
         
         Bundle dmtest = getBundle("org.apache.felix.metatype");
         try {

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/ServiceDependencyTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/ServiceDependencyTest.java?rev=1724881&r1=1724880&r2=1724881&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/ServiceDependencyTest.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/ServiceDependencyTest.java Fri Jan 15 21:43:31 2016
@@ -38,8 +38,8 @@ public class ServiceDependencyTest exten
         Component sc = component(m).impl(new ServiceConsumer(e)).withService(ServiceInterface.class).build();
         		
         Component sc2 = component(m).impl(new ServiceConsumerCallbacks(e))
-        		.withService(ServiceInterface.class, srv -> srv.required(false).cb(ADD, ServiceConsumerCallbacks::add).cb(REM, ServiceConsumerCallbacks::remove))
-        		.build();
+            .withService(ServiceInterface.class, srv -> srv.required(false).cb(ADD, ServiceConsumerCallbacks::add).cb(REM, ServiceConsumerCallbacks::remove))
+            .build();
 
         m.add(sp);
         m.add(sc);

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/factory/Activator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/factory/Activator.java?rev=1724881&r1=1724880&r2=1724881&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/factory/Activator.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/factory/Activator.java Fri Jan 15 21:43:31 2016
@@ -20,6 +20,7 @@ package org.apache.felix.dependencymanag
 
 import static java.lang.System.out;
 import static org.apache.felix.dm.builder.lambda.Cb.ADD;
+import static org.apache.felix.dm.builder.lambda.Cb.START;
 
 import org.apache.felix.dm.builder.lambda.DependencyActivatorBase;
 import org.osgi.service.log.LogService;
@@ -35,7 +36,7 @@ public class Activator extends Dependenc
         component(comp -> comp
             .factory(ProviderFactory::new, ProviderFactory::create)       
             .provides(Provider.class)
-            .start(ProviderImpl::start)                      
+            .cb(START, ProviderImpl::start)                      
             .withService(LogService.class, srv -> srv.required().cb(ADD, ProviderImpl::set)));
     }
 }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/hello/Activator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/hello/Activator.java?rev=1724881&r1=1724880&r2=1724881&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/hello/Activator.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/hello/Activator.java Fri Jan 15 21:43:31 2016
@@ -19,8 +19,9 @@
 package org.apache.felix.dependencymanager.lambda.samples.hello;
 
 import static java.lang.System.out;
-import static org.apache.felix.dm.builder.lambda.Cb.ADD;
+import static org.apache.felix.dm.builder.lambda.Cb.*;
 
+import org.apache.felix.dm.builder.lambda.Cb;
 import org.apache.felix.dm.builder.lambda.DependencyActivatorBase;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.log.LogService;
@@ -36,7 +37,7 @@ public class Activator extends Dependenc
         component(comp -> comp
             .impl(ServiceProviderImpl.class)
             .provides(ServiceProvider.class, property1 -> "value1", property2 -> 123) // property names are deduced from lambda parameter names
-            .start(ServiceProviderImpl::activate)
+            .cb(START, ServiceProviderImpl::activate)
             .withService(LogService.class, srv -> srv.cb(ADD, ServiceProviderImpl::bind)));
 
         component(comp -> comp

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/rx/observable/ObservableComponent.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/rx/observable/ObservableComponent.java?rev=1724881&r1=1724880&r2=1724881&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/rx/observable/ObservableComponent.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dependencymanager/lambda/samples/rx/observable/ObservableComponent.java Fri Jan 15 21:43:31 2016
@@ -26,6 +26,7 @@ import java.util.List;
 
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
+import org.apache.felix.dm.builder.lambda.Cb;
 import org.osgi.service.log.LogService;
 
 import io.reactivex.Observable;
@@ -79,7 +80,7 @@ public class ObservableComponent {
 	        publisher.onSubscribe(EmptySubscription.INSTANCE);
 			component(m_dm, builder -> builder
 					.factory(() -> new DocumentViewer(title))
-					.start(publisher::onNext));
+					.cbi(Cb.START, publisher::onNext));
 		});
 	}
 }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/Cb.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/Cb.java?rev=1724881&r1=1724880&r2=1724881&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/Cb.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/Cb.java Fri Jan 15 21:43:31 2016
@@ -1,38 +1,70 @@
 package org.apache.felix.dm.builder.lambda;
 
 /**
- * Defines various types of dependency callbacks.
+ * Defines various types of Dependency Manager callbacks (service callbacks, component lifecycle callbacks ...).
  */
 public enum Cb {
     /**
      * Service is added.
      */
-    ADD {
-        @Override
-        public String getCallback() {
-            return "add";
-        }  
-    },
+    ADD,
     
     /**
      * Service properties updated
      */
-    CHG {
-        @Override
-        public String getCallback() {
-            return "change";
-        }  
-    },
+    CHG,
     
     /**
      * Service removed.
      */
-    REM {
-        @Override
-        public String getCallback() {
-            return "remove";
-        }  
-    };
-   
-    public abstract String getCallback();
+    REM,
+    
+    /**
+     * Component initialized.
+     */
+    INIT,
+
+    /**
+     * Component started
+     */
+    START,
+       
+    /**
+     * Component stopped.
+     */
+    STOP,
+    
+    /**
+     * Component destroyed.
+     */
+    DESTROY;   
+    
+    /**
+     * Ensures that this enum is a component lifecycle callback.
+     */
+    public void ensureLifecyleCallback() {
+        switch (this) {
+        case INIT:
+        case START:
+        case STOP:
+        case DESTROY:
+            break;
+        default:
+            throw new IllegalStateException(this + " is not a lifecycle callback");
+        }
+    }
+    
+    /**
+     * Ensures that this enum is a service dependency callback.
+     */
+    public void ensureServiceCallback() {
+        switch (this) {
+        case ADD:
+        case CHG:
+        case REM:
+            break;
+        default:
+            throw new IllegalStateException(this + " is not a service callback");
+        }
+    }
 }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/ComponentBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/ComponentBuilder.java?rev=1724881&r1=1724880&r2=1724881&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/ComponentBuilder.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/ComponentBuilder.java Fri Jan 15 21:43:31 2016
@@ -1,61 +1,43 @@
 package org.apache.felix.dm.builder.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 org.apache.felix.dm.Component;
+import org.apache.felix.dm.builder.lambda.Functions.CbBiConsumer;
+import org.apache.felix.dm.builder.lambda.Functions.CbComponent;
+import org.apache.felix.dm.builder.lambda.Functions.CbConsumer;
+import org.apache.felix.dm.builder.lambda.Functions.FluentProperties;
+
 /**
- * Builds a DependencyManager Component using java8 constructs. This interface provides builder methods used to configure general Component
- * parameters, like:<p>
- * 
- * <ul>
- * <li> factory parameters
- * <li> component service properties
- * <li> component lifecycle callbacks(init/start/stop/destroy)
- * <li> service dependencies
- * <li> configuration dependencies
- * <li> auto-injected OSGi and DM objects (BundleContext, Component, etc ...)
- * </ul>
- * 
- * Code example:
- * 
- * <pre> {@code
- * public class Activator extends DependencyActivatorBase {    
- *     public void init() throws Exception {
- *         component(comp -> comp
- *             .factory(ServiceImplFactory::new, ServiceImplFactory::create)            
- *             .provides(Service.class)
- *             .withService(LogService.class, srv -> srv.required().cb(ADD, ServiceImpl::set))
- *             .start(ServiceImpl::activate));                      
- *     }
- * }
- * }</pre>
+ * Base class for all kinds of component builders.
  *
- * @param <B> This generic parameter is used by interfaces that may extends this builder, like adapters or aspect builders.
- * The intent of this parameter is to be able to make each component builder method return the type of sub-interfaces. 
- * 
- * TODO: add support for reflection for lifecycle callbacks (like in Dependency Manager).
+ * @param <B> the builder that extends this class.
  */
-public interface ComponentBuilder<T> extends ComponentBuilderBase<T, ComponentBuilder<T>> {
-	/**
-	 * 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> ComponentBuilder<U> impl(U impl);   
-	
-	/**
-	 * TODO
-	 */
-	<U> ComponentBuilder<U> impl(Class<U> implClass);   
-
-	/**
-	 * 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> ComponentBuilder<U> factory(Supplier<U> create);
+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);   
+    
+    /**
+     * TODO
+     */
+    <U> B impl(Class<U> implClass);   
+
+    /**
+     * 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.
@@ -67,7 +49,7 @@ public interface ComponentBuilder<T> ext
      * @param create the method reference on the Factory method that is used to create the Component implementation
      * @return this builder
      */
-	<U, V> ComponentBuilder<V> factory(Supplier<U> factory, Function<U, V> create);
+    <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.
@@ -83,7 +65,7 @@ public interface ComponentBuilder<T> ext
      * @param getComposition
      * @return this builder
      */
-    <U> ComponentBuilder<U> factory(Supplier<U> factory, Supplier<Object[]> getComposition);
+    <U> B factory(Supplier<U> factory, Supplier<Object[]> getComposition);
 
     /**
      * Configures a factory that also returns a composition of objects for this component implemenation.
@@ -100,5 +82,151 @@ public interface ComponentBuilder<T> ext
      * @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> ComponentBuilder<V> factory(Supplier<U> factory, Function<U, V> create, Function<U, Object[]> getComposition);
+    <U, V> B factory(Supplier<U> factory, Function<U, V> create, Function<U, Object[]> getComposition);
+
+	B provides(Class<?>  iface);
+	B provides(Class<?>  iface, String name, Object value, Object ... rest);
+    B provides(Class<?>  iface, FluentProperties ... properties);
+    B provides(Class<?>  iface, Dictionary<?,?> properties);
+    
+    B provides(Class<?>[] ifaces);
+    B provides(Class<?>[] ifaces, String name, Object value, Object ... rest);
+    B provides(Class<?>[] ifaces, FluentProperties ... properties);
+    B provides(Class<?>[] ifaces, Dictionary<?,?> properties);
+
+    B provides(String iface);
+    B provides(String iface, String name, Object value, Object ... rest);
+    B provides(String iface, FluentProperties ... properties);
+    B provides(String iface, Dictionary<?,?> properties);
+    
+    B provides(String[] ifaces);
+    B provides(String[] ifaces, String name, Object value, Object ... rest);
+    B provides(String[] ifaces, FluentProperties ... properties);
+    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 dependency that is required and that will be injected in any field with the same dependency type.
+     * @return this builder
+     */
+    B withService(Class<?> service, Class<?> ... services);
+           
+    /**
+     * Adds a service dependency.
+     * @param service the service
+     * @param consumer the lambda for building the service dependency
+     * @return this builder.
+     */
+    <U> B withService(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 withConfiguration(Consumer<ConfigurationDependencyBuilder> consumer);        
+    
+    /**
+     * Adds a bundle dependency.
+     * @param consumer the lambda used to build the bundle dependency.
+     * @return this builder.
+     */
+    B withBundle(Consumer<BundleDependencyBuilder> consumer);        
+
+    /**
+     * TODO
+     * @param future
+     * @return
+     */
+    <U> B withFuture(CompletableFuture<U> future, Consumer<FutureDependencyBuilder<U>> consumer);
+
+    <U> B cb(Cb callbackType, CbConsumer<U> callback);
+    <U> B cb(Cb callbackType, CbBiConsumer<U, Component> callback);
+    B cbi(Cb callbackType, Runnable callback);
+    B cbi(Cb 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 autoInject(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 autoInject(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);
+
+    B composition(Supplier<Object[]> getCompositionMethod);
+
+    /**
+     * Builds the real DependencyManager Component.
+     * @return the real DependencyManager Component.
+     */
+    Component build();
 }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/DependencyActivatorBase.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/DependencyActivatorBase.java?rev=1724881&r1=1724880&r2=1724881&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/DependencyActivatorBase.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/DependencyActivatorBase.java Fri Jan 15 21:43:31 2016
@@ -78,15 +78,15 @@ public abstract class DependencyActivato
      * @return a Component builder that can be used to create a Component.
      */
     protected ComponentBuilder<?> component() {
-        return new ComponentBuilderImpl<Object>(m_manager);
+        return new ComponentBuilderImpl(m_manager);
     }
     
     /**
      * Creates a service Aspect builder that can be used to create an Aspect Component. 
      * @return a service Aspect builder that can be used to create an Aspect Component.
      */
-    protected <T> ServiceAspectBuilder<T, ?> aspect(Class<T> aspectType) {
-        ServiceAspectBuilderImpl<T, ?> aspectBuilder = new ServiceAspectBuilderImpl<>(m_manager, aspectType);
+    protected <T> ServiceAspectBuilder<T> aspect(Class<T> aspectType) {
+        ServiceAspectBuilderImpl<T> aspectBuilder = new ServiceAspectBuilderImpl<>(m_manager, aspectType);
         return aspectBuilder;
     }
     
@@ -94,8 +94,8 @@ public abstract class DependencyActivato
      * Creates a service Adapter builder that can be used to create an Adapter Component. 
      * @return a service Adapter builder that can be used to create an Adapter Component.
      */
-    protected <T> ServiceAdapterBuilder<T,?> adapter(Class<T> adapteeType) {
-        ServiceAdapterBuilderImpl<T, ?> adapterBuilder = new ServiceAdapterBuilderImpl<>(m_manager, adapteeType);
+    protected <T> ServiceAdapterBuilder<T> adapter(Class<T> adapteeType) {
+        ServiceAdapterBuilderImpl<T> adapterBuilder = new ServiceAdapterBuilderImpl<>(m_manager, adapteeType);
         return adapterBuilder;
     }
     
@@ -105,7 +105,7 @@ public abstract class DependencyActivato
      * The component is auto-added to the DependencyManager, unless the lambda calls the ComponentBuilder.autoAdd(false) method.
      * @return a newly built DM component.
      */
-    protected <T> Component component(Consumer<ComponentBuilder<T>> consumer) {
+    protected Component component(Consumer<ComponentBuilder<?>> consumer) {
         return component(m_manager, consumer);
     }
         
@@ -115,7 +115,7 @@ public abstract class DependencyActivato
      * 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) {
+    protected <T> Component aspect(Class<T> aspect, Consumer<ServiceAspectBuilder<T>> consumer) {
         return aspect(m_manager, aspect, consumer);
     }
 
@@ -125,7 +125,7 @@ public abstract class DependencyActivato
      * 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) {
+    protected <T> Component adapter(Class<T> adaptee, Consumer<ServiceAdapterBuilder<T>> consumer) {
         return adapter(m_manager, adaptee, consumer);
     }
     
@@ -135,7 +135,7 @@ public abstract class DependencyActivato
      * The component is auto-added to the DependencyManager, unless the lambda calls the FactoryPidAdapterBuilder.autoAdd(false) method.
      * @return a newly built DM component.
      */
-    protected <T> Component factoryPidAdapter(Consumer<FactoryPidAdapterBuilder<T>> consumer) {
+    protected Component factoryPidAdapter(Consumer<FactoryPidAdapterBuilder> consumer) {
         return factoryPidAdapter(m_manager, consumer);
     }
     
@@ -146,7 +146,7 @@ public abstract class DependencyActivato
      * @return a Component builder that can be used to create a Component.
      */
     public static ComponentBuilder<?> component(DependencyManager dm) {
-        return new ComponentBuilderImpl<Object>(dm);
+        return new ComponentBuilderImpl(dm);
     }
     
     /**
@@ -155,8 +155,8 @@ public abstract class DependencyActivato
      * @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);
+    public static <T> ServiceAspectBuilder<T> aspect(DependencyManager dm, Class<T> aspect) {
+        ServiceAspectBuilderImpl<T> aspectBuilder = new ServiceAspectBuilderImpl<>(dm, aspect);
         return aspectBuilder;
     }
     
@@ -166,8 +166,8 @@ public abstract class DependencyActivato
      * @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);
+    public static <T> ServiceAdapterBuilder<T> adapter(DependencyManager dm, Class<T> adaptee) {
+        ServiceAdapterBuilderImpl<T> adapterBuilder = new ServiceAdapterBuilderImpl<>(dm, adaptee);
         return adapterBuilder;
     }
 
@@ -176,8 +176,8 @@ public abstract class DependencyActivato
      * @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);
+    public static FactoryPidAdapterBuilder factoryPidAdapter(DependencyManager dm) {
+        return new FactoryPidAdapterBuilderImpl(dm);
     }
     
     /**
@@ -188,11 +188,11 @@ public abstract class DependencyActivato
      * 
      * @return the built DM component.
      */
-    public static <T> Component component(DependencyManager dm, Consumer<ComponentBuilder<T>> consumer) {
-        ComponentBuilder<T> componentBuilder = new ComponentBuilderImpl<>(dm);
+    public static Component component(DependencyManager dm, Consumer<ComponentBuilder<?>> consumer) {
+        ComponentBuilder<?> componentBuilder = new ComponentBuilderImpl(dm);
         consumer.accept(componentBuilder);
         Component comp = componentBuilder.build();
-        if (((ComponentBuilderImpl<T>) componentBuilder).isAutoAdd()) {
+        if (((ComponentBuilderImpl) componentBuilder).isAutoAdd()) {
         	dm.add(comp);
         }
         return comp;
@@ -203,8 +203,8 @@ public abstract class DependencyActivato
      * @param comp an existing DM component
      * @param consumer the lambda that will be used to update the component
      */
-    public static <T> void component(Component comp, Consumer<ComponentBuilder<T>> consumer) {
-        ComponentBuilder<T> componentBuilder = new ComponentBuilderImpl<>(comp, true /* update component */);
+    public static void component(Component comp, Consumer<ComponentBuilder<?>> consumer) {
+        ComponentBuilder<?> componentBuilder = new ComponentBuilderImpl(comp, true /* update component */);
         consumer.accept(componentBuilder);
         componentBuilder.build();
     }
@@ -217,8 +217,8 @@ public abstract class DependencyActivato
      * @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);
+    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()) {
@@ -235,8 +235,8 @@ public abstract class DependencyActivato
      * @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);
+    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()) {
@@ -252,8 +252,8 @@ public abstract class DependencyActivato
      * @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<T>> consumer) {
-        FactoryPidAdapterBuilderImpl<T> factoryPidAdapter = new FactoryPidAdapterBuilderImpl<>(dm);
+    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()) {

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/FactoryPidAdapterBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/FactoryPidAdapterBuilder.java?rev=1724881&r1=1724880&r2=1724881&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/FactoryPidAdapterBuilder.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/FactoryPidAdapterBuilder.java Fri Jan 15 21:43:31 2016
@@ -25,83 +25,17 @@ import org.apache.felix.dm.builder.lambd
  *
  * TODO: javadoc
  */
-public interface FactoryPidAdapterBuilder<T> extends ComponentBuilderBase<T, FactoryPidAdapterBuilder<T>> {
-    /**
-     * 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> FactoryPidAdapterBuilder<U> impl(U impl);   
+public interface FactoryPidAdapterBuilder extends ComponentBuilder<FactoryPidAdapterBuilder> {
+    FactoryPidAdapterBuilder factoryPid(String pid);
+    FactoryPidAdapterBuilder factoryPid(Class<?> pidClass);
+    FactoryPidAdapterBuilder propagate();
+    FactoryPidAdapterBuilder propagate(boolean propagate);
     
-    /**
-     * TODO
-     */
-    <U> FactoryPidAdapterBuilder<U> impl(Class<U> implClass);   
-
-    /**
-     * 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> FactoryPidAdapterBuilder<U> factory(Supplier<U> create);
+    FactoryPidAdapterBuilder cb(String updateMethod);
+    FactoryPidAdapterBuilder cb(Object callbackInstance, String updateMethod);
     
-    /**
-     * 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> FactoryPidAdapterBuilder<V> 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> FactoryPidAdapterBuilder<U> 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> FactoryPidAdapterBuilder<V> factory(Supplier<U> factory, Function<U, V> create, Function<U, Object[]> getComposition);
-
-    FactoryPidAdapterBuilder<T> factoryPid(String pid);
-    FactoryPidAdapterBuilder<T> factoryPid(Class<?> pidClass);
-    FactoryPidAdapterBuilder<T> propagate();
-    FactoryPidAdapterBuilder<T> propagate(boolean propagate);
-    
-    FactoryPidAdapterBuilder<T> cb(String updateMethod);
-    FactoryPidAdapterBuilder<T> cb(Object callbackInstance, String updateMethod);
-    
-    <U> FactoryPidAdapterBuilder<T> cb(CbTypeDictionary<U> callback);
-    <U> FactoryPidAdapterBuilder<T> cb(CbTypeComponentDictionary<U> callback);
-    FactoryPidAdapterBuilder<T> cbi(CbDictionary callback);
-    FactoryPidAdapterBuilder<T> cbi(CbComponentDictionary callback);
+    <U> FactoryPidAdapterBuilder cb(CbTypeDictionary<U> callback);
+    <U> FactoryPidAdapterBuilder cb(CbTypeComponentDictionary<U> callback);
+    FactoryPidAdapterBuilder cbi(CbDictionary callback);
+    FactoryPidAdapterBuilder cbi(CbComponentDictionary callback);
 }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/Functions.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/Functions.java?rev=1724881&r1=1724880&r2=1724881&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/Functions.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/Functions.java Fri Jan 15 21:43:31 2016
@@ -4,6 +4,7 @@ import java.io.Serializable;
 import java.util.Dictionary;
 import java.util.Map;
 import java.util.Objects;
+import java.util.function.BiConsumer;
 
 import org.apache.felix.dm.Component;
 import org.osgi.framework.Bundle;
@@ -38,6 +39,26 @@ public class Functions {
         }
     }
     
+    @FunctionalInterface
+    public interface CbConsumer<T> extends SerializableLambda {
+        void accept(T t);
+        
+        default CbConsumer<T> andThen(CbConsumer<? super T> after) {
+            Objects.requireNonNull(after);
+            return (T t) -> { accept(t); after.accept(t); };
+        }
+    }
+    
+    @FunctionalInterface
+    public interface CbBiConsumer<T, U> extends SerializableLambda {
+        void accept(T t, U u);
+
+        default BiConsumer<T, U> andThen(BiConsumer<? super T, ? super U> after) {
+            Objects.requireNonNull(after);
+            return (l, r) -> { accept(l, r); after.accept(l, r); };
+        }
+    }
+    
     @FunctionalInterface
     public interface CbTypeFuture<T, F> extends SerializableLambda {
         void accept(T instance, F future);

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/ServiceAdapterBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/ServiceAdapterBuilder.java?rev=1724881&r1=1724880&r2=1724881&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/ServiceAdapterBuilder.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/ServiceAdapterBuilder.java Fri Jan 15 21:43:31 2016
@@ -19,74 +19,8 @@ import java.util.function.Supplier;
  * @param <T> the adaptee service
  * TODO: add javadoc
  */
-public interface ServiceAdapterBuilder<T, C> extends ComponentBuilderBase<C, ServiceAdapterBuilder<T, C>>, ServiceCallbacksBuilder<T, ServiceAdapterBuilder<T, C>> {
-    /**
-     * 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> ServiceAdapterBuilder<T, U> impl(U impl);   
-    
-    /**
-     * TODO
-     */
-    <U> ServiceAdapterBuilder<T, U> impl(Class<U> implClass);   
-
-    /**
-     * 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> ServiceAdapterBuilder<T, U> 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> ServiceAdapterBuilder<T, V> 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> ServiceAdapterBuilder<T, U> 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> ServiceAdapterBuilder<T, V> factory(Supplier<U> factory, Function<U, V> create, Function<U, Object[]> getComposition);
-
-    ServiceAdapterBuilder<T, C> filter(String adapteeFilter);
-    ServiceAdapterBuilder<T, C> propagate();
-    ServiceAdapterBuilder<T, C> propagate(boolean propagate);
+public interface ServiceAdapterBuilder<T> extends ComponentBuilder<ServiceAdapterBuilder<T>>, ServiceCallbacksBuilder<T, ServiceAdapterBuilder<T>> {
+    ServiceAdapterBuilder<T> filter(String adapteeFilter);
+    ServiceAdapterBuilder<T> propagate();
+    ServiceAdapterBuilder<T> propagate(boolean propagate);
 }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/ServiceAspectBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/ServiceAspectBuilder.java?rev=1724881&r1=1724880&r2=1724881&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/ServiceAspectBuilder.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/ServiceAspectBuilder.java Fri Jan 15 21:43:31 2016
@@ -24,74 +24,7 @@ import java.util.function.Supplier;
  * 
  * TODO: javadoc
  */
-public interface ServiceAspectBuilder<T, C> extends ComponentBuilderBase<C, ServiceAspectBuilder<T, C>>, ServiceCallbacksBuilder<T, ServiceAspectBuilder<T, C>>  {
-    /**
-     * 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> ServiceAspectBuilder<T, U> impl(U impl);   
-    
-    /**
-     * TODO
-     */
-    <U> ServiceAspectBuilder<T, U> impl(Class<U> implClass);   
-
-    /**
-     * 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> ServiceAspectBuilder<T, U> 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> ServiceAspectBuilder<T, V> 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> ServiceAspectBuilder<T, U> 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> ServiceAspectBuilder<T, V> factory(Supplier<U> factory, Function<U, V> create, Function<U, Object[]> getComposition);
-
-    ServiceAspectBuilder<T, C> filter(String filter);
-
-    ServiceAspectBuilder<T, C> rank(int ranking);
+public interface ServiceAspectBuilder<T> extends ComponentBuilder<ServiceAspectBuilder<T>>, ServiceCallbacksBuilder<T, ServiceAspectBuilder<T>>  {
+    ServiceAspectBuilder<T> filter(String filter);
+    ServiceAspectBuilder<T> rank(int ranking);
 }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/AdapterBase.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/AdapterBase.java?rev=1724881&r1=1724880&r2=1724881&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/AdapterBase.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/AdapterBase.java Fri Jan 15 21:43:31 2016
@@ -2,17 +2,18 @@ package org.apache.felix.dm.builder.lamb
 
 import java.util.Dictionary;
 import java.util.concurrent.CompletableFuture;
-import java.util.function.BiConsumer;
 import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.function.Supplier;
 
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.builder.lambda.BundleDependencyBuilder;
+import org.apache.felix.dm.builder.lambda.Cb;
 import org.apache.felix.dm.builder.lambda.ComponentBuilder;
-import org.apache.felix.dm.builder.lambda.ComponentBuilderBase;
 import org.apache.felix.dm.builder.lambda.ConfigurationDependencyBuilder;
+import org.apache.felix.dm.builder.lambda.Functions.CbBiConsumer;
 import org.apache.felix.dm.builder.lambda.Functions.CbComponent;
+import org.apache.felix.dm.builder.lambda.Functions.CbConsumer;
 import org.apache.felix.dm.builder.lambda.Functions.FluentProperties;
 import org.apache.felix.dm.builder.lambda.FutureDependencyBuilder;
 import org.apache.felix.dm.builder.lambda.ServiceDependencyBuilder;
@@ -23,10 +24,40 @@ import org.apache.felix.dm.builder.lambd
  * TODO javadoc
  */
 @SuppressWarnings({"unchecked"})
-public interface AdapterBase<T, B extends ComponentBuilderBase<T, B>> extends ComponentBuilderBase<T, B> {
+public interface AdapterBase<B extends ComponentBuilder<B>> extends ComponentBuilder<B> {
 	
-    void andThenBuild(Consumer<ComponentBuilder<T>> builder);
+    void andThenBuild(Consumer<ComponentBuilder> builder);
     
+    default <U> B impl(U impl) {
+        andThenBuild(compBuilder -> compBuilder.impl(impl));
+        return (B) this;
+    }
+    
+    default <U> B impl(Class<U> implClass) {        
+        andThenBuild(compBuilder -> compBuilder.impl(implClass));
+        return (B) this;
+    }
+
+    default <U> B factory(Supplier<U> create) {        
+        andThenBuild(compBuilder -> compBuilder.factory(create));
+        return (B) this;
+    }
+    
+    default <U, V> B factory(Supplier<U> factory, Function<U, V> create) {        
+        andThenBuild(compBuilder -> compBuilder.factory(factory, create));
+        return (B) this;
+    }
+        
+    default <U> B factory(Supplier<U> factory, Supplier<Object[]> getComposition) {        
+        andThenBuild(compBuilder -> compBuilder.factory(factory, getComposition));
+        return (B) this;
+    }
+
+    default <U, V> B factory(Supplier<U> factory, Function<U, V> create, Function<U, Object[]> getComposition) {       
+        andThenBuild(compBuilder -> compBuilder.factory(factory, create, getComposition));
+        return (B) this;
+    }
+
     default B provides(Class<?>  iface) {
         andThenBuild(compBuilder -> compBuilder.provides(iface));
         return (B) this;
@@ -147,123 +178,23 @@ public interface AdapterBase<T, B extend
         return (B) this;
     }
     
-    default B init(Consumer<T> callback) {
-        andThenBuild(compBuilder -> compBuilder.init(callback));
-        return (B) this;
-    }
-    
-    default B init(BiConsumer<T, Component> callback) {
-        andThenBuild(compBuilder -> compBuilder.init(callback));
+    default <U> B cb(Cb callbackType, CbConsumer<U> callback) {
+        andThenBuild(compBuilder -> compBuilder.cb(callbackType, callback));
         return (B) this;
     }
     
-    default B init(Runnable callback) {
-        andThenBuild(compBuilder -> compBuilder.init(callback));
+    default <U> B cb(Cb callbackType, CbBiConsumer<U, Component> callback) {
+        andThenBuild(compBuilder -> compBuilder.cb(callbackType, callback));
         return (B) this;
     }
     
-    default <U> B init(Class<U> type, Consumer<U> callback) {
-        andThenBuild(compBuilder -> compBuilder.init(type, callback));
+    default B cbi(Cb callbackType, Runnable callback) {
+        andThenBuild(compBuilder -> compBuilder.cbi(callbackType, callback));
         return (B) this;
     }
     
-    default <U> B init(Class<U> type, BiConsumer<U, Component> callback) {
-        andThenBuild(compBuilder -> compBuilder.init(type, callback));
-        return (B) this;
-    }
-
-    default B init(CbComponent callback) {
-        andThenBuild(compBuilder -> compBuilder.init(callback));
-        return (B) this;
-    }
-    
-    default B start(Consumer<T> callback) {
-        andThenBuild(compBuilder -> compBuilder.start(callback));
-        return (B) this;
-    }
-    
-    default B start(BiConsumer<T, Component> callback) {
-        andThenBuild(compBuilder -> compBuilder.start(callback));
-        return (B) this;
-    }
-    
-    default <U> B start(Class<U> type, Consumer<U> callback) {
-        andThenBuild(compBuilder -> compBuilder.start(type, callback));
-        return (B) this;
-    }
-    
-    default <U> B start(Class<U> type, BiConsumer<U, Component> callback) {
-        andThenBuild(compBuilder -> compBuilder.start(type, callback));
-        return (B) this;
-    }
-    
-    default B start(Runnable callback) {
-        andThenBuild(compBuilder -> compBuilder.start(callback));
-        return (B) this;
-    }
-
-    default B start(CbComponent callback) {
-        andThenBuild(compBuilder -> compBuilder.init(callback));
-        return (B) this;
-    }
-
-    default B stop(Consumer<T> callback) {
-        andThenBuild(compBuilder -> compBuilder.stop(callback));
-        return (B) this;
-    }
-    
-    default B stop(BiConsumer<T, Component> callback) {
-        andThenBuild(compBuilder -> compBuilder.stop(callback));
-        return (B) this;
-    }
-    
-    default <U> B stop(Class<U> type, Consumer<U> callback) {
-        andThenBuild(compBuilder -> compBuilder.stop(type, callback));
-        return (B) this;
-    }
-    
-    default <U> B stop(Class<U> type, BiConsumer<U, Component> callback) {
-        andThenBuild(compBuilder -> compBuilder.stop(type, callback));
-        return (B) this;
-    }
-    
-    default B stop(Runnable callback) {
-        andThenBuild(compBuilder -> compBuilder.stop(callback));
-        return (B) this;
-    }
-
-    default B stop(CbComponent callback) {
-        andThenBuild(compBuilder -> compBuilder.init(callback));
-        return (B) this;
-    }
-
-    default B destroy(Consumer<T> callback) {
-        andThenBuild(compBuilder -> compBuilder.destroy(callback));
-        return (B) this;
-    }
-    
-    default B destroy(BiConsumer<T, Component> callback) {
-        andThenBuild(compBuilder -> compBuilder.destroy(callback));
-        return (B) this;
-    }
-    
-    default <U> B destroy(Class<U> type, Consumer<U> callback) {
-        andThenBuild(compBuilder -> compBuilder.destroy(type, callback));
-        return (B) this;
-    }
-    
-    default <U> B destroy(Class<U> type, BiConsumer<U, Component> callback) {
-        andThenBuild(compBuilder -> compBuilder.destroy(type, callback));
-        return (B) this;
-    }
-    
-    default B destroy(Runnable callback) {
-        andThenBuild(compBuilder -> compBuilder.destroy(callback));
-        return (B) this;
-    }
-
-    default B destroy(CbComponent callback) {
-        andThenBuild(compBuilder -> compBuilder.init(callback));
+    default B cbi(Cb callbackType, CbComponent callback) {
+        andThenBuild(compBuilder -> compBuilder.cbi(callbackType, callback));
         return (B) this;
     }
 

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/BundleDependencyBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/BundleDependencyBuilderImpl.java?rev=1724881&r1=1724880&r2=1724881&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/BundleDependencyBuilderImpl.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/BundleDependencyBuilderImpl.java Fri Jan 15 21:43:31 2016
@@ -38,7 +38,7 @@ public class BundleDependencyBuilderImpl
 	private Supplier<Dictionary<?, ?>> m_propagateSupplier;
 	private final Component m_component;
     
-	private final Map<String, List<MethodRef<Object>>> m_refs = new HashMap<>();
+	private final Map<Cb, List<MethodRef<Object>>> m_refs = new HashMap<>();
 
     @FunctionalInterface
     interface MethodRef<I> {
@@ -171,24 +171,24 @@ public class BundleDependencyBuilderImpl
 
     @Override
     public <T> BundleDependencyBuilder cb(Cb callbackType, CbTypeBundle<T> callback) {      
-        return setComponentCallbackRef(callbackType.getCallback(), Helpers.getLambdaGenericType(callback, 0),
+        return setComponentCallbackRef(callbackType, Helpers.getLambdaGenericType(callback, 0),
             (inst, component, bundle) -> callback.accept ((T) inst, bundle));
     }
 
     @Override
     public <T> BundleDependencyBuilder cb(Cb callbackType, CbTypeComponentBundle<T> callback) {
-        return setComponentCallbackRef(callbackType.getCallback(), Helpers.getLambdaGenericType(callback, 0),
+        return setComponentCallbackRef(callbackType, Helpers.getLambdaGenericType(callback, 0),
             (inst, component, bundle) -> callback.accept ((T) inst, component, bundle));
     }
     
     @Override
     public BundleDependencyBuilder cbi(Cb callbackType, CbBundle callback) {
-        return setInstanceCallbackRef(callbackType.getCallback(), (inst, component, bundle) -> callback.accept(bundle));
+        return setInstanceCallbackRef(callbackType, (inst, component, bundle) -> callback.accept(bundle));
     }
 
     @Override
     public BundleDependencyBuilder cbi(Cb callbackType, CbComponentBundle callback) {
-        return setInstanceCallbackRef(callbackType.getCallback(), (inst, component, bundle) -> callback.accept(component, bundle));
+        return setInstanceCallbackRef(callbackType, (inst, component, bundle) -> callback.accept(component, bundle));
     }
 
 	@Override
@@ -229,18 +229,20 @@ public class BundleDependencyBuilderImpl
         return dep;
 	}
 
-	private <T> BundleDependencyBuilder setInstanceCallbackRef(String cb, MethodRef<T> ref) {
+	private <T> BundleDependencyBuilder setInstanceCallbackRef(Cb cbType, MethodRef<T> ref) {
+	    cbType.ensureServiceCallback();
 		requiresNoStringCallbacks();
 		if (! m_autoConfigInvoked) m_autoConfig = false;
-		List<MethodRef<Object>> list = m_refs.computeIfAbsent(cb, l -> new ArrayList<>());
+		List<MethodRef<Object>> list = m_refs.computeIfAbsent(cbType, l -> new ArrayList<>());
 		list.add((instance, component, bundle) -> ref.accept(null, component, bundle));
 		return this;
 	}
 	
-	private <T> BundleDependencyBuilder setComponentCallbackRef(String cb, Class<T> type, MethodRef<T> ref) {
-		requiresNoStringCallbacks();
+	private <T> BundleDependencyBuilder setComponentCallbackRef(Cb cbType, Class<T> type, MethodRef<T> ref) {
+	    cbType.ensureServiceCallback();
+	    requiresNoStringCallbacks();
 		if (! m_autoConfigInvoked) m_autoConfig = false;
-		List<MethodRef<Object>> list = m_refs.computeIfAbsent(cb, l -> new ArrayList<>());
+		List<MethodRef<Object>> list = m_refs.computeIfAbsent(cbType, l -> new ArrayList<>());
 		list.add((instance, component, bundle) -> {
             Stream.of(component.getInstances()).forEach(inst -> {
                 if (Helpers.getClass(inst).equals(type)) {
@@ -257,23 +259,23 @@ public class BundleDependencyBuilderImpl
 
 		cb = new Object() {
 			void add(Component c, Bundle bundle) {
-				invokeMethodRefs("add", c, bundle);
+				invokeMethodRefs(Cb.ADD, c, bundle);
 			}
 
 			void change(Component c, Bundle bundle) {
-				invokeMethodRefs("change", c, bundle);
+				invokeMethodRefs(Cb.CHG, c, bundle);
 			}
 
 			void remove(Component c, Bundle bundle) {
-				invokeMethodRefs("remove", c, bundle);
+				invokeMethodRefs(Cb.REM, c, bundle);
 			}
 		};
 
 		return cb;
 	}
 
-	private void invokeMethodRefs(String method, Component c, Bundle bundle) {
-		m_refs.computeIfPresent(method, (k, mrefs) -> {
+	private void invokeMethodRefs(Cb cbType, Component c, Bundle bundle) {
+		m_refs.computeIfPresent(cbType, (k, mrefs) -> {
 			mrefs.forEach(mref -> mref.accept(null, c, bundle));
 			return mrefs;
 		});



Mime
View raw message