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/02/18 22:07:18 UTC
svn commit: r1731147 [5/7] - in /felix/trunk/dependencymanager:
org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/
org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/compositefact...
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java?rev=1731147&r1=1731146&r2=1731147&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java Thu Feb 18 21:07:16 2016
@@ -1,37 +1,35 @@
package org.apache.felix.dm.lambda;
-import org.apache.felix.dm.lambda.callbacks.CbComponent;
-import org.apache.felix.dm.lambda.callbacks.CbComponentRef;
-import org.apache.felix.dm.lambda.callbacks.CbComponentRefService;
-import org.apache.felix.dm.lambda.callbacks.CbComponentRefServiceRefService;
-import org.apache.felix.dm.lambda.callbacks.CbComponentService;
-import org.apache.felix.dm.lambda.callbacks.CbComponentServiceService;
-import org.apache.felix.dm.lambda.callbacks.CbRef;
-import org.apache.felix.dm.lambda.callbacks.CbRefService;
import org.apache.felix.dm.lambda.callbacks.CbRefServiceRefService;
+import org.apache.felix.dm.lambda.callbacks.CbRefServiceRefServiceComponent;
import org.apache.felix.dm.lambda.callbacks.CbService;
+import org.apache.felix.dm.lambda.callbacks.CbServiceComponent;
+import org.apache.felix.dm.lambda.callbacks.CbServiceComponentRef;
import org.apache.felix.dm.lambda.callbacks.CbServiceDict;
import org.apache.felix.dm.lambda.callbacks.CbServiceMap;
+import org.apache.felix.dm.lambda.callbacks.CbServiceRef;
import org.apache.felix.dm.lambda.callbacks.CbServiceService;
-import org.apache.felix.dm.lambda.callbacks.CbTypeComponent;
-import org.apache.felix.dm.lambda.callbacks.CbTypeComponentRef;
-import org.apache.felix.dm.lambda.callbacks.CbTypeComponentRefService;
-import org.apache.felix.dm.lambda.callbacks.CbTypeComponentRefServiceRefService;
-import org.apache.felix.dm.lambda.callbacks.CbTypeComponentService;
-import org.apache.felix.dm.lambda.callbacks.CbTypeComponentServiceService;
-import org.apache.felix.dm.lambda.callbacks.CbTypeRef;
-import org.apache.felix.dm.lambda.callbacks.CbTypeRefService;
-import org.apache.felix.dm.lambda.callbacks.CbTypeRefServiceRefService;
-import org.apache.felix.dm.lambda.callbacks.CbTypeService;
-import org.apache.felix.dm.lambda.callbacks.CbTypeServiceDict;
-import org.apache.felix.dm.lambda.callbacks.CbTypeServiceMap;
-import org.apache.felix.dm.lambda.callbacks.CbTypeServiceService;
+import org.apache.felix.dm.lambda.callbacks.CbServiceServiceComponent;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbRefServiceRefService;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbRefServiceRefServiceComponent;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbService;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceComponent;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceComponentRef;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceDict;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceMap;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceRef;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceService;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceServiceComponent;
/**
* Builds a service dependency callback (required by default).
*
+ * TODO: fix javadoc for method reference (do the same as in ConfigurationDependencyBuilder: use double quotes ...
+ *
* 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:
+ * The builder supports reflection based callbacks (same as with the original DM API), as well as java8 method reference based callbacks.
+ *
+ * <p> <b> List of signatures supported using reflection based callbacks (same as original DM API): </b>
*
* <pre> {@code
* method(S service)
@@ -48,26 +46,29 @@ import org.apache.felix.dm.lambda.callba
* swapMethod(Component component, S oldService, S newService)
* swapMethod(Component component, ServiceReference<S> oldRef, S old, ServiceReference<S> newRef, S newService)
* }</pre>
- *
- * The following families of callbacks are supported:
*
- * <ul>
- * <li> "cb(String ... callback)": stands for "callback" and specifies a list of callbacks from the component instances. When using one arg, it stands for the "add" callback.
- * When using two args, it stands for "add/remove" callbacks. When using three args, it stands for "add/change/remove" callbacks. When using four args, it stands for "add/change/remove/swap" callbacks.
- * <li> "cbi(Object callbackInstance, String ... callbacks)": stands for "callback instance" and specifies some callbacks on a given object instance.
- * <li> "cb(lambda) ": stands for "callback" and specifies a method reference of a callback from a given component class.
- * <li> "cbi(lambda)": stands for "callback instance" and specifies a method reference from a given object instance.
- * <li> "sw(lambda)": stands for "swap callback" and specifies a method reference of a swap callback from a given component class.
- * <li> "swi(lambda)": stands for "swap callback instance" and specifies a method reference of a swap callback from a given object instance.
- * </ul>
+ * <b> List of signatures supported using java 8 method references: </b>
*
+ * <pre> {@code
+ * method(S service)
+ * method(S service, ServiceReference<S> serviceRef),
+ * method(S service, Map<String, Object> serviceProperties)
+ * method(S service, Dictionary<String, Object> serviceProperties)
+ * method(S service, Component serviceComponent)
+ * method(S service, Component serviceComponent, ServiceReference<S> serviceRef)
+ * swapMethod(S oldService, S newService)
+ * swapMethod(S oldService, S newService, Component component))
+ * swapMethod(ServiceReference<S> oldRef, S old, ServiceReference<S> newRef, S newService)
+ * swapMethod(ServiceReference<S> oldRef, S old, ServiceReference<S> newRef, S newService, Component component)
+ * }</pre>
+ *
* <p> Here is an example of a Component that defines a dependency of a LogService which is injected in the "bindLogService" method using a ServiceCallbacksBuilder:
- * The withSrv(...)" declaration defines a method reference on the "ComponentImpl::bindLogService" method (using a lambda):
+ * The withSvc(...)" declaration defines a method reference on the "ComponentImpl::bindLogService" method (using a lambda):
*
* <pre> {@code
* public class Activator extends DependencyManagerActivator {
- * public void activate() throws Exception {
- * component(comp -> comp.impl(ComponentImpl.class).withSrv(LogService.class, log -> log.cb(ComponentImpl::bindLogService)));
+ * public void init(BundleContext ctx, DependencyManager dm) throws Exception {
+ * component(comp -> comp.impl(ComponentImpl.class).withSvc(LogService.class, log -> log.add(ComponentImpl::bindLogService)));
* }
* }}</pre>
*
@@ -75,9 +76,9 @@ import org.apache.felix.dm.lambda.callba
*
* <pre> {@code
* public class Activator extends DependencyManagerActivator {
- * public void activate() throws Exception {
+ * public void init(BundleContext ctx, DependencyManager dm) throws Exception {
* ComponentImpl impl = new ComponentImpl();
- * component(comp -> comp.impl(impl).withSrv(LogService.class, log -> log.cbi(impl::bindLogService)));
+ * component(comp -> comp.impl(impl).withSvc(LogService.class, log -> log.add(impl::bindLogService)));
* }
* }}</pre>
*
@@ -85,8 +86,8 @@ import org.apache.felix.dm.lambda.callba
*
* <pre> {@code
* public class Activator extends DependencyManagerActivator {
- * public void activate() throws Exception {
- * component(comp -> comp.impl(ComponentImpl::class).withSrv(LogService.class, log -> log.cb("bindLogService")));
+ * public void init(BundleContext ctx, DependencyManager dm) throws Exception {
+ * component(comp -> comp.impl(ComponentImpl::class).withSvc(LogService.class, log -> log.add("bindLogService")));
* }
* }}</pre>
*
@@ -94,9 +95,9 @@ import org.apache.felix.dm.lambda.callba
*
* <pre> {@code
* public class Activator extends DependencyManagerActivator {
- * public void activate() throws Exception {
+ * public void init(BundleContext ctx, DependencyManager dm) throws Exception {
* ComponentImpl impl = new ComponentImpl();
- * component(comp -> comp.impl(impl).withSrv(LogService.class, log -> log.cbi(impl, "bindLogService")));
+ * component(comp -> comp.impl(impl).withSvc(LogService.class, log -> log.callbackInstance(impl).add("bindLogService")));
* }
* }}</pre>
*
@@ -106,12 +107,18 @@ import org.apache.felix.dm.lambda.callba
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public interface ServiceCallbacksBuilder<S, B extends ServiceCallbacksBuilder<S, B>> {
+
/**
- * Sets <code>callback</code> methods to invoke on the component instance(s). When a service matches the service
- * filter, then the service is injected using the specified callback methods. When you specify one callback, it stands for the "add" callback.
- * When you specify two callbacks, the first one corresponds to the "add" callback, and the second one to the "remove" callback. When you specify three
- * callbacks, the first one stands for the "add" callback, the second one for the "change" callback, and the third one for the "remove" callback.
- * When you specify four callbacks, it stands for "add"/"change"/"remove"/swap callbacks.
+ * Sets the callback instance used for reflection based callbacks.
+ * @param callbackInstance the object on which reflection based callbacks are invoked on.
+ * @return this builder
+ */
+ B callbackInstance(Object callbackInstance);
+
+ /**
+ * Sets <code>callback</code> methods to invoke when a service is added. When a service matches the service
+ * filter, then the service is injected using the specified callback method. The callback is invoked on the component instances, or on the callback
+ * instance, is specified using the {@link #callbackInstance(Object)} method.
*
* The following method signature are supported:
* <pre>{@code
@@ -124,676 +131,496 @@ public interface ServiceCallbacksBuilder
* method(Component serviceComponent, ServiceReference<S> serviceRef)
* method(Component serviceComponent, S service)
* method(Component serviceComponent, ServiceReference<S> serviceRef, S service)
- * swapMethod(S oldService, S newService)
- * swapMethod(ServiceReference<S> oldRef, S old, ServiceReference<S> newRef, S newService)
- * swapMethod(Component component, S oldService, S newService)
- * swapMethod(Component component, ServiceReference<S> oldRef, S old, ServiceReference<S> newRef, S newService)
* }</pre>
*
- * @param callbacks a list of callbacks (1 param: "add", 2 params: "add"/remove", 3 params: "add"/"change"/"remove", 4 params: "add"/"change"/"remove"/"swap" callbacks).
+ * @param callback the add callback
* @return this builder
+ * @see #callbackInstance(Object)
*/
- B cb(String ... callbacks);
+ B add(String callback);
/**
- * Sets <code>callback instance</code> methods to invoke on a given Object instance. When a service matches the service
- * filter, then the service is injected using the specified callback methods. When you specify one callback, it stands for the "add" callback.
- * When you specify two callbacks, the first one corresponds to the "add" callback, and the second one to the "remove" callback. When you specify three
- * callbacks, the first one stands for the "add" callback, the second one for the "change" callback, and the third one for the "remove" callback.
+ * Sets <code>callback</code> methods to invoke when a service is changed. When a changed service matches the service
+ * filter, then the service is injected using the specified callback method. The callback is invoked on the component instances, or on the callback
+ * instance, is specified using the {@link #callbackInstance(Object)} method.
+ *
+ * The following method signature are supported:
+ * <pre>{@code
+ * method(S service)
+ * method(S service, Map<String, Object> serviceProperties)
+ * method(S service, Dictionary<String, Object> serviceProperties)
+ * method(ServiceReference<S> serviceRef, S service),
+ * method(ServiceReference<S> serviceRef)
+ * method(Component serviceComponent)
+ * method(Component serviceComponent, ServiceReference<S> serviceRef)
+ * method(Component serviceComponent, S service)
+ * method(Component serviceComponent, ServiceReference<S> serviceRef, S service)
+ * }</pre>
*
- * @param callbackInstance the object on which the callback is invoked.
- * @param callbacks a list of callbacks (1 param : "add", 2 params : "add"/remove", 3 params : "add"/"change"/"remove", 4 params : "add"/"change"/"remove"/"swap" callbacks).
- * @see #cb(String...)
+ * @param callback the change callback
* @return this builder
+ * @see #callbackInstance(Object)
*/
- B cbi(Object callbackInstance, String ... callbacks);
+ B change(String callback);
/**
- * Sets a <code>callback</code> invoked when a service is added.
- * The method reference must point to a Component implementation class method. Callback argument(s): the service.
+ * Sets <code>callback</code> methods to invoke when a service is removed. When a removed service matches the service
+ * filter, then the specified callback in invoked with the removed service. The callback is invoked on the component instances, or on the callback
+ * instance, is specified using the {@link #callbackInstance(Object)} method.
*
- * @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
+ * The following method signature are supported:
+ * <pre>{@code
+ * method(S service)
+ * method(S service, Map<String, Object> serviceProperties)
+ * method(S service, Dictionary<String, Object> serviceProperties)
+ * method(ServiceReference<S> serviceRef, S service),
+ * method(ServiceReference<S> serviceRef)
+ * method(Component serviceComponent)
+ * method(Component serviceComponent, ServiceReference<S> serviceRef)
+ * method(Component serviceComponent, S service)
+ * method(Component serviceComponent, ServiceReference<S> serviceRef, S service)
+ * }</pre>
+ *
+ * @param callback the remove callback
* @return this builder
+ * @see #callbackInstance(Object)
*/
- <T> B cb(CbTypeService<T, S> add);
+ B remove(String callback);
/**
- * Sets a <code>callback</code> invoked when a service is added or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the service.
+ * Sets <code>callback</code> methods to invoke when a service is swapped. The callback is invoked on the component instances, or on the callback
+ * instance, is specified using the {@link #callbackInstance(Object)} method.
*
- * @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
- * @param remove the method reference invoked when a service is removed.
- * @return this builder
- */
- <T> B cb(CbTypeService<T, S> add, CbTypeService<T, S> remove);
-
- /**
- * Sets a <code>callback</code> invoked when a service is added, changed, or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the service.
+ * The following method signature are supported:
+ * <pre>{@code
+ * swapMethod(S oldService, S newService)
+ * swapMethod(ServiceReference<S> oldRef, S old, ServiceReference<S> newRef, S newService)
+ * swapMethod(Component component, S oldService, S newService)
+ * swapMethod(Component component, ServiceReference<S> oldRef, S old, ServiceReference<S> newRef, S newService)
+ * }</pre>
*
- * @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
- * @param change the method reference invoked when a service is changed.
- * @param remove the method reference invoked when a service is removed.
+ * @param callback the remove callback
* @return this builder
+ * @see #callbackInstance(Object)
*/
- <T> B cb(CbTypeService<T, S> add, CbTypeService<T, S> change, CbTypeService<T, S> remove);
+ B swap(String callback);
/**
- * Sets a <code>callback</code> invoked when a service is added.
- * The method reference must point to a Component implementation class method. Callback argument(s): the service, and a properties map.
+ * Sets a <code>component instance callback(Service)</code> callback. The callback is invoked when a service is added.
+ * The method reference must point to a Component implementation class method.
*
* @param <T> the type of the component instance class on which the callback is invoked.
* @param add the method reference invoked when a service is added.
* @return this builder
*/
- <T> B cb(CbTypeServiceMap<T, S> add);
+ <T> B add(CbService<T, S> add);
/**
- * Sets a <code>callback</code> invoked when a service is added or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the service, and a properties map.
+ * Sets a <code>component instance callback(Service)</code> callback. The callback is invoked when a service is changed.
+ * The method reference must point to a Component implementation class method.
*
* @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
- * @param remove the method reference invoked when a service is removed.
+ * @param change the method reference invoked when a service is changed.
* @return this builder
*/
- <T> B cb(CbTypeServiceMap<T, S> add, CbTypeServiceMap<T, S> remove);
+ <T> B change(CbService<T, S> change);
/**
- * Sets a <code>callback</code> invoked when a service is added, changed, or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the service, and a properties map.
+ * Sets a <code>component instance callback(Service)</code> callback. The callback is invoked when a service is removed.
+ * The method reference must point to a Component implementation class method.
*
* @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
- * @param change the method reference invoked when a service is changed.
* @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- <T> B cb(CbTypeServiceMap<T, S> add, CbTypeServiceMap<T, S> change, CbTypeServiceMap<T, S> remove);
+ <T> B remove(CbService<T, S> remove);
/**
- * Sets a <code>callback</code> invoked when a service is added.
- * The method reference must point to a Component implementation class method. Callback argument(s): the service, and a properties dictionary.
+ * Sets a {@code component instance callback(Service, Map<String, Object>)} callback. The callback is invoked when a service is added.
+ * The method reference must point to a Component implementation class method.
*
* @param <T> the type of the component instance class on which the callback is invoked.
* @param add the method reference invoked when a service is added.
* @return this builder
*/
- <T> B cb(CbTypeServiceDict<T, S> add);
+ <T> B add(CbServiceMap<T, S> add);
/**
- * Sets a <code>callback</code> invoked when a service is added or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the service, and a properties dictionary.
+ * Sets a {@code component instance callback(Service, Map<String, Object>)} callback. The callback is invoked when a service is changed.
+ * The method reference must point to a Component implementation class method.
*
* @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
- * @param remove the method reference invoked when a service is removed.
- * @return this builder
- */
- <T> B cb(CbTypeServiceDict<T, S> add, CbTypeServiceDict<T, S> remove);
-
- /**
- * Sets a <code>callback</code> invoked when a service is added, changed, or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the service, and a properties dictionary.
- *
- * @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
* @param change the method reference invoked when a service is changed.
- * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- <T> B cb(CbTypeServiceDict<T, S> add, CbTypeServiceDict<T, S> change, CbTypeServiceDict<T, S> remove);
-
+ <T> B change(CbServiceMap<T, S> change);
+
/**
- * Sets a <code>callback</code> invoked when a service is added.
- * The method reference must point to a Component implementation class method. Callback argument(s): the service reference, and the service.
+ * Sets a {@code component instance callback(Service, Map<String, Object></code>)} callback. The callback is invoked when a service is removed.
+ * The method reference must point to a Component implementation class method.
*
* @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
+ * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- <T> B cb(CbTypeRefService<T, S> add);
+ <T> B remove(CbServiceMap<T, S> remove);
/**
- * Sets a <code>callback</code> invoked when a service is added or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the service reference, and the service.
+ * Sets a {@code component instance callback(Service, Dictionary<String, Object>)} callback. The callback is invoked when a service is added.
+ * The method reference must point to a Component implementation class method.
*
* @param <T> the type of the component instance class on which the callback is invoked.
* @param add the method reference invoked when a service is added.
- * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- <T> B cb(CbTypeRefService<T, S> add, CbTypeRefService<T, S> remove);
-
+ <T> B add(CbServiceDict<T, S> add);
+
/**
- * Sets a <code>callback</code> invoked when a service is added, changed, or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the service reference, and the service.
+ * Sets a {@code component instance callback(Service, Dictionary<String, Object>)} callback. The callback is invoked when a service is changed.
+ * The method reference must point to a Component implementation class method.
*
* @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
* @param change the method reference invoked when a service is changed.
- * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- <T> B cb(CbTypeRefService<T, S> add, CbTypeRefService<T, S> change, CbTypeRefService<T, S> remove);
+ <T> B change(CbServiceDict<T, S> change);
/**
- * Sets a <code>callback</code> invoked when a service is added.
- * The method reference must point to a Component implementation class method. Callback argument(s): the service reference.
+ * Sets a {@code component instance callback(Service, Dictionary<String, Object>)} callback. The callback is invoked when a service is removed.
+ * The method reference must point to a Component implementation class method.
*
* @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
- * @return this builder
- */
- <T> B cb(CbTypeRef<T, S> add);
-
- /**
- * Sets a <code>callback</code> invoked when a service is added or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the service reference.
- *
- * @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
- * @param remove the method reference invoked when a service is removed.
- * @return this builder
- */
- <T> B cb(CbTypeRef<T, S> add, CbTypeRef<T, S> remove);
-
- /**
- * Sets a <code>callback</code> invoked when a service is added, changed, or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the service reference.
- *
- * @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
- * @param change the method reference invoked when a service is changed.
* @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- <T> B cb(CbTypeRef<T, S> add, CbTypeRef<T, S> change, CbTypeRef<T, S> remove);
-
- /**
- * Sets a <code>callback</code> invoked when a service is added.
- * The method reference must point to a Component implementation class method. Callback argument(s): the Component.
- *
- * @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
- * @return this builder
- */
- <T> B cb(CbTypeComponent<T> add);
-
+ <T> B remove(CbServiceDict<T, S> remove);
+
/**
- * Sets a <code>callback</code> invoked when a service is added or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the Component.
- *
+ * Sets a <code>component instance callback(Service, ServiceReference)</code> callback. The callback is invoked when a service is added.
+ * The method reference must point to a Component implementation class method.
* @param <T> the type of the component instance class on which the callback is invoked.
* @param add the method reference invoked when a service is added.
- * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- <T> B cb(CbTypeComponent<T> add, CbTypeComponent<T> remove);
+ <T> B add(CbServiceRef<T, S> add);
/**
- * Sets a <code>callback</code> invoked when a service is added, changed, or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the Component.
+ * Sets a <code>component instance callback(Service, ServiceReference)</code> callback. The callback is invoked when a service is changed.
+ * The method reference must point to a Component implementation class method.
*
* @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
* @param change the method reference invoked when a service is changed.
- * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- <T> B cb(CbTypeComponent<T> add, CbTypeComponent<T> change, CbTypeComponent<T> remove);
+ <T> B change(CbServiceRef<T, S> change);
/**
- * Sets a <code>callback</code> invoked when a service is added.
- * The method reference must point to a Component implementation class method. Callback argument(s): the Component, and the service reference.
+ * Sets a <code>component instance callback(Service, ServiceReference)</code> callback. The callback is invoked when a service is removed.
+ * The method reference must point to a Component implementation class method.
*
* @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
- * @return this builder
- */
- <T> B cb(CbTypeComponentRef<T, S> add);
-
- /**
- * Sets a <code>callback</code> invoked when a service is added or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the Component, and the service reference.
- *
- * @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
* @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- <T> B cb(CbTypeComponentRef<T, S> add, CbTypeComponentRef<T, S> remove);
-
+ <T> B remove(CbServiceRef<T, S> remove);
+
/**
- * Sets a <code>callback</code> invoked when a service is added, changed, or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the Component, and the service reference.
+ * Sets a <code>component instance callback(Service, Component)</code> callback. The callback is invoked when a service is added.
+ * The method reference must point to a Component implementation class method.
*
* @param <T> the type of the component instance class on which the callback is invoked.
* @param add the method reference invoked when a service is added.
- * @param change the method reference invoked when a service is changed.
- * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- <T> B cb(CbTypeComponentRef<T, S> add, CbTypeComponentRef<T, S> change, CbTypeComponentRef<T, S> remove);
+ <T> B add(CbServiceComponent<T, S> add);
/**
- * Sets a <code>callback</code> invoked when a service is added.
- * The method reference must point to a Component implementation class method. Callback argument(s): the Component, and the service.
+ * Sets a <code>component instance callback(Service, Component)</code> callback. The callback is invoked when a service is changed.
+ * The method reference must point to a Component implementation class method.
*
* @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
+ * @param change the method reference invoked when a service is changed.
* @return this builder
*/
- <T> B cb(CbTypeComponentService<T, S> add);
+ <T> B change(CbServiceComponent<T, S> change);
/**
- * Sets a <code>callback</code> invoked when a service is added or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the Component, and the service.
+ * Sets a <code>component instance callback(Service, Component)</code> callback. The callback is invoked when a service is removed.
+ * The method reference must point to a Component implementation class method.
*
* @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
* @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- <T> B cb(CbTypeComponentService<T, S> add, CbTypeComponentService<T, S> remove);
+ <T> B remove(CbServiceComponent<T, S> remove);
/**
- * Sets a <code>callback</code> invoked when a service is added, changed, or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the Component, and the service.
+ * Sets a <code>component instance callback(Service, Component, ServiceReference ref)</code> callback. The callback is invoked when a service is added.
+ * The method reference must point to a Component implementation class method.
*
* @param <T> the type of the component instance class on which the callback is invoked.
* @param add the method reference invoked when a service is added.
- * @param change the method reference invoked when a service is changed.
- * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- <T> B cb(CbTypeComponentService<T, S> add, CbTypeComponentService<T, S> change, CbTypeComponentService<T, S> remove);
-
- /**
- * Sets a <code>callback</code> invoked when a service is added.
- * The method reference must point to a Component implementation class method. Callback argument(s): the Component, the service Reference and the service.
- *
- * @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
- * @return this builder
- */
- <T> B cb(CbTypeComponentRefService<T, S> add);
+ <T> B add(CbServiceComponentRef<T, S> add);
/**
- * Sets a <code>callback</code> invoked when a service is added or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the Component, the service Reference and the service.
- *
- * @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
- * @param remove the method reference invoked when a service is removed.
- * @return this builder
- */
- <T> B cb(CbTypeComponentRefService<T, S> add, CbTypeComponentRefService<T, S> remove);
-
- /**
- * Sets a <code>callback</code> invoked when a service is added, changed, or removed.
- * The method reference must point to a Component implementation class method. Callback argument(s): the Component, the service Reference and the service.
+ * Sets a <code>component instance callback(Service, Component, ServiceReference)</code> callback. The callback is invoked when a service is changed.
+ * The method reference must point to a Component implementation class method.
*
* @param <T> the type of the component instance class on which the callback is invoked.
- * @param add the method reference invoked when a service is added.
* @param change the method reference invoked when a service is changed.
- * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- <T> B cb(CbTypeComponentRefService<T, S> add, CbTypeComponentRefService<T, S> change, CbTypeComponentRefService<T, S> remove);
+ <T> B change(CbServiceComponentRef<T, S> change);
/**
- * Sets a <code>swap callback(Service, Service)</code> invoked when a service is swapped.
- * The method reference must point to a Component implementation class method. Callback argument(s): the old service and the new replacing service.
+ * Sets a <code>component instance callback(Service, Component, ServiceReference)</code> callback. The callback is invoked when a service is removed.
+ * The method reference must point to a Component implementation class method.
*
* @param <T> the type of the component instance class on which the callback is invoked.
- * @param swap the method reference invoked when the service is swapped.
- * @return this builder
- */
- <T> B sw(CbTypeServiceService<T, S> swap);
-
- /**
- * Sets a <code>swap callback(Component, Service, Service)</code> invoked when a service is swapped.
- * The method reference must point to a Component implementation class method. Callback argument(s): the component, the old service and the new replacing service.
- *
- * @param <T> the type of the component instance class on which the callback is invoked.
- * @param swap the method reference invoked when the service is swapped.
+ * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- <T> B sw(CbTypeComponentServiceService<T, S> swap);
+ <T> B remove(CbServiceComponentRef<T, S> remove);
/**
- * Sets a <code>swap callback(ServiceReference, Service, ServiceReference, Service)</code> invoked when a service is swapped.
- * The method reference must point to a Component implementation class method. Callback argument(s): the old service reference, the old service, the new service reference, and
- * the new service.
+ * Sets an <code>object instance callback(Service)</code> callback. The callback is invoked when a service is added.
+ * The method reference must point to a method from an Object instance.
*
- * @param <T> the type of the component instance class on which the callback is invoked.
- * @param swap the method reference invoked when the service is swapped.
+ * @param add the method reference invoked when a service is added.
* @return this builder
*/
- <T> B sw(CbTypeRefServiceRefService<T, S> swap);
+ B add(InstanceCbService<S> add);
/**
- * Sets a swap <code>callback</code> invoked when a service is swapped.
- * The method reference must point to a Component implementation class method. Callback argument(s): the component, the old service reference, the old service, the new service reference, and
- * the new service.
+ * Sets an <code>object instance callback(Service)</code> callback. The callback is invoked when a service is changed.
+ * The method reference must point to method from an Object instance.
*
- * @param <T> the type of the component instance class on which the callback is invoked.
- * @param swap the method reference invoked when the service is swapped.
+ * @param change the method reference invoked when a service is changed.
* @return this builder
*/
- <T> B sw(CbTypeComponentRefServiceRefService<T, S> swap);
+ B change(InstanceCbService<S> change);
/**
- * Sets a <code>callback instance</code> invoked when a service is added.
- * The method reference must point to a method from an Object instance. Callback argument(s): a service.
+ * Sets an <code>object instance callback(Service)</code> callback. The callback is invoked when a service is removed.
+ * The method reference must point to method from an Object instance.
*
- * @param add the method reference invoked when a service is added.
+ * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- B cbi(CbService<S> add);
-
+ B remove(InstanceCbService<S> remove);
+
/**
- * Sets a <code>callback instance</code> invoked when a service is added/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a service.
+ * Sets an {@code object instance callback(Service, Map<String, Object>)} callback. The callback is invoked when a service is added.
+ * The method reference must point to a method from an Object instance.
*
* @param add the method reference invoked when a service is added.
- * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- B cbi(CbService<S> add, CbService<S> remove);
+ B add(InstanceCbServiceMap<S> add);
/**
- * Sets a <code>callback instance</code> invoked when a service is added/changed/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a service.
+ * Sets an {@code object instance callback(Service, Map<String, Object>)} callback. The callback is invoked when a service is changed.
+ * The method reference must point to method from an Object instance.
*
- * @param add the method reference invoked when a service is added.
* @param change the method reference invoked when a service is changed.
- * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- B cbi(CbService<S> add, CbService<S> change, CbService<S> remove);
+ B change(InstanceCbServiceMap<S> change);
/**
- * Sets a <code>callback instance</code> invoked when a service is added.
- * The method reference must point to a method from an Object instance. Callback argument(s): a service and a properties Map.
+ * Sets an {@code object instance callback(Service, Map<String, Object>)} callback. The callback is invoked when a service is removed.
+ * The method reference must point to method from an Object instance.
*
- * @param add the method reference invoked when a service is added.
+ * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- B cbi(CbServiceMap<S> add);
+ B remove(InstanceCbServiceMap<S> remove);
/**
- * Sets a <code>callback instance</code> invoked when a service is added/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a service and a properties Map.
+ * Sets an {@code object instance callback(Service svc, Dictionary<String, Object>} callback. The callback is invoked when a service is added.
+ * The method reference must point to a method from an Object instance.
*
* @param add the method reference invoked when a service is added.
- * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- B cbi(CbServiceMap<S> add, CbServiceMap<S> remove);
-
+ B add(InstanceCbServiceDict<S> add);
+
/**
- * Sets a <code>callback instance</code> invoked when a service is added/changed/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a service and a properties Map.
+ * Sets an {@code object instance callback(Service, Dictionary<String, Object>)} callback. The callback is invoked when a service is changed.
+ * The method reference must point to method from an Object instance.
*
- * @param add the method reference invoked when a service is added.
* @param change the method reference invoked when a service is changed.
- * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- B cbi(CbServiceMap<S> add, CbServiceMap<S> change, CbServiceMap<S> remove);
+ B change(InstanceCbServiceDict<S> change);
/**
- * Sets a <code>callback instance</code> invoked when a service is added.
- * The method reference must point to a method from an Object instance. Callback argument(s): a service and a properties Dictionary.
+ * Sets an {@code object instance callback(Service, Dictionary<String, Object>)} callback. The callback is invoked when a service is removed.
+ * The method reference must point to method from an Object instance.
*
- * @param add the method reference invoked when a service is added.
+ * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- B cbi(CbServiceDict<S> add);
-
+ B remove(InstanceCbServiceDict<S> remove);
+
/**
- * Sets a <code>callback instance</code> invoked when a service is added/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a service and a properties Dictionary.
+ * Sets an <code>object instance callback(Service, ServiceReference)</code> callback. The callback is invoked when a service is added.
+ * The method reference must point to a method from an Object instance.
*
* @param add the method reference invoked when a service is added.
- * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- B cbi(CbServiceDict<S> add, CbServiceDict<S> remove);
-
+ B add(InstanceCbServiceRef<S> add);
+
/**
- * Sets a <code>callback instance</code> invoked when a service is added/changed/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a service and a properties Dictionary.
+ * Sets an <code>object instance callback(Service, ServiceReference)</code> callback. The callback is invoked when a service is changed.
+ * The method reference must point to method from an Object instance.
*
- * @param add the method reference invoked when a service is added.
* @param change the method reference invoked when a service is changed.
- * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- B cbi(CbServiceDict<S> add, CbServiceDict<S> change, CbServiceDict<S> remove);
+ B change(InstanceCbServiceRef<S> change);
/**
- * Sets a <code>callback instance</code> invoked when a service is added.
- * The method reference must point to a method from an Object instance. Callback argument(s): a service reference and a service.
+ * Sets an <code>object instance callback(Service, ServiceReference)</code> callback. The callback is invoked when a service is removed.
+ * The method reference must point to method from an Object instance.
*
- * @param add the method reference invoked when a service is added.
+ * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- B cbi(CbRefService<S> add);
+ B remove(InstanceCbServiceRef<S> remove);
/**
- * Sets a <code>callback instance</code> invoked when a service is added/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a service reference and a service.
+ * Sets an <code>object instance callback(Service, Component)</code> callback invoked. The callback is when a service is added.
+ * The method reference must point to a method from an Object instance.
*
* @param add the method reference invoked when a service is added.
- * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- B cbi(CbRefService<S> add, CbRefService<S> remove);
+ B add(InstanceCbServiceComponent<S> add);
/**
- * Sets a <code>callback instance</code> invoked when a service is added/changed/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a service reference and a service.
+ * Sets an <code>object instance callback(Service, Component)</code> callback invoked. The callback is when a service is changed.
+ * The method reference must point to method from an Object instance.
*
- * @param add the method reference invoked when a service is added.
* @param change the method reference invoked when a service is changed.
- * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- B cbi(CbRefService<S> add, CbRefService<S> change, CbRefService<S> remove);
+ B change(InstanceCbServiceComponent<S> change);
/**
- * Sets a <code>callback instance</code> invoked when a service is added.
- * The method reference must point to a method from an Object instance. Callback argument(s): a service reference.
+ * Sets an <code>object instance callback(Service, Component)</code> callback. The callback is invoked when a service is removed.
+ * The method reference must point to method from an Object instance.
*
- * @param add the method reference invoked when a service is added.
- * @return this builder
- */
- B cbi(CbRef<S> add);
-
- /**
- * Sets a <code>callback instance</code> invoked when a service is added/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a service reference.
- *
- * @param add the method reference invoked when a service is added.
* @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- B cbi(CbRef<S> add, CbRef<S> remove);
-
+ B remove(InstanceCbServiceComponent<S> remove);
+
/**
- * Sets a <code>callback instance</code> invoked when a service is added/changed/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a service reference.
+ * Sets an <code>object instance callback(Service, Component, ServiceReference)</code> callback. The callback is invoked when a service is added.
+ * The method reference must point to a method from an Object instance.
*
* @param add the method reference invoked when a service is added.
- * @param change the method reference invoked when a service is changed.
- * @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- B cbi(CbRef<S> add, CbRef<S> change, CbRef<S> remove);
-
+ B add(InstanceCbServiceComponentRef<S> add);
+
/**
- * Sets a <code>callback instance</code> invoked when a service is added.
- * The method reference must point to a method from an Object instance. Callback argument(s): a Component.
+ * Sets an <code>object instance callback(Service, Component, ServiceReference)</code> callback. The callback is invoked when a service is changed.
+ * The method reference must point to method from an Object instance.
*
- * @param add the method reference invoked when a service is added.
+ * @param change the method reference invoked when a service is changed.
* @return this builder
*/
- B cbi(CbComponent add);
+ B change(InstanceCbServiceComponentRef<S> change);
/**
- * Sets a <code>callback instance</code> invoked when a service is added/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a Component.
- *
- * @param add the method reference invoked when a service is added.
- * @param remove the method reference invoked when a service is removed.
- * @return this builder
- */
- B cbi(CbComponent add, CbComponent remove);
-
- /**
- * Sets a <code>callback instance</code> invoked when a service is added/changed/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a Component.
+ * Sets an <code>object instance callback(Service, Component, ServiceReference)</code> callback. The callback is invoked when a service is removed.
+ * The method reference must point to method from an Object instance.
*
- * @param add the method reference invoked when a service is added.
- * @param change the method reference invoked when a service is changed.
* @param remove the method reference invoked when a service is removed.
* @return this builder
*/
- B cbi(CbComponent add, CbComponent change, CbComponent remove);
-
- /**
- * Sets a <code>callback instance</code> invoked when a service is added.
- * The method reference must point to a method from an Object instance. Callback argument(s): a Component and a service reference.
- *
- * @param add the method reference invoked when a service is added.
- * @return this builder
- */
- B cbi(CbComponentRef<S> add);
+ B remove(InstanceCbServiceComponentRef<S> remove);
/**
- * Sets a <code>callback instance</code> invoked when a service is added/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a Component and a service reference.
+ * Sets a swap <code>component instance callback(Service, Service)</code> method reference. The callback is invoked when a service is swapped.
+ * The method reference must point to a Component implementation class method.
*
- * @param add the method reference invoked when a service is added.
- * @param remove the method reference invoked when a service is removed.
+ * @param <T> the type of the component instance class on which the callback is invoked.
+ * @param swap the method reference invoked when the service is swapped.
* @return this builder
*/
- B cbi(CbComponentRef<S> add, CbComponentRef<S> remove);
+ <T> B swap(CbServiceService<T, S> swap);
/**
- * Sets a <code>callback instance</code> invoked when a service is added/changed/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a Component and a service reference.
+ * Sets a wap <code>component instance callback(Service, Service, Component)</code> method reference. The callback is invoked when a service is swapped.
+ * The method reference must point to a Component implementation class method.
*
- * @param add the method reference invoked when a service is added.
- * @param change the method reference invoked when a service is changed.
- * @param remove the method reference invoked when a service is removed.
- * @return this builder
- */
- B cbi(CbComponentRef<S> add, CbComponentRef<S> change, CbComponentRef<S> remove);
-
- /**
- * Sets a <code>callback instance</code> invoked when a service is added.
- * The method reference must point to a method from an Object instance. Callback argument(s): a Component and a service.
- *
- * @param add the method reference invoked when a service is added.
+ * @param <T> the type of the component instance class on which the callback is invoked.
+ * @param swap the method reference invoked when the service is swapped.
* @return this builder
*/
- B cbi(CbComponentService<S> add);
-
+ <T> B swap(CbServiceServiceComponent<T, S> swap);
+
/**
- * Sets a <code>callback instance</code> invoked when a service is added/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a Component and a service.
+ * Sets a swap <code>component instance callback(ServiceReference, Service, ServiceReference, Service)</code> method reference. The callback is invoked when a service is swapped.
+ * The method reference must point to a Component implementation class method.
+ * the new service.
*
- * @param add the method reference invoked when a service is added.
- * @param remove the method reference invoked when a service is removed.
+ * @param <T> the type of the component instance class on which the callback is invoked.
+ * @param swap the method reference invoked when the service is swapped.
* @return this builder
*/
- B cbi(CbComponentService<S> add, CbComponentService<S> remove);
-
+ <T> B swap(CbRefServiceRefService<T, S> swap);
+
/**
- * Sets a <code>callback instance</code> invoked when a service is added/changed/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a Component and a service.
+ * Sets a swap <code>component instance callback(ServiceReference, Service, ServiceReference, Service, Component</code> method reference. The callback is invoked when a service is swapped.
+ * The method reference must point to a Component implementation class method.
+ * the new service.
*
- * @param add the method reference invoked when a service is added.
- * @param change the method reference invoked when a service is changed.
- * @param remove the method reference invoked when a service is removed.
+ * @param <T> the type of the component instance class on which the callback is invoked.
+ * @param swap the method reference invoked when the service is swapped.
* @return this builder
*/
- B cbi(CbComponentService<S> add, CbComponentService<S> change, CbComponentService<S> remove);
+ <T> B swap(CbRefServiceRefServiceComponent<T, S> swap);
/**
- * Sets a <code>callback instance</code> invoked when a service is added.
- * The method reference must point to a method from an Object instance. Callback argument(s): a Component, a service reference, and a service.
- *
- * @param add the method reference invoked when a service is added.
- * @return this builder
- */
- B cbi(CbComponentRefService<S> add);
-
- /**
- * Sets a <code>callback instance</code> invoked when a service is added/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a Component, a service reference, and a service.
- *
- * @param add the method reference invoked when a service is added.
- * @param remove the method reference invoked when a service is removed.
- * @return this builder
- */
- B cbi(CbComponentRefService<S> add, CbComponentRefService<S> remove);
-
- /**
- * Sets a <code>callback instance</code> invoked when a service is added/changed/removed.
- * The method reference must point to method from an Object instance. Callback argument(s): a Component, a service reference, and a service.
- *
- * @param add the method reference invoked when a service is added.
- * @param change the method reference invoked when a service is changed.
- * @param remove the method reference invoked when a service is removed.
- * @return this builder
- */
- B cbi(CbComponentRefService<S> add, CbComponentRefService<S> change, CbComponentRefService<S> remove);
-
- /**
- * Sets a swap <code>callback instance</code> invoked when a service is swapped.
- * The method reference must point to a method from an Object instance. Callback argument(s): the old service, and the new service.
- * the new service.
+ * Sets a swap <code>instance callback(Service, Service)</code> method reference. The callback is invoked when a service is swapped.
+ * The method reference must point to a method from an Object instance.
*
* @param swap the method reference invoked when the service is swapped.
* @return this builder
*/
- B swi(CbServiceService<S> swap);
+ B swap(InstanceCbServiceService<S> swap);
/**
- * Sets a swap <code>callback instance</code> invoked when a service is swapped.
- * The method reference must point to a method from an Object instance. Callback argument(s): the component, the old service, and the new service.
- * the new service.
+ * Sets a swap <code>instance callback(Service, Service, Component)</code> method reference. The callback is invoked when a service is swapped.
+ * The method reference must point to a method from an Object instance.
*
* @param swap the method reference invoked when the service is swapped.
* @return this builder
*/
- B swi(CbComponentServiceService<S> swap);
+ B swap(InstanceCbServiceServiceComponent<S> swap);
/**
- * Sets a swap <code>callback instance</code> invoked when a service is swapped.
- * The method reference must point to a method from an Object instance. Callback argument(s): the old service reference, the old service, the
- * new service reference, and the new service.
+ * Sets a swap <code>instance callback(ServiceReference, Service, ServiceReference, Service)</code> method reference. The callback is invoked when a service is swapped.
+ * The method reference must point to a method from an Object instance.
*
* @param swap the method reference invoked when the service is swapped.
* @return this builder
*/
- B swi(CbRefServiceRefService<S> swap);
+ B swap(InstanceCbRefServiceRefService<S> swap);
/**
- * Sets a swap <code>callback instance</code> invoked when a service is swapped.
- * The method reference must point to a method from an Object instance. Callback argument(s): the component, old service reference, the old service, the
- * new service reference, and the new service.
+ * Sets a swap <code>instance callback(ServiceReference, Service, ServiceReference, Service, Component)</code> method reference. The callback is invoked when a service is swapped.
+ * The method reference must point to a method from an Object instance.
*
* @param swap the method reference invoked when the service is swapped.
* @return this builder
*/
- B swi(CbComponentRefServiceRefService<S> swap);
+ B swap(InstanceCbRefServiceRefServiceComponent<S> swap);
}
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceDependencyBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceDependencyBuilder.java?rev=1731147&r1=1731146&r2=1731147&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceDependencyBuilder.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceDependencyBuilder.java Thu Feb 18 21:07:16 2016
@@ -8,8 +8,10 @@ import org.apache.felix.dm.ServiceDepend
import org.osgi.framework.ServiceReference;
/**
- * Builds a Dependency Manager Service Dependency. Dependency callbacks can be defined using methods reflection like
- * in original DM API, or using Java8 method references.
+ * Builds a Dependency Manager Service Dependency.
+ * The Dependency is required by default, but you can
+ * control the default mode (required or optional) using the "org.apache.felix.dependencymanager.lambda.dependencymode"
+ * system property which can be set to either "required" or "optional" ("required" by default).
*
* Unlike with original DM, dependencies are required by default.
*
@@ -31,19 +33,22 @@ public interface ServiceDependencyBuilde
ServiceDependencyBuilder<S> ref(ServiceReference<S> ref);
/**
- * Configures this dependency as optional. By default, a dependency is required.
+ * Configures this dependency as optional. By default, the dependency is required, but you can specify the default mode
+ * using the "org.apache.felix.dependencymanager.lambda.dependencymode" system property.
* @return this builder
*/
ServiceDependencyBuilder<S> optional();
/**
- * Configures this dependency as required. By default, a dependency is required.
+ * Configures this dependency as required. By default, the dependency is required, but you can specify the default mode
+ * using the "org.apache.felix.dependencymanager.lambda.dependencymode" system property.
* @return this builder
*/
ServiceDependencyBuilder<S> required();
/**
- * Configures whether this dependency is required or not.
+ * Configures whether this dependency is required or not. By default, the dependency is required, but you can specify the default mode
+ * using the "org.apache.felix.dependencymanager.lambda.dependencymode" system property.
*
* @param required true if the dependency is required, false if not. Unlike with the original DM API, service dependencies are required by default.
* @return this builder
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/Cb.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/Cb.java?rev=1731147&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/Cb.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/Cb.java Thu Feb 18 21:07:16 2016
@@ -0,0 +1,25 @@
+package org.apache.felix.dm.lambda.callbacks;
+
+import java.util.Objects;
+
+/**
+ * Represents a java8 method reference to a zero-argument method from a given component implementation class.
+ * <p> The type of the class on which the callback is invoked on is represented by the T generic parameter.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@FunctionalInterface
+public interface Cb<T> extends SerializableLambda {
+ /**
+ * Invokes the callback method on the given component implementation instance.
+ * @param t the component implementation instance the callback is invoked on.
+ */
+ void accept(T t);
+
+ default Cb<T> andThen(Cb<? super T> after) {
+ Objects.requireNonNull(after);
+ return (T t) -> {
+ accept(t);
+ after.accept(t);
+ };
+ }
+}
\ No newline at end of file
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbBundle.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbBundle.java?rev=1731147&r1=1731146&r2=1731147&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbBundle.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbBundle.java Thu Feb 18 21:07:16 2016
@@ -5,23 +5,25 @@ import java.util.Objects;
import org.osgi.framework.Bundle;
/**
- * Represents a callback(Bundle) on an Object instance.
+ * Represents a callback(Bundle) that is invoked on a Component implementation class.
+ * The type of the class on which the callback is invoked on is represented by the T generic parameter.
*
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
@FunctionalInterface
-public interface CbBundle extends SerializableLambda {
+public interface CbBundle<T> extends SerializableLambda {
/**
- * Handles the given argument.
+ * Handles the given arguments.
+ * @param instance the Component implementation instance on which the callback is invoked on.
* @param bundle the callback parameter
*/
- void accept(Bundle bundle);
+ void accept(T instance, Bundle bundle);
- default CbBundle andThen(CbBundle after) {
+ default CbBundle<T> andThen(CbBundle<? super T> after) {
Objects.requireNonNull(after);
- return (Bundle bundle) -> {
- accept(bundle);
- after.accept(bundle);
+ return (T instance, Bundle bundle) -> {
+ accept(instance, bundle);
+ after.accept(instance, bundle);
};
}
}
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbBundleComponent.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbBundleComponent.java?rev=1731147&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbBundleComponent.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbBundleComponent.java Thu Feb 18 21:07:16 2016
@@ -0,0 +1,31 @@
+package org.apache.felix.dm.lambda.callbacks;
+
+import java.util.Objects;
+
+import org.apache.felix.dm.Component;
+import org.osgi.framework.Bundle;
+
+/**
+ * Represents a callback(Bundle, Component) that is invoked on a Component implementation class.
+ * The type of the class on which the callback is invoked on is represented by the T generic parameter.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@FunctionalInterface
+public interface CbBundleComponent<T> extends SerializableLambda {
+ /**
+ * Handles the given arguments.
+ * @param instance the Component implementation instance on which the callback is invoked on.
+ * @param bundle the first callback parameter
+ * @param component the second callback parameter
+ */
+ void accept(T instance, Bundle bundle, Component component);
+
+ default CbBundleComponent<T> andThen(CbBundleComponent<? super T> after) {
+ Objects.requireNonNull(after);
+ return (T instance, Bundle bundle, Component component) -> {
+ accept(instance, bundle, component);
+ after.accept(instance, bundle, component);
+ };
+ }
+}
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbComponent.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbComponent.java?rev=1731147&r1=1731146&r2=1731147&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbComponent.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbComponent.java Thu Feb 18 21:07:16 2016
@@ -5,23 +5,26 @@ import java.util.Objects;
import org.apache.felix.dm.Component;
/**
- * Represents a callback(Component) on an Object instance.
+ * Represents a callback(Component) that is invoked on a Component implementation class.
+ * The type of the component implementation class on which the callback is invoked on is represented by the T generic parameter.
+ * The component callback accepts in argument a Component parameter.
*
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
@FunctionalInterface
-public interface CbComponent {
+public interface CbComponent<T> extends SerializableLambda {
/**
- * Handles the given argument.
+ * Handles the given arguments.
+ * @param instance the Component implementation class instance on which the callback is invoked on.
* @param component the callback parameter
*/
- void accept(Component component);
+ void accept(T instance, Component bundle);
- default CbComponent andThen(CbComponent after) {
+ default CbComponent<T> andThen(CbComponent<? super T> after) {
Objects.requireNonNull(after);
- return (Component component) -> {
- accept(component);
- after.accept(component);
+ return (T instance, Component component) -> {
+ accept(instance, component);
+ after.accept(instance, component);
};
}
}
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbConfiguration.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbConfiguration.java?rev=1731147&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbConfiguration.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbConfiguration.java Thu Feb 18 21:07:16 2016
@@ -0,0 +1,83 @@
+package org.apache.felix.dm.lambda.callbacks;
+
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Represents a callback(Configuration) that is invoked on a Component implementation class.
+ * The callback which accepts a type-safe configuration class for wrapping properties behind a dynamic proxy interface.
+ *
+ * <p> The T generic parameter represents the type of the class on which the callback is invoked on.
+ * <p> The U generic parameter represents the type of the configuration class passed to the callback argument.
+ *
+ * <p> Using such callback provides a way for creating type-safe configurations from a actual {@link Map} or {@link Dictionary} that is
+ * normally injected by Dependency Manager.
+ * The callback accepts in argument an interface that you have to provide, and DM will inject a proxy that converts
+ * method calls from your configuration-type to lookups in the actual map or dictionary. The results of these lookups are then
+ * converted to the expected return type of the invoked configuration method.<br>
+ * As proxies are injected, no implementations of the desired configuration-type are necessary!
+ * </p>
+ * <p>
+ * The lookups performed are based on the name of the method called on the configuration type. The method names are
+ * "mangled" to the following form: <tt>[lower case letter] [any valid character]*</tt>. Method names starting with
+ * <tt>get</tt> or <tt>is</tt> (JavaBean convention) are stripped from these prefixes. For example: given a dictionary
+ * with the key <tt>"foo"</tt> can be accessed from a configuration-type using the following method names:
+ * <tt>foo()</tt>, <tt>getFoo()</tt> and <tt>isFoo()</tt>.
+ * </p>
+ * <p>
+ * The return values supported are: primitive types (or their object wrappers), strings, enums, arrays of
+ * primitives/strings, {@link Collection} types, {@link Map} types, {@link Class}es and interfaces. When an interface is
+ * returned, it is treated equally to a configuration type, that is, it is returned as a proxy.
+ * </p>
+ * <p>
+ * Arrays can be represented either as comma-separated values, optionally enclosed in square brackets. For example:
+ * <tt>[ a, b, c ]</tt> and <tt>a, b,c</tt> are both considered an array of length 3 with the values "a", "b" and "c".
+ * Alternatively, you can append the array index to the key in the dictionary to obtain the same: a dictionary with
+ * "arr.0" => "a", "arr.1" => "b", "arr.2" => "c" would result in the same array as the earlier examples.
+ * </p>
+ * <p>
+ * Maps can be represented as single string values similarly as arrays, each value consisting of both the key and value
+ * separated by a dot. Optionally, the value can be enclosed in curly brackets. Similar to array, you can use the same
+ * dot notation using the keys. For example, a dictionary with
+ *
+ * <pre>{@code "map" => "{key1.value1, key2.value2}"}</pre>
+ *
+ * and a dictionary with <p>
+ *
+ * <pre>{@code "map.key1" => "value1", "map2.key2" => "value2"}</pre>
+ *
+ * result in the same map being returned.
+ * Instead of a map, you could also define an interface with the methods <tt>getKey1()</tt> and <tt>getKey2</tt> and use
+ * that interface as return type instead of a {@link Map}.
+ *
+ * <p>
+ * In case a lookup does not yield a value from the underlying map or dictionary, the following rules are applied:
+ * <ol>
+ * <li>primitive types yield their default value, as defined by the Java Specification;
+ * <li>string, {@link Class}es and enum values yield <code>null</code>;
+ * <li>for arrays, collections and maps, an empty array/collection/map is returned;
+ * <li>for other interface types that are treated as configuration type a null-object is returned.
+ * </ol>
+ * </p>
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@FunctionalInterface
+public interface CbConfiguration<T, U> extends SerializableLambda {
+ /**
+ * Handles the given arguments
+ * @param instance the Component implementation instance on which the callback is invoked on.
+ * @param configuration the configuration proxy
+ */
+ void accept(T instance, U configuration);
+
+ default CbConfiguration<T, U> andThen(CbConfiguration<T, U> after) {
+ Objects.requireNonNull(after);
+ return (T instance, U configuration) -> {
+ accept(instance, configuration);
+ after.accept(instance, configuration);
+ };
+ }
+}
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbConfigurationComponent.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbConfigurationComponent.java?rev=1731147&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbConfigurationComponent.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbConfigurationComponent.java Thu Feb 18 21:07:16 2016
@@ -0,0 +1,33 @@
+package org.apache.felix.dm.lambda.callbacks;
+
+import java.util.Objects;
+
+import org.apache.felix.dm.Component;
+
+/**
+ * Represents a callback(Configuration, Component) which accepts a configuration type for wrapping properties
+ * behind a dynamic proxy interface. For more informations about configuration type, please refer to {@link CbConfiguration}.
+ *
+ * <p> The T generic parameter represents the type of the class on which the callback is invoked on.
+ * <p> The U generic parameter represents the type of the configuration class passed to the callback argument.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@FunctionalInterface
+public interface CbConfigurationComponent<T, U> extends SerializableLambda {
+ /**
+ * Handles the given arguments
+ * @param instance the Component implementation instance on which the callback is invoked on.
+ * @param configuration the configuration proxy
+ * @param component the callback Component
+ */
+ void accept(T instance, U configuration, Component component);
+
+ default CbConfigurationComponent<T, U> andThen(CbConfigurationComponent<T, U> after) {
+ Objects.requireNonNull(after);
+ return (T instance, U configuration, Component component) -> {
+ accept(instance, configuration, component);
+ after.accept(instance, configuration, component);
+ };
+ }
+}
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbDictionary.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbDictionary.java?rev=1731147&r1=1731146&r2=1731147&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbDictionary.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbDictionary.java Thu Feb 18 21:07:16 2016
@@ -4,23 +4,25 @@ import java.util.Dictionary;
import java.util.Objects;
/**
- * Represents a callback(Dictionary) on an Object instance.
+ * Represents a callback(Dictionary) that is invoked on a Component implementation class.
+ * The type of the class on which the callback is invoked on is represented by the T generic parameter.
*
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
@FunctionalInterface
-public interface CbDictionary {
+public interface CbDictionary<T> extends SerializableLambda {
/**
- * Handles the given argument.
- * @param conf the properties
+ * Handles the given arguments.
+ * @param instance the Component implementation instance on which the callback is invoked on.
+ * @param conf the callback argument
*/
- void accept(Dictionary<String, Object> conf);
+ void accept(T instance, Dictionary<String, Object> conf);
- default CbDictionary andThen(CbDictionary after) {
+ default CbDictionary<T> andThen(CbDictionary<? super T> after) {
Objects.requireNonNull(after);
- return (Dictionary<String, Object> conf) -> {
- accept(conf);
- after.accept(conf);
+ return (T instance, Dictionary<String, Object> conf) -> {
+ accept(instance, conf);
+ after.accept(instance, conf);
};
}
}
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbDictionaryComponent.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbDictionaryComponent.java?rev=1731147&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbDictionaryComponent.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbDictionaryComponent.java Thu Feb 18 21:07:16 2016
@@ -0,0 +1,31 @@
+package org.apache.felix.dm.lambda.callbacks;
+
+import java.util.Dictionary;
+import java.util.Objects;
+
+import org.apache.felix.dm.Component;
+
+/**
+ * Represents a callback(Dictionary, Component) that is invoked on a Component implementation class.
+ * The type of the class on which the callback is invoked on is represented by the T generic parameter.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@FunctionalInterface
+public interface CbDictionaryComponent<T> extends SerializableLambda {
+ /**
+ * Handles the given arguments.
+ * @param instance the Component implementation instance on which the callback is invoked on.
+ * @param conf the first callback parameter
+ * @param component the second callback parameter
+ */
+ void accept(T instance, Dictionary<String, Object> conf, Component component);
+
+ default CbDictionaryComponent<T> andThen(CbDictionaryComponent<? super T> after) {
+ Objects.requireNonNull(after);
+ return (T instance, Dictionary<String, Object> conf, Component component) -> {
+ accept(instance, conf, component);
+ after.accept(instance, conf, component);
+ };
+ }
+}
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbFuture.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbFuture.java?rev=1731147&r1=1731146&r2=1731147&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbFuture.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbFuture.java Thu Feb 18 21:07:16 2016
@@ -3,23 +3,26 @@ package org.apache.felix.dm.lambda.callb
import java.util.Objects;
/**
- * Represents a callback that accepts a the result of a CompletableFuture. The callback is invoked on an Object instance.
+ * Represents a callback that accepts the result of a CompletableFuture operation. The callback is invoked on a Component implementation class.
+ * The type of the class on which the callback is invoked on is represented by the T generic parameter.
+ * The type of the result of the CompletableFuture is represented by the F generic parameter.
*
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
@FunctionalInterface
-public interface CbFuture<F> {
+public interface CbFuture<T, F> extends SerializableLambda {
/**
- * Handles the result of a CompletableFuture operation.
+ * Handles the given arguments.
+ * @param instance the Component implementation instance on which the callback is invoked on.
* @param future the result of a CompletableFuture operation.
*/
- void accept(F future);
+ void accept(T instance, F future);
- default CbFuture<F> andThen(CbFuture<? super F> after) {
+ default CbFuture<T, F> andThen(CbFuture<? super T, F> after) {
Objects.requireNonNull(after);
- return (F f) -> {
- accept(f);
- after.accept(f);
+ return (T instance, F future) -> {
+ accept(instance, future);
+ after.accept(instance, future);
};
}
}
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbRefServiceRefService.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbRefServiceRefService.java?rev=1731147&r1=1731146&r2=1731147&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbRefServiceRefService.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbRefServiceRefService.java Thu Feb 18 21:07:16 2016
@@ -5,26 +5,28 @@ import java.util.Objects;
import org.osgi.framework.ServiceReference;
/**
- * Represents a callback(ServiceReference, Service, ServiceReference, Service) on an Object instance.
+ * Represents a callback(ServiceReference, Service, ServiceReference, Service) that is invoked on a Component implementation class.
+ * The type of the class on which the callback is invoked on is represented by the T generic parameter.
*
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
@FunctionalInterface
-public interface CbRefServiceRefService<S> {
+public interface CbRefServiceRefService<T, S> extends SerializableLambda {
/**
- * Handles the given arguments
- * @param oldRef a service reference
- * @param old a service
- * @param replaceRef a service reference
- * @param replace a service
+ * Handles the given arguments.
+ * @param instance the Component implementation instance on which the callback is invoked on.
+ * @param oldRef first callback param
+ * @param old second callback param
+ * @param replaceRef third callback param
+ * @param replace fourth callback param
*/
- void accept(ServiceReference<S> oldRef, S old, ServiceReference<S> replaceRef, S replace);
+ void accept(T instance, ServiceReference<S> oldRef, S old, ServiceReference<S> replaceRef, S replace);
- default CbRefServiceRefService<S> andThen(CbRefServiceRefService<S> after) {
+ default CbRefServiceRefService<T, S> andThen(CbRefServiceRefService<? super T, S> after) {
Objects.requireNonNull(after);
- return (ServiceReference<S> oldRef, S old, ServiceReference<S> replaceRef, S replace) -> {
- accept(oldRef, old, replaceRef, replace);
- after.accept(oldRef, old, replaceRef, replace);
+ return (T instance, ServiceReference<S> oldRef, S old, ServiceReference<S> replaceRef, S replace) -> {
+ accept(instance, oldRef, old, replaceRef, replace);
+ after.accept(instance, oldRef, old, replaceRef, replace);
};
}
}