public final class ServiceBindings extends java.lang.Object implements BindingPublisher
Bindings from the OSGi service registry.| Modifier and Type | Field and Description |
|---|---|
private java.util.regex.Pattern[] |
allowed |
private org.osgi.framework.BundleContext |
context |
private static java.util.regex.Pattern |
GLOB_SYNTAX |
private java.util.regex.Pattern[] |
ignored |
private int |
maxRank |
private java.util.concurrent.ConcurrentMap<java.lang.String,BindingTracker<?>> |
trackers |
| Constructor and Description |
|---|
ServiceBindings(org.osgi.framework.BundleContext context)
Creates new publisher of service bindings, using the given OSGi
BundleContext to track services.Uses default allow/ignore settings and assigns any published services the lowest possible ranking. |
ServiceBindings(org.osgi.framework.BundleContext context,
java.lang.String allow,
java.lang.String ignore,
int maxRank)
Creates new publisher of service bindings, using the given OSGi
BundleContext 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). |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
defaultAllow() |
static java.lang.String |
defaultIgnore() |
int |
maxBindingRank()
Estimates the maximum rank this publisher may assign to a
Binding. |
private static java.util.regex.Pattern[] |
parseGlobs(java.lang.String globs) |
private boolean |
shouldTrack(java.lang.String clazzName) |
<T> void |
subscribe(BindingSubscriber<T> subscriber)
Subscribes the given
BindingSubscriber to receive Bindings. |
<T> void |
unsubscribe(BindingSubscriber<T> subscriber)
Stops the given
BindingSubscriber from receiving Bindings. |
private static final java.util.regex.Pattern GLOB_SYNTAX
private final java.util.concurrent.ConcurrentMap<java.lang.String,BindingTracker<?>> trackers
private final org.osgi.framework.BundleContext context
private final java.util.regex.Pattern[] allowed
private final java.util.regex.Pattern[] ignored
private final int maxRank
public ServiceBindings(org.osgi.framework.BundleContext context,
java.lang.String allow,
java.lang.String ignore,
int maxRank)
BundleContext to track services.context - The tracking contextallow - Globbed pattern of packages/types to allowignore - Globbed pattern of packages/types to ignoremaxRank - Maximum binding rankpublic ServiceBindings(org.osgi.framework.BundleContext context)
BundleContext to track services.context - The tracking contextpublic static java.lang.String defaultAllow()
org.eclipse.sisu.osgi.ServiceBindings.allow} system propertypublic static java.lang.String defaultIgnore()
org.eclipse.sisu.osgi.ServiceBindings.ignore} system propertypublic <T> void subscribe(BindingSubscriber<T> subscriber)
BindingPublisherBindingSubscriber to receive Bindings.subscribe in interface BindingPublishersubscriber - The subscriberpublic <T> void unsubscribe(BindingSubscriber<T> subscriber)
BindingPublisherBindingSubscriber from receiving Bindings.unsubscribe in interface BindingPublishersubscriber - The subscriberpublic int maxBindingRank()
BindingPublisherBinding.maxBindingRank in interface BindingPublisherprivate boolean shouldTrack(java.lang.String clazzName)
private static java.util.regex.Pattern[] parseGlobs(java.lang.String globs)