org.osgi.service.component.annotations
Annotation Type Reference


@Retention(value=CLASS)
@Target(value=METHOD)
public @interface Reference

Identify the annotated method as a bind method of a Service Component.

The annotated method is a bind method of the Component.

This annotation is not processed at runtime by a Service Component Runtime implementation. It must be processed by tools and used to add a Component Description to the bundle.

See Also:
"The reference element of a Component Description."

Optional Element Summary
 ReferenceCardinality cardinality
          The cardinality of the reference.
 java.lang.String name
          The name of this reference.
 ReferencePolicy policy
          The policy for the reference.
 java.lang.Class<?> service
          The type of the service to bind to this reference.
 java.lang.String target
          The target filter for the reference.
 java.lang.String unbind
          The name of the unbind method which pairs with the annotated bind method.
 

name

public abstract java.lang.String name
The name of this reference.

If not specified, the name of this reference is based upon the name of the method being annotated. If the method name begins with set or add, that is removed.

See Also:
"The name attribute of the reference element of a Component Description."
Default:
""

service

public abstract java.lang.Class<?> service
The type of the service to bind to this reference.

If not specified, the type of the service to bind is based upon the type of the first argument of the method being annotated.

See Also:
"The interface attribute of the reference element of a Component Description."
Default:
java.lang.Object.class

cardinality

public abstract ReferenceCardinality cardinality
The cardinality of the reference.

If not specified, the reference has a 1..1 cardinality.

See Also:
"The cardinality attribute of the reference element of a Component Description."
Default:
org.osgi.service.component.annotations.ReferenceCardinality.MANDATORY

policy

public abstract ReferencePolicy policy
The policy for the reference.

If not specified, the STATIC reference policy is used.

See Also:
"The policy attribute of the reference element of a Component Description."
Default:
org.osgi.service.component.annotations.ReferencePolicy.STATIC

target

public abstract java.lang.String target
The target filter for the reference.

See Also:
"The target attribute of the reference element of a Component Description."
Default:
""

unbind

public abstract java.lang.String unbind
The name of the unbind method which pairs with the annotated bind method.

To declare no unbind method, the value "-" must be used.

If not specified, the name of the unbind method is derived from the name of the annotated bind method. If the annotated method name begins with set, that is replaced with unset to derive the unbind method name. If the annotated method name begins with add, that is replaced with remove to derive the unbind method name. Otherwise, un is prefixed to the annotated method name to derive the unbind method name.

See Also:
"The unbind attribute of the reference element of a Component Description."
Default:
""