Package org.eclipse.sisu.osgi
Class ServiceBindings
java.lang.Object
org.eclipse.sisu.osgi.ServiceBindings
- All Implemented Interfaces:
BindingPublisher
On-demand publisher of
Bindings from the OSGi service registry.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Pattern[]private final org.osgi.framework.BundleContextprivate static final Patternprivate final Pattern[]private final intprivate final ConcurrentMap<String, BindingTracker<?>> -
Constructor Summary
ConstructorsConstructorDescriptionServiceBindings(org.osgi.framework.BundleContext context) Creates new publisher of service bindings, using the given OSGiBundleContextto 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 OSGiBundleContextto 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 TypeMethodDescriptionstatic Stringstatic StringintEstimates the maximum rank this publisher may assign to aBinding.private static Pattern[]parseGlobs(String globs) private booleanshouldTrack(String clazzName) <T> voidsubscribe(BindingSubscriber<T> subscriber) Subscribes the givenBindingSubscriberto receiveBindings.<T> voidunsubscribe(BindingSubscriber<T> subscriber) Stops the givenBindingSubscriberfrom receivingBindings.
-
Field Details
-
GLOB_SYNTAX
-
trackers
-
context
private final org.osgi.framework.BundleContext context -
allowed
-
ignored
-
maxRank
private final int maxRank
-
-
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 OSGiBundleContextto 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 OSGiBundleContextto track services.
Uses default allow/ignore settings and assigns any published services the lowest possible ranking.- Parameters:
context- The tracking context
-
-
Method Details
-
defaultAllow
- Returns:
- Globbed pattern of types to allow
-
defaultIgnore
- Returns:
- Globbed pattern of types to ignore
-
subscribe
Description copied from interface:BindingPublisherSubscribes the givenBindingSubscriberto receiveBindings.- Specified by:
subscribein interfaceBindingPublisher- Parameters:
subscriber- The subscriber
-
unsubscribe
Description copied from interface:BindingPublisherStops the givenBindingSubscriberfrom receivingBindings.- Specified by:
unsubscribein interfaceBindingPublisher- Parameters:
subscriber- The subscriber
-
maxBindingRank
public int maxBindingRank()Description copied from interface:BindingPublisherEstimates the maximum rank this publisher may assign to aBinding.- Specified by:
maxBindingRankin interfaceBindingPublisher- Returns:
- Maximum binding rank
-
shouldTrack
-
parseGlobs
-