@Retention(value=CLASS)
@Target(value=TYPE)
public @interface AspectService
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)
Here, the AspectService is registered into the OSGI registry each time an InterceptedService is found from the registry. The AspectService class intercepts the InterceptedService, and decorates its "doWork()" method. This aspect uses a rank with value "10", meaning that it will intercept some other eventual aspects with lower ranks. The Aspect also uses a service property (param=value), and include eventual service properties found from the InterceptedService:
@AspectService(ranking=10)) class AspectService implements InterceptedService { // The service we are intercepting (injected by reflection) volatile InterceptedService intercepted; public void doWork() { intercepted.doWork(); } }
Modifier and Type | Required Element and Description |
---|---|
int |
ranking
Sets the ranking of this aspect.
|
Modifier and Type | Optional Element and Description |
---|---|
java.lang.String |
added
The callback method to be invoked when the original service is available.
|
java.lang.String |
changed
The callback method to be invoked when the original service properties have changed.
|
java.lang.String |
factoryMethod
Sets the static method used to create the AspectService implementation instance.
|
java.lang.String |
field
Sets the field name where to inject the original service.
|
java.lang.String |
filter
Sets the filter condition to use with the service interface this aspect is applying to.
|
Property[] |
properties
Deprecated.
you can apply
Property annotation directly on the component class. |
java.lang.String |
removed
The callback method to invoke when the service is lost.
|
ServiceScope |
scope
The service scope for the service of this Component.
|
java.lang.Class<?> |
service
Sets the service interface to apply the aspect to.
|
java.lang.String |
swap
name of the callback method to invoke on swap.
|
public abstract int ranking
public abstract java.lang.Class<?> service
public abstract java.lang.String filter
public abstract java.lang.String field
public abstract java.lang.String added
public abstract java.lang.String changed
public abstract java.lang.String removed
public abstract java.lang.String swap
public abstract java.lang.String factoryMethod
public abstract ServiceScope scope
If not specified, the singleton
service
scope is used.