from the official OSGI R5 Compendium Spec page 281ff.
Reference power
Link power can be specified as one of four options:
- 0..1 - Optional and unary.
- 1..1 - Mandatory and unary (default).
- 0..n - Optional and plural.
- 1..n - Mandatory and plural.
Strategy
- Event strategy . SCR calls a method on a component instance when a service becomes connected, when a service becomes unconnected, or when its properties are updated. These methods are to bind, update and untie the methods specified in the link. An event strategy is useful if a component needs to be notified of changes to related services for a dynamic link.
- Search strategy . A component instance can use one of the locateService methods for the ComponentContext to find the associated service. These methods take the name of the link as a parameter. If the link has a dynamic policy, it is important not to save the returned service object (s), but to look for it every time it is necessary.
Politics
static policy is the simplest policy and is the default policy. A component instance never sees any dynamics. Component configurations are deactivated before any related service is referenced, a static policy will become unavailable. If the target service is available to replace a related service that has become unavailable, the component configuration must be activated and linked to the replacement service.
Dynamic policy a bit more complicated, since the component implementation must correctly handle changes in the set of related services that can occur in any thread. With dynamic policies, SCR can change the set of related services without deactivating the component configuration. If a component uses an event strategy to access services, then an instance of the component will be notified of changes in the set of related services by binding calls and undo methods.
Policy option
- reluctantly . Minimize re-binding and re-inclusion.
- greedy . Maximize your use of the best service by disabling static links or redesigning dynamic links.
other specific felix resources
[Felic SCR Annotations] ( http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/scr-annotations.html )
source share