public interface AspectComponent extends Component<AspectComponent>
public class Activator extends DependencyActivatorBase { &Override public void init(BundleContext context, DependencyManager dm) throws Exception { Component aspectComponent = createAspectComponent() .setAspect(Database.class, null, 10) .setImplementation(DatabaseCache.class); dm.add(aspectComponent); } } interface Database { String get(String key); } class DatabaseCache implements Database { volatile Database originalDatabase; // injected String get(String key) { String value = cache.get(key); if (value == null) { value = this.originalDatabase.get(key); store(key, value); } return value; } ... }
For "add", "change", "remove" callbacks, the following method signatures are supported:
(Component comp, ServiceReference ref, Service service)
(Component comp, ServiceReference ref, Object service)
(Component comp, ServiceReference ref)
(Component comp, Service service)
(Component comp, Object service)
(Component comp)
(Component comp, Map properties, Service service)
(ServiceReference ref, Service service)
(ServiceReference ref, Object service)
(ServiceReference ref)
(Service service)
(Service service, Map propeerties)
(Map properties, Service, service)
(Service service, Dictionary properties)
(Dictionary properties, Service service)
(Object service)
For "swap" callbacks, the following method signatures are supported:
(Service old, Service replace)
(Object old, Object replace)
(ServiceReference old, Service old, ServiceReference replace, Service replace)
(ServiceReference old, Object old, ServiceReference replace, Object replace)
(Component comp, Service old, Service replace)
(Component comp, Object old, Object replace)
(Component comp, ServiceReference old, Service old, ServiceReference replace, Service replace)
(Component comp, ServiceReference old, Object old, ServiceReference replace, Object replace)
(ServiceReference old, ServiceReference replace)
(Component comp, ServiceReference old, ServiceReference replace)
Component.ServiceScope
Modifier and Type | Method and Description |
---|---|
AspectComponent |
setAspect(java.lang.Class<?> service,
java.lang.String filter,
int ranking)
Sets the service interface to apply the aspect to (required parameter)
|
AspectComponent |
setAspectCallbackInstance(java.lang.Object callbackInstance)
Sets the instance to invoke the callbacks on (optional parameter).
|
AspectComponent |
setAspectCallbacks(java.lang.String add,
java.lang.String change,
java.lang.String remove,
java.lang.String swap)
Sets name of the callbacks method to invoke on add,change,remove, or swap callbacks (optional parameter).
|
AspectComponent |
setAspectField(java.lang.String autoConfig)
Sets the aspect implementation field name where to inject original service (optional parameter).
|
add, add, getServiceRegistration, remove, remove, setAutoConfig, setAutoConfig, setCallbacks, setCallbacks, setComposition, setComposition, setDebug, setFactory, setFactory, setImplementation, setInterface, setInterface, setInterface, setInterface, setScope, setServiceProperties
getComponentDeclaration, getDependencyManager, getInstance, getInstances, getServiceProperties
AspectComponent setAspect(java.lang.Class<?> service, java.lang.String filter, int ranking)
service
- the service interface to apply the aspect tofilter
- the filter condition to use with the service aspect interface (null if no filter)ranking
- the level used to organize the aspect chain orderingAspectComponent setAspectField(java.lang.String autoConfig)
autoConfig
- the aspect implementation field name where to inject original serviceAspectComponent setAspectCallbacks(java.lang.String add, java.lang.String change, java.lang.String remove, java.lang.String swap)
add
- name of the callback method to invoke on addchange
- name of the callback method to invoke on changeremove
- name of the callback method to invoke on removeswap
- name of the callback method to invoke on swapAspectComponent setAspectCallbackInstance(java.lang.Object callbackInstance)
callbackInstance
- the instance to invoke the callbacks on