@Retention(CLASS)
@Target({METHOD,FIELD})
public @interface Reference
When the annotation is applied to a method, the method is the bind method of the reference. When the annotation is applied to a field, the field will contain the bound service(s) of the reference.
This annotation is not processed at runtime by Service Component Runtime. 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.
| Modifier and Type | Optional Element | Description |
|---|---|---|
java.lang.String |
bind |
The name of the bind method for this reference.
|
ReferenceCardinality |
cardinality |
The cardinality of this reference.
|
java.lang.String |
field |
The name of the field for this reference.
|
FieldOption |
fieldOption |
The field option for this reference.
|
java.lang.String |
name |
The name of this reference.
|
ReferencePolicy |
policy |
The policy for this reference.
|
ReferencePolicyOption |
policyOption |
The policy option for this reference.
|
ReferenceScope |
scope |
The reference scope for this reference.
|
java.lang.Class<?> |
service |
The type of the service for this reference.
|
java.lang.String |
target |
The target property for this reference.
|
java.lang.String |
unbind |
The name of the unbind method for this reference.
|
java.lang.String |
updated |
The name of the updated method for this reference.
|
java.lang.String name
The name of this reference must be specified when using this annotation
in the Component.reference() element since there is no annotated
member from which the name can be determined.
If not specified, the name of this reference is based upon how this
annotation is used:
bind,
set or add, that prefix is removed to create the name of
the reference. Otherwise, the name of the reference is the method name.java.lang.Class<?> service
The type of the service for this reference must be specified when using
this annotation in the Component.reference() element since there
is no annotated member from which the type of the service can be
determined.
If not specified, the type of the service for this reference is based upon how this annotation is used:
0..n, or
1..n, the type of the field
must be one of java.util.Collection, java.util.List, or a
subtype of java.util.Collection so the type of the service is the
generic type of the collection. Otherwise, the type of the service is the
type of the field.ReferenceCardinality cardinality
If not specified, the cardinality of this reference is based upon how this annotation is used:
1..1.java.util.Collection,
java.util.List, or a subtype of java.util.Collection, the
cardinality is 0..n. Otherwise the
cardinality is 1..1.Component.reference() element - The cardinality is
1..1.ReferencePolicy policy
If not specified, the policy of this reference is based upon how this annotation is used:
STATIC.volatile, the policy is
ReferencePolicy.DYNAMIC. Otherwise the policy is
STATIC.Component.reference() element - The policy is
STATIC.java.lang.String target
If not specified, no target property is set.
ReferencePolicyOption policyOption
If not specified, the RELUCTANT
reference policy option is used.
ReferenceScope scope
If not specified, the bundle reference
scope is used.
java.lang.String bind
If specified and this reference annotates a method, the specified name must match the name of the annotated method.
If not specified, the name of the bind method is based upon how this annotation is used:
Component.reference() element - There is no bind method name.
If there is a bind method name, the component must contain a method with that name.
java.lang.String updated
If not specified, the name of the updated method is based upon how this annotation is used:
bind, set or add, that prefix is replaced
with updated to create the name candidate for the updated method.
Otherwise, updated is prefixed to the name of the annotated
method to create the name candidate for the updated method. If the
component type contains a method with the candidate name, the candidate
name is used as the name of the updated method. To declare no updated
method when the component type contains a method with the candidate name,
the value "-" must be used.Component.reference() element - There is no updated method
name.If there is an updated method name, the component must contain a method with that name.
java.lang.String unbind
If not specified, the name of the unbind method is based upon how this annotation is used:
bind, set or add, that prefix is replaced
with unbind, unset or remove, respectively, to
create the name candidate for the unbind method. Otherwise, un is
prefixed to the name of the annotated method to create the name candidate
for the unbind method. If the component type contains a method with the
candidate name, the candidate name is used as the name of the unbind
method. To declare no unbind method when the component type contains a
method with the candidate name, the value "-" must be used.Component.reference() element - There is no unbind method
name.If there is an unbind method name, the component must contain a method with that name.
java.lang.String field
If specified and this reference annotates a field, the specified name must match the name of the annotated field.
If not specified, the name of the field is based upon how this annotation is used:
Component.reference() element - There is no field name.If there is a field name, the component must contain a field with that name.
FieldOption fieldOption
If not specified, the field option is based upon how this annotation is used:
ReferencePolicy.DYNAMIC, the cardinality is
0..n or
1..n, and the field is declared
final, the field option is FieldOption.UPDATE. Otherwise,
the field option is FieldOption.REPLACEComponent.reference() element - There is no field option.