T
- the adaptee servicepublic interface ServiceAdapterBuilder<T> extends ComponentBuilder<ServiceAdapterBuilder<T>>, ServiceCallbacksBuilder<T,ServiceAdapterBuilder<T>>
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");
}
}
Modifier and Type | Method and Description |
---|---|
ServiceAdapterBuilder<T> |
autoConfig()
Injects this adapted service in all fields matching the adapted service type.
|
ServiceAdapterBuilder<T> |
autoConfig(boolean autoConfig)
Configures whether or not the adapted service can be injected in all fields matching the adapted service type.
|
ServiceAdapterBuilder<T> |
autoConfig(java.lang.String field)
Injects this adapted service on the field matching the given name
|
ServiceAdapterBuilder<T> |
filter(java.lang.String adapteeFilter)
Specifies the filter used to match a given adapted service.
|
ServiceAdapterBuilder<T> |
propagate(boolean propagate)
Specifies whether or not the adapted service properties must be propagated to the adapter service (true by default).
|
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, withSvc
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
ServiceAdapterBuilder<T> filter(java.lang.String adapteeFilter)
adapteeFilter
- the filter used to match a given adapted serviceServiceAdapterBuilder<T> propagate(boolean propagate)
propagate
- true if the adapted service properties must be propagated to the adapter service (true by default).ServiceAdapterBuilder<T> autoConfig()
ServiceAdapterBuilder<T> autoConfig(boolean autoConfig)
autoConfig
- true if the adapted service can be injected in all fields matching the adapted service typeServiceAdapterBuilder<T> autoConfig(java.lang.String field)
field
- the field name where the adapted service must be injected to.