Package org.apache.felix.dm.lambda
Interface ServiceAdapterBuilder<T>
- Type Parameters:
T- the adaptee service
- All Superinterfaces:
ComponentBuilder<ServiceAdapterBuilder<T>>,ServiceCallbacksBuilder<T,ServiceAdapterBuilder<T>>
public interface ServiceAdapterBuilder<T>
extends ComponentBuilder<ServiceAdapterBuilder<T>>, ServiceCallbacksBuilder<T,ServiceAdapterBuilder<T>>
Builds a Dependency Manager Service Adapter Component.
The adapter will be applied to any service that matches the specified interface and filter. For each matching service an adapter will be created based on the adapter implementation class. The adapter will be registered with the specified interface and existing properties from the original service plus any extra properties you supply here.
Code example that adapts a "Device" service to an HttpServlet service. The adapter is created using a ServiceAdapterBuilder that is passed to the lambda.
public class Activator extends DependencyManagerActivator {
public void init(BundleContext ctx, DependencyManager dm) throws Exception {
adapter(Device.class, adapt -> adapt.impl(DeviceServlet.class).provides(HttpServlet.class).properties(alias -> "/device");
}
}-
Method Summary
Modifier and TypeMethodDescriptionInjects this adapted service in all fields matching the adapted service type.autoConfig(boolean autoConfig) Configures whether or not the adapted service can be injected in all fields matching the adapted service type.autoConfig(String field) Injects this adapted service on the field matching the given nameSpecifies the filter used to match a given adapted service.propagate(boolean propagate) Specifies whether or not the adapted service properties must be propagated to the adapter service (true by default).Methods inherited from interface org.apache.felix.dm.lambda.ComponentBuilder
autoAdd, autoConfig, autoConfig, build, composition, composition, composition, debug, destroy, destroy, destroy, destroy, factory, factory, factory, factory, factory, impl, init, init, init, init, listener, properties, properties, properties, provides, provides, provides, provides, provides, provides, provides, provides, provides, provides, provides, provides, provides, provides, provides, provides, scope, start, start, start, start, stop, stop, stop, stop, withBundle, withCnf, withCnf, withCnf, withDep, withFuture, withSvc, withSvc, withSvc, withSvc, withSvc, withSvcMethods inherited from interface org.apache.felix.dm.lambda.ServiceCallbacksBuilder
add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, callbackInstance, change, change, change, change, change, change, change, change, change, change, change, change, change, change, change, change, change, change, change, dereference, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, swap, swap, swap, swap, swap, swap, swap, swap, swap, swap, swap, swap, swap, swap, swap
-
Method Details
-
filter
Specifies the filter used to match a given adapted service.- Parameters:
adapteeFilter- the filter used to match a given adapted service- Returns:
- this builder
-
propagate
Specifies whether or not the adapted service properties must be propagated to the adapter service (true by default).- Parameters:
propagate- true if the adapted service properties must be propagated to the adapter service (true by default).- Returns:
- this builder
-
autoConfig
ServiceAdapterBuilder<T> autoConfig()Injects this adapted service in all fields matching the adapted service type.- Returns:
- this builder
-
autoConfig
Configures whether or not the adapted service can be injected in all fields matching the adapted service type.- Parameters:
autoConfig- true if the adapted service can be injected in all fields matching the adapted service type- Returns:
- this builder
-
autoConfig
Injects this adapted service on the field matching the given name- Parameters:
field- the field name where the adapted service must be injected to.- Returns:
- this builder
-