Package org.eclipse.sisu.osgi
Class ServiceBindings
- java.lang.Object
-
- org.eclipse.sisu.osgi.ServiceBindings
-
- All Implemented Interfaces:
BindingPublisher
public final class ServiceBindings extends Object implements BindingPublisher
On-demand publisher ofBindings from the OSGi service registry.
-
-
Constructor Summary
Constructors Constructor Description 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.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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Tadapt(Class<T> type)Attempts to adapt this publisher to the given type.static StringdefaultAllow()Configured byorg.eclipse.sisu.osgi.ServiceBindings.allowsystem property.static StringdefaultIgnore()Configured byorg.eclipse.sisu.osgi.ServiceBindings.ignoresystem property.intmaxBindingRank()Estimates the maximum rank this publisher may assign to aBinding.<T> voidsubscribe(BindingSubscriber<T> subscriber)Subscribes the givenBindingSubscriberto receiveBindings.<T> voidunsubscribe(BindingSubscriber<T> subscriber)Stops the givenBindingSubscriberfrom receivingBindings.
-
-
-
Constructor Detail
-
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 Detail
-
defaultAllow
public static String defaultAllow()
Configured byorg.eclipse.sisu.osgi.ServiceBindings.allowsystem property.- Returns:
- Globbed pattern of types to allow
-
defaultIgnore
public static String defaultIgnore()
Configured byorg.eclipse.sisu.osgi.ServiceBindings.ignoresystem property.- Returns:
- Globbed pattern of types to ignore
-
subscribe
public <T> void subscribe(BindingSubscriber<T> subscriber)
Description copied from interface:BindingPublisherSubscribes the givenBindingSubscriberto receiveBindings.- Specified by:
subscribein interfaceBindingPublisher- Parameters:
subscriber- The subscriber
-
unsubscribe
public <T> void unsubscribe(BindingSubscriber<T> subscriber)
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
-
adapt
public <T> T adapt(Class<T> type)
Description copied from interface:BindingPublisherAttempts to adapt this publisher to the given type.- Specified by:
adaptin interfaceBindingPublisher- Parameters:
type- The target type- Returns:
- Adapted instance;
nullif it couldn't be adapted
-
-