org.apache.felix.scr.annotations
Annotation Type Reference


@Target(value={TYPE,FIELD})
@Retention(value=SOURCE)
@Documented
public @interface Reference

The Reference annotation defines references to other services made available to the component by the Service Component Runtime.

This annotation may be declared for a Java Class or any Java Field to which it might apply. Depending on where the annotation is declared, the parameters may have different default values.

This annotation is used to declare <reference> elements of the component declaration. See section 112.4.7, Reference Element, in the OSGi Service Platform Service Compendium Specification for more information.


Optional Element Summary
 String bind
          The name of the method to be called when the service is to be bound to the component.
 ReferenceCardinality cardinality
          The cardinality of the service reference.
 String name
          The local name of the reference.
 ReferencePolicy policy
          The dynamicity policy of the reference.
 Class<?> referenceInterface
          The name of the service interface.
 ReferenceStrategy strategy
          The reference strategy for the reference.
 String target
          A service target filter to select specific services to be made available.
 String unbind
          The name of the method to be called when the service is to be unbound from the component.
 String updated
          The name of the method to be called when the bound service updates its service registration properties.
 

name

public abstract String name
The local name of the reference. If the annotation is declared on class level, this parameter is required. If the tag is declared for a field, the default value for the name parameter is the name of the field.

Default:
""

referenceInterface

public abstract Class<?> referenceInterface
The name of the service interface. This name is used by the Service Component Runtime to access the service on behalf of the component. If the annotation is declared on class level, this parameter is required. If the annotation is declared for a field, the default value for the interface parameter is the type of the field.

Default:
org.apache.felix.scr.annotations.AutoDetect.class

cardinality

public abstract ReferenceCardinality cardinality
The cardinality of the service reference. This must be one of 0..1, 1..1, 0..n, and 1..n.

Default:
org.apache.felix.scr.annotations.ReferenceCardinality.MANDATORY_UNARY

policy

public abstract ReferencePolicy policy
The dynamicity policy of the reference. If dynamic the service will be made available to the component as it comes and goes. If static the component will be deactivated and re-activated if the service comes and/or goes away.

Default:
org.apache.felix.scr.annotations.ReferencePolicy.STATIC

target

public abstract String target
A service target filter to select specific services to be made available. In order to be able to overwrite the value of this value by a configuration property, this parameter must be declared. If the parameter is not declared, the respective declaration attribute will not be generated.

Default:
""

bind

public abstract String bind
The name of the method to be called when the service is to be bound to the component. The default value is the name created by appending the reference name to the string bind. The method must be declared public or protected and take single argument which is declared with the service interface type.

Default:
""

unbind

public abstract String unbind
The name of the method to be called when the service is to be unbound from the component. The default value is the name created by appending the reference name to the string unbind. The method must be declared public or protected and take single argument which is declared with the service interface type.

Default:
""

updated

public abstract String updated
The name of the method to be called when the bound service updates its service registration properties. By default this is not set.

Default:
""

strategy

public abstract ReferenceStrategy strategy
The reference strategy for the reference. This can either be ReferenceStrategy.EVENT in which case the bind and unbind methods are used or it can be ReferenceStrategy.LOOKUP in which case the reference is looked up through the component context.

Default:
org.apache.felix.scr.annotations.ReferenceStrategy.EVENT


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.