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 23:52:57 UTC
svn commit: r1727446 - in
/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda:
./ impl/
Author: pderop
Date: Thu Jan 28 22:52:57 2016
New Revision: 1727446
URL: http://svn.apache.org/viewvc?rev=1727446&view=rev
Log:
Javadoc.
Modified:
felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleDependencyBuilder.java
felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java
felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ConfigurationDependencyBuilder.java
felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyActivatorBase.java
felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FactoryPidAdapterBuilder.java
felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FutureDependencyBuilder.java
felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAdapterBuilder.java
felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAspectBuilder.java
felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java
felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceDependencyBuilder.java
felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java
Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleDependencyBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleDependencyBuilder.java?rev=1727446&r1=1727445&r2=1727446&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleDependencyBuilder.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleDependencyBuilder.java Thu Jan 28 22:52:57 2016
@@ -20,7 +20,7 @@ import org.osgi.framework.Bundle;
* public void init() throws Exception {
* component(comp -> comp
* .impl(MyComponent.class)
- * .withBundle(b -> b.filter("(Bundle-SymbolicName=" + BSN + ")").cb(MyComponent::add, MyComponent::remove))
+ * .withBundle(b -> b.filter("(Bundle-SymbolicName=" + BSN + ")").cb(MyComponent::add, MyComponent::remove)));
*
* }
* } </pre></blockquote>
Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java?rev=1727446&r1=1727445&r2=1727446&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java Thu Jan 28 22:52:57 2016
@@ -16,7 +16,18 @@ import org.apache.felix.dm.lambda.callba
/**
* 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 ...).
+ * <p> Example of a component that depends on a ConfigurationAdmin service. The dependency is injected by reflection
+ * on a class field which type matches the ConfigurationAdmin interface:
+ *
+ * <blockquote><pre>
+ * public class Activator extends DependencyActivatorBase {
+ * public void init() throws Exception {
+ * component(comp -> comp.impl(Configurator.class).withSrv(ConfigurationAdmin.class));
+ * }
+ * } </pre></blockquote>
+ *
+ * @param <B> the type of a builder that may extends this builder interface (aspect/adapter).
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public interface ComponentBuilder<B extends ComponentBuilder<B>> {
/**
@@ -27,13 +38,6 @@ public interface ComponentBuilder<B exte
<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.
@@ -356,53 +360,301 @@ public interface ComponentBuilder<B exte
<U> B withFuture(CompletableFuture<U> future, Consumer<FutureDependencyBuilder<U>> consumer);
/**
- * TODO
+ * Sets the name of the method used as the "init" callback. This method, when found, is
+ * invoked as part of the life cycle management of the component implementation.
+ * This method is useful because when it is invoked, all required dependencies defines in the Activator
+ * are already injected, and you can then add more extra dependencies from the init() method.
+ * And once all extra dependencies will be available and injected, then the "start" callback will be invoked.
+ * The dependency manager will look for a method of this name with the following signatures,
+ * in this order:
+ * <ol>
+ * <li>method(Component component)</li>
+ * <li>method()</li>
+ * </ol>
+ *
+ * @param callback the name of the init method
* @return this builder.
*/
B init(String callback);
+
+ /**
+ * Sets the name of the method used as the "start" callback. This method, when found, is
+ * invoked as part of the life cycle management of the component implementation. The
+ * dependency manager will look for a method of this name with the following signatures,
+ * in this order:
+ * <ol>
+ * <li>method(Component component)</li>
+ * <li>method()</li>
+ * </ol>
+ *
+ * @param init the name of the init method
+ * @return this builder.
+ */
B start(String callback);
+
+ /**
+ * Sets the name of the method used as the "stop" callback. This method, when found, is
+ * invoked as part of the life cycle management of the component implementation. The
+ * dependency manager will look for a method of this name with the following signatures,
+ * in this order:
+ * <ol>
+ * <li>method(Component component)</li>
+ * <li>method()</li>
+ * </ol>
+ *
+ * @param init the name of the init method
+ * @return this builder.
+ */
B stop(String callback);
+
+ /**
+ * Sets the name of the method used as the "destroy" callback. This method, when found, is
+ * invoked as part of the life cycle management of the component implementation. The
+ * dependency manager will look for a method of this name with the following signatures,
+ * in this order:
+ * <ol>
+ * <li>method(Component component)</li>
+ * <li>method()</li>
+ * </ol>
+ *
+ * @param init the name of the init method
+ * @return this builder.
+ */
B destroy(String callback);
+ /**
+ * Sets the name of the methods used as init callback that is invoked on a given Object instance.
+ * These methods, when found, are invoked on the specified instance as part of the life cycle management
+ * of the component implementation.
+ * <p>
+ * Specifying an instance means you can create a manager
+ * that will be invoked whenever the life cycle of a component changes and this manager
+ * can then decide how to expose this life cycle to the actual component, offering an
+ * important indirection when developing your own component models.
+ * @see #init(String)
+ * @param callback the name of the init method
+ * @return this builder.
+ */
B init(Object callbackInstance, String callback);
+
+ /**
+ * Sets the name of the methods used as start callback that is invoked on a given Object instance.
+ * These methods, when found, are invoked on the specified instance as part of the life cycle management
+ * of the component implementation.
+ * <p>
+ * Specifying an instance means you can create a manager
+ * that will be invoked whenever the life cycle of a component changes and this manager
+ * can then decide how to expose this life cycle to the actual component, offering an
+ * important indirection when developing your own component models.
+ * @see #start(String)
+ * @param callback the name of the start method
+ * @return this builder.
+ */
B start(Object callbackInstance, String callback);
+
+ /**
+ * Sets the name of the methods used as stop callback that is invoked on a given Object instance.
+ * These methods, when found, are invoked on the specified instance as part of the life cycle management
+ * of the component implementation.
+ * <p>
+ * Specifying an instance means you can create a manager
+ * that will be invoked whenever the life cycle of a component changes and this manager
+ * can then decide how to expose this life cycle to the actual component, offering an
+ * important indirection when developing your own component models.
+ * @see #stop(String)
+ * @param callback the name of the stop method
+ * @return this builder.
+ */
B stop(Object callbackInstance, String callback);
+
+ /**
+ * Sets the name of the methods used as destroy callback that is invoked on a given Object instance.
+ * These methods, when found, are invoked on the specified instance as part of the life cycle management
+ * of the component implementation.
+ * <p>
+ * Specifying an instance means you can create a manager
+ * that will be invoked whenever the life cycle of a component changes and this manager
+ * can then decide how to expose this life cycle to the actual component, offering an
+ * important indirection when developing your own component models.
+ * @see #destroy(String)
+ * @param callback the name of the destroy method
+ * @return this builder.
+ */
B destroy(Object callbackInstance, String callback);
/**
- * TODO
+ * Sets a method reference used as the "init" callback. This method reference must point to method from one
+ * of the component instance classes. It is invoked as part of the life cycle management of the component implementation.
+ * This method is useful because when it is invoked, all required dependencies defines in the Activator
+ * are already injected, and you can then add more extra dependencies from the init() method.
+ * And once all extra dependencies will be available and injected, then the "start" callback will be invoked.
+ * The method does not take any parameters.
+ *
+ * @param callback a method reference must point to method from one of the component instance classes.
* @return this builder
*/
<U> B init(CbConsumer<U> callback);
+
+ /**
+ * Sets a method reference used as the "start" callback. This method reference must point to method from one
+ * of the component instance classes. This method is invoked as part of the life cycle management of the component implementation.
+ *
+ * @param callback a method reference must point to method from one of the component instance classes.
+ * @return this builder.
+ */
<U> B start(CbConsumer<U> callback);
+
+ /**
+ * Sets a method reference used as the "stop" callback. This method reference must point to method from one
+ * of the component instance classes. This method is invoked as part of the life cycle management of the component implementation.
+ *
+ * @param callback a method reference must point to method from one of the component instance classes.
+ * @return this builder.
+ */
<U> B stop(CbConsumer<U> callback);
+
+ /**
+ * Sets a method reference used as the "destroy" callback. This method reference must point to method from one
+ * of the component instance classes. This method is invoked as part of the life cycle management of the component implementation.
+ *
+ * @param callback a method reference must point to method from one of the component instance classes.
+ * @return this builder.
+ */
<U> B destroy(CbConsumer<U> callback);
/**
- * TODO
+ * Sets a method reference used as the "init" callback. This method reference must point to method from one
+ * of the component instance classes. It is invoked as part of the life cycle management of the component implementation.
+ * This method is useful because when it is invoked, all required dependencies defines in the Activator
+ * are already injected, and you can then add more extra dependencies from the init() method.
+ * And once all extra dependencies will be available and injected, then the "start" callback will be invoked.
+ * The method takes as argument a Component parameter.
+ *
+ * @param callback a method reference must point to method from one of the component instance classes. The method takes as argument a Component parameter.
* @return this builder
*/
<U> B init(CbTypeComponent<U> callback);
+
+ /**
+ * Sets a method reference used as the "start" callback. This method reference must point to method from one
+ * of the component instance classes. This method is invoked as part of the life cycle management of the component implementation.
+ * The method takes as argument a Component parameter.
+ *
+ * @param callback a method reference must point to method from one of the component instance classes. The method takes as argument a Component parameter.
+ * @return this builder.
+ */
<U> B start(CbTypeComponent<U> callback);
+
+ /**
+ * Sets a method reference used as the "stop" callback. This method reference must point to method from one
+ * of the component instance classes. This method is invoked as part of the life cycle management of the component implementation.
+ * The method takes as argument a Component parameter.
+ *
+ * @param callback a method reference must point to method from one of the component instance classes. The method takes as argument a Component parameter.
+ * @return this builder.
+ */
<U> B stop(CbTypeComponent<U> callback);
+
+ /**
+ * Sets a method reference used as the "destroy" callback. This method reference must point to method from one
+ * of the component instance classes. This method is invoked as part of the life cycle management of the component implementation.
+ * The method takes as argument a Component parameter.
+ *
+ * @param callback a method reference must point to method from one of the component instance classes. The method takes as argument a Component parameter.
+ * @return this builder.
+ */
<U> B destroy(CbTypeComponent<U> callback);
/**
- * TODO
+ * Sets an Object instance method reference used as the "init" callback. It is invoked as part of the life cycle management of the component
+ * implementation.
+ * This method is useful because when it is invoked, all required dependencies defines in the Activator
+ * are already injected, and you can then add more extra dependencies from the init() method.
+ * And once all extra dependencies will be available and injected, then the "start" callback will be invoked.
+ * The method does not take any parameters.
+ *
+ * @param callback an Object instance method reference. The method does not take any parameters.
* @return this builder
*/
B initInstance(Runnable callback);
+
+ /**
+ * Sets an Object instance method reference used as the "start" callback. This method reference must point to method from one
+ * of the component instance classes. This method is invoked as part of the life cycle management of the component implementation.
+ * The method does not take any parameters.
+ *
+ * @param callback an Object instance method reference. The method does not take any parameters.
+ * @return this builder.
+ */
B startInstance(Runnable callback);
+
+ /**
+ * Sets an Object instance method reference used as the "stop" callback. It is invoked as part of the life cycle management of the component
+ * implementation.
+ * This method is useful because when it is invoked, all required dependencies defines in the Activator
+ * are already injected, and you can then add more extra dependencies from the init() method.
+ * And once all extra dependencies will be available and injected, then the "start" callback will be invoked.
+ * The method does not take any parameters.
+ *
+ * @param callback an Object instance method reference. The method does not take any parameters.
+ * @return this builder
+ */
B stopInstance(Runnable callback);
+
+ /**
+ * Sets an Object instance method reference used as the "destroy" callback. It is invoked as part of the life cycle management of the component
+ * implementation.
+ * This method is useful because when it is invoked, all required dependencies defines in the Activator
+ * are already injected, and you can then add more extra dependencies from the init() method.
+ * And once all extra dependencies will be available and injected, then the "start" callback will be invoked.
+ * The method does not take any parameters.
+ *
+ * @param callback an Object instance method reference. The method does not take any parameters.
+ * @return this builder
+ */
B destroyInstance(Runnable callback);
/**
- * TODO
- * @return this builder.
+ * Sets an Object instance method reference used as the "init" callback. It is invoked as part of the life cycle management of the component
+ * implementation.
+ * This method is useful because when it is invoked, all required dependencies defines in the Activator
+ * are already injected, and you can then add more extra dependencies from the init() method.
+ * And once all extra dependencies will be available and injected, then the "start" callback will be invoked.
+ * The method takes as argument a Component parameter.
+ *
+ * @param callback an Object instance method reference.
+ * @return this builder
*/
B initInstance(CbComponent callback);
+
+ /**
+ * Sets an Object instance method reference used as the "start" callback. This method reference must point to method from one
+ * of the component instance classes. This method is invoked as part of the life cycle management of the component implementation.
+ * The method takes as argument a Component parameter.
+ *
+ * @param callback an Object instance method reference. The method takes as argument a Component parameter.
+ * @return this builder.
+ */
B startInstance(CbComponent callback);
+
+ /**
+ * Sets an Object instance method reference used as the "stop" callback. This method reference must point to method from one
+ * of the component instance classes. This method is invoked as part of the life cycle management of the component implementation.
+ * The method takes as argument a Component parameter.
+ *
+ * @param callback an Object instance method reference. The method takes as argument a Component parameter.
+ * @return this builder.
+ */
B stopInstance(CbComponent callback);
+
+ /**
+ * Sets an Object instance method reference used as the "destroy" callback. This method reference must point to method from one
+ * of the component instance classes. This method is invoked as part of the life cycle management of the component implementation.
+ * The method takes as argument a Component parameter.
+ *
+ * @param callback an Object instance method reference. The method takes as argument a Component parameter.
+ * @return this builder.
+ */
B destroyInstance(CbComponent callback);
/**
@@ -442,24 +694,35 @@ public interface ComponentBuilder<B exte
B autoAdd();
/**
- * TODO
- * @param method
- * @return
+ * Sets the method to invoke on the service implementation to get back all
+ * instances that are part of a composition and need dependencies injected.
+ * All of them will be searched for any of the dependencies. The method that
+ * is invoked must return an <code>Object[]</code>.
+ *
+ * @param getMethod the method to invoke
+ * @return this builder
*/
B composition(String getCompositionMethod);
/**
- * TODO
- * @param instance
- * @param method
- * @return
+ * Sets the instance and method to invoke to get back all instances that
+ * are part of a composition and need dependencies injected. All of them
+ * will be searched for any of the dependencies. The method that is
+ * invoked must return an <code>Object[]</code>.
+ *
+ * @param instance the instance that has the method
+ * @param getMethod the method to invoke
+ * @return this builder
*/
B composition(Object instance, String getCompositionMethod);
/**
- * TODO
- * @param getCompositionMethod
- * @return
+ * Sets a java8 method reference to a Supplier that returns all instances that are part of a composition and need dependencies injected.
+ * All of them will be searched for any of the dependencies. The method that
+ * is invoked must return an <code>Object[]</code>.
+ *
+ * @param getMethod the method to invoke
+ * @return this builder
*/
B composition(Supplier<Object[]> getCompositionMethod);
Modified: 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=1727446&r1=1727445&r2=1727446&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ConfigurationDependencyBuilder.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ConfigurationDependencyBuilder.java Thu Jan 28 22:52:57 2016
@@ -10,7 +10,8 @@ import org.apache.felix.dm.lambda.callba
* 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:
+ * <p> Code example with a component that defines a Configuration Dependency. the ServiceImpl modified method
+ * callback is declared using a method reference (see the "cb(ServiceImpl::modified)" code):
*
* <pre> {@code
* public class Activator extends DependencyActivatorBase {
@@ -20,53 +21,64 @@ import org.apache.felix.dm.lambda.callba
* .withConf(conf -> conf.pid(ServiceConsumer.class).cb(ServiceImpl::modified)));
* }
* }</pre>
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public interface ConfigurationDependencyBuilder extends DependencyBuilder<ConfigurationDependency> {
/**
- * Specifies the pid for this configuration dependency.
+ * Sets 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.
+ * Sets 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).
+ * Sets 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).
+ * Sets 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.
+ * Sets 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.
+ * Sets a <code>callback</code> 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.
+ * Sets a <code>callback instance</code> to call on a given object instance when the configuration is updated.
+ * When the updated method is invoked, the Component implementation has not yet been instantiated, unless you have called
+ * the @link {@link #needsInstance(boolean)} method with "true".
+ *
* @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
@@ -74,29 +86,39 @@ public interface ConfigurationDependency
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.
+ * Sets a <code>callback</code> method reference used to invoke an update method. The method reference must point to a method from one of the component
+ * implementation classes, and is invoked when the configuration is updated.
+ *
+ * @param updateMethod the callback method reference which must point to a method from one of the component implementation classes. The method
+ * takes as argument a Dictionary.
* @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.
+ * Sets the <code>callback</code> method reference used to invoke an update method. The method reference must point to a method from one of the
+ * component implementation classes, and is invoked 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.
+ * The method takes as argument a Component and a Dictionary.
* @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.
+ * Sets a <code>callback instance</code> method reference used to invoke the update method. The method reference must point to an Object instance
+ * method which takes as argument a Dictionary.
+ *
+ * @param updateMethod a method reference that points to an Object instance method which takes as argument a Dictionary.
+ * @return this builder
+ */
+ ConfigurationDependencyBuilder cbi(CbDictionary updated);
+
+ /**
+ * Sets a <code>callback instance</code> method reference used to invoke the update method. The method reference must point to an Object instance method
+ * which takes as argument a Component and a Dictionary.
+ *
+ * @param updateMethod a method reference that points to an Object instance method which takes as argument a Component and a Dictionary.
* @return this builder
*/
ConfigurationDependencyBuilder cbi(CbComponentDictionary updated);
Modified: 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=1727446&r1=1727445&r2=1727446&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyActivatorBase.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyActivatorBase.java Thu Jan 28 22:52:57 2016
@@ -56,7 +56,7 @@ import org.osgi.framework.BundleContext;
*
* <pre> {@code
*
- * import static org.apache.felix.dm.builder.lambda.DependencyActivatorBase.*;
+ * import static org.apache.felix.dm.lambda.DependencyActivatorBase.*;
*
* public class Activator extends DependencyActivatorBase {
* public void init() throws Exception {
Modified: 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=1727446&r1=1727445&r2=1727446&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FactoryPidAdapterBuilder.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FactoryPidAdapterBuilder.java Thu Jan 28 22:52:57 2016
@@ -6,9 +6,9 @@ import org.apache.felix.dm.lambda.callba
import org.apache.felix.dm.lambda.callbacks.CbTypeDictionary;
/**
- * Defines the interface for a Dependency Manager Factory Configuration Adapter.
+ * Builder for a DM Factory Configuration Adapter Component.<p>
*
- * Example that defines a factory configuration adapter service for the "foo.bar" factory pid.
+ * Example that defines a factory configuration adapter service for the "foo.bar" factory pid:
*
* <pre> {@code
* public class Activator extends DependencyActivatorBase {
Modified: 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=1727446&r1=1727445&r2=1727446&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FutureDependencyBuilder.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FutureDependencyBuilder.java Thu Jan 28 22:52:57 2016
@@ -7,49 +7,46 @@ import org.apache.felix.dm.lambda.callba
import org.apache.felix.dm.lambda.callbacks.CbTypeFuture;
/**
- * Defines a builder for CompletableFuture dependency.
+ * Defines a builder for CompletableFuture required 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.
+ * represented by a standard jdk <code>CompletableFuture</code> object;
+ *
+ * A FutureDependency is required and unblock the Component once the future result has completed.
*
* <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
+ * <p> Here is an Activator that 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 MyComponent::setPage method and
* the component is then called in its start method:
*
- * <blockquote>
- * <pre>
+ * <pre> {@code
*
* public class Activator extends DependencyActivatorBase {
- *
- * @Override
* public void init() throws Exception {
* String url = "http://felix.apache.org/";
- * CompletableFuture<String> felixFuture = CompletableFuture.supplyAsync(() -> downloadSite(url));
+ * CompletableFuture<String> page = CompletableFuture.supplyAsync(() -> downloadSite(url));
*
- * // The component depends on a log service and on the content of the Felix site.
+ * // 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)));
- *
+ * .impl(MyComponent.class)
+ * .withService(LogService.class, log -> log.onAdd(MyComponent::bindLog))
+ * .withFuture(page, future -> future.cb(MyComponent::setPage)));
* }
* }
- * </pre>
- * </blockquote>
+ * }</pre>
*
* @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.
+ * Sets 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.
+ * Sets 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.
@@ -59,51 +56,50 @@ public interface FutureDependencyBuilder
/**
* 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.
+ * @param callback the function to perform when the future task as completed.
* @return this dependency
*/
- <T> FutureDependencyBuilder<F> cb(CbTypeFuture<T, ? super F> action);
+ <T> FutureDependencyBuilder<F> cb(CbTypeFuture<T, ? super F> callback);
/**
* 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 callback the function to perform when the future task as completed.
* @return this dependency
*/
- <T> FutureDependencyBuilder<F> cb(CbTypeFuture<T, ? super F> action, boolean async);
+ <T> FutureDependencyBuilder<F> cb(CbTypeFuture<T, ? super F> callback, 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 callback 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);
+ <T> FutureDependencyBuilder<F> cb(CbTypeFuture<T, ? super F> callback, 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.
+ * @param callback a Consumer instance which accepts the result of the completed future.
* @return this dependency
*/
- FutureDependencyBuilder<F> cbi(CbFuture<? super F> action);
+ FutureDependencyBuilder<F> cbi(CbFuture<? super F> callback);
/**
* 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.
+ * @param callback a Consumer instance which accepts the result of the completed future.
* @return this dependency
*/
- FutureDependencyBuilder<F> cbi(CbFuture<? super F> action, boolean async);
+ FutureDependencyBuilder<F> cbi(CbFuture<? super F> callback, 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 callback 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);
+ FutureDependencyBuilder<F> cbi(CbFuture<? super F> callback, Executor executor);
}
Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAdapterBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAdapterBuilder.java?rev=1727446&r1=1727445&r2=1727446&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAdapterBuilder.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAdapterBuilder.java Thu Jan 28 22:52:57 2016
@@ -11,7 +11,8 @@ package org.apache.felix.dm.lambda;
* <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");
+ * adapter(Device.class, adapt -> adapt
+ * .impl(DeviceServlet.class).provides(HttpServlet.class).properties(alias -> "/device");
* }
* }}</pre>
*
Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAspectBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAspectBuilder.java?rev=1727446&r1=1727445&r2=1727446&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAspectBuilder.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceAspectBuilder.java Thu Jan 28 22:52:57 2016
@@ -11,11 +11,9 @@ package org.apache.felix.dm.lambda;
* <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))
+ * aspect(DictionaryService.class, asp -> asp
+ * .filter("(lang=en)").rank(10).impl(DictionaryAspect.class)
+ * .cb(dict -> dict.cb(DictionaryAspect::bind))
* .withSrv(LogService.class, log -> log.required(false)));
* }
* }}</pre>
Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java?rev=1727446&r1=1727445&r2=1727446&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java Thu Jan 28 22:52:57 2016
@@ -28,7 +28,7 @@ import org.apache.felix.dm.lambda.callba
import org.apache.felix.dm.lambda.callbacks.CbTypeServiceService;
/**
- * Builds a service dependency callback.
+ * Builds a service dependency callback (required by default).
*
* 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>
Modified: 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=1727446&r1=1727445&r2=1727446&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceDependencyBuilder.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceDependencyBuilder.java Thu Jan 28 22:52:57 2016
@@ -8,7 +8,10 @@ import org.apache.felix.dm.ServiceDepend
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.
+ * Defines a Service dependency. Dependency callbacks can be defined using methods reflection like
+ * (like in original DM Api), or using Java8 method references.
+ *
+ * Unlike with original DM, dependencies are required by default.
*
* @param <S> the type of the service dependency
*/
Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java?rev=1727446&r1=1727445&r2=1727446&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java (original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java Thu Jan 28 22:52:57 2016
@@ -254,13 +254,7 @@ public class ComponentBuilderImpl implem
m_impl = instance;
return this;
}
-
- @Override
- public <U> ComponentBuilderImpl impl(Class<U> implClass) {
- m_impl = implClass;
- return this;
- }
-
+
@Override
public ComponentBuilderImpl factory(Object factory, String createMethod) {
m_factory = factory;