OSGi™ Enterprise
Release 5

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.

In the generated Component Description for a component, the references must be ordered in ascending lexicographical order (using String.compareTo ) of the reference names.

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.
 ReferencePolicyOption policyOption
          The policy option 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 is associated with the annotated bind method.
 java.lang.String updated
          The name of the updated method which is associated 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 bind, 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 is associated 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 bind, set or add, that is replaced with unbind, unset or remove, respectively, to derive the unbind method name. Otherwise, un is prefixed to the annotated method name to derive the unbind method name. The unbind method is only set if the component type contains a method with the derived name.

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

policyOption

public abstract ReferencePolicyOption policyOption
The policy option for the reference.

If not specified, the RELUCTANT reference policy option is used.

Since:
1.2
See Also:
"The policy-option attribute of the reference element of a Component Description."
Default:
org.osgi.service.component.annotations.ReferencePolicyOption.RELUCTANT

updated

public abstract java.lang.String updated
The name of the updated method which is associated with the annotated bind method.

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

If not specified, the name of the updated method is derived from the name of the annotated bind method. If the annotated method name begins with bind, set or add, that is replaced with updated to derive the updated method name. Otherwise, updated is prefixed to the annotated method name to derive the updated method name. The updated method is only set if the component type contains a method with the derived name.

Since:
1.2
See Also:
"The updated attribute of the reference element of a Component Description."
Default:
""

OSGi™ Enterprise
Release 5

Copyright © OSGi Alliance (2000, 2012). All Rights Reserved. Licensed under the OSGi Specification License, Version 2.0