Package org.eclipse.sisu.osgi
Class ServiceBindings
java.lang.Object
org.eclipse.sisu.osgi.ServiceBindings
- All Implemented Interfaces:
BindingPublisher
On-demand publisher of
Binding
s from the OSGi service registry.-
Constructor Summary
ConstructorsConstructorDescriptionServiceBindings
(org.osgi.framework.BundleContext context) Creates new publisher of service bindings, using the given OSGiBundleContext
to track services.
Uses default allow/ignore settings and assigns any published services the lowest possible ranking.ServiceBindings
(org.osgi.framework.BundleContext context, String allow, String ignore, int maxRank) Creates new publisher of service bindings, using the given OSGiBundleContext
to track services.
The globbed patterns control whether tracking requests for particular types are allowed or ignored.
Any published bindings are ranked according to their service ranking (up to the given maximum). -
Method Summary
Modifier and TypeMethodDescription<T> T
Attempts to adapt this publisher to the given type.static String
Configured byorg.eclipse.sisu.osgi.ServiceBindings.allow
system property.static String
Configured byorg.eclipse.sisu.osgi.ServiceBindings.ignore
system property.int
Estimates the maximum rank this publisher may assign to aBinding
.<T> void
subscribe
(BindingSubscriber<T> subscriber) Subscribes the givenBindingSubscriber
to receiveBinding
s.<T> void
unsubscribe
(BindingSubscriber<T> subscriber) Stops the givenBindingSubscriber
from receivingBinding
s.
-
Constructor Details
-
ServiceBindings
public ServiceBindings(org.osgi.framework.BundleContext context, String allow, String ignore, int maxRank) Creates new publisher of service bindings, using the given OSGiBundleContext
to track services.
The globbed patterns control whether tracking requests for particular types are allowed or ignored.
Any published bindings are ranked according to their service ranking (up to the given maximum).- Parameters:
context
- The tracking contextallow
- Globbed pattern of packages/types to allowignore
- Globbed pattern of packages/types to ignoremaxRank
- Maximum binding rank
-
ServiceBindings
public ServiceBindings(org.osgi.framework.BundleContext context) Creates new publisher of service bindings, using the given OSGiBundleContext
to track services.
Uses default allow/ignore settings and assigns any published services the lowest possible ranking.- Parameters:
context
- The tracking context
-
-
Method Details
-
defaultAllow
Configured byorg.eclipse.sisu.osgi.ServiceBindings.allow
system property.- Returns:
- Globbed pattern of types to allow
-
defaultIgnore
Configured byorg.eclipse.sisu.osgi.ServiceBindings.ignore
system property.- Returns:
- Globbed pattern of types to ignore
-
subscribe
Description copied from interface:BindingPublisher
Subscribes the givenBindingSubscriber
to receiveBinding
s.- Specified by:
subscribe
in interfaceBindingPublisher
- Parameters:
subscriber
- The subscriber
-
unsubscribe
Description copied from interface:BindingPublisher
Stops the givenBindingSubscriber
from receivingBinding
s.- Specified by:
unsubscribe
in interfaceBindingPublisher
- Parameters:
subscriber
- The subscriber
-
maxBindingRank
public int maxBindingRank()Description copied from interface:BindingPublisher
Estimates the maximum rank this publisher may assign to aBinding
.- Specified by:
maxBindingRank
in interfaceBindingPublisher
- Returns:
- Maximum binding rank
-
adapt
Description copied from interface:BindingPublisher
Attempts to adapt this publisher to the given type.- Specified by:
adapt
in interfaceBindingPublisher
- Parameters:
type
- The target type- Returns:
- Adapted instance;
null
if it couldn't be adapted
-