public final class ServiceBindings extends java.lang.Object implements BindingPublisher
Binding
s 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 Binding s. |
<T> void |
unsubscribe(BindingSubscriber<T> subscriber)
Stops the given
BindingSubscriber from receiving Binding s. |
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 property
public static java.lang.String defaultIgnore()
org.eclipse.sisu.osgi.ServiceBindings.ignore} system property
public <T> void subscribe(BindingSubscriber<T> subscriber)
BindingPublisher
BindingSubscriber
to receive Binding
s.subscribe
in interface BindingPublisher
subscriber
- The subscriberpublic <T> void unsubscribe(BindingSubscriber<T> subscriber)
BindingPublisher
BindingSubscriber
from receiving Binding
s.unsubscribe
in interface BindingPublisher
subscriber
- The subscriberpublic int maxBindingRank()
BindingPublisher
Binding
.maxBindingRank
in interface BindingPublisher
private boolean shouldTrack(java.lang.String clazzName)
private static java.util.regex.Pattern[] parseGlobs(java.lang.String globs)