|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.osgi.util.OsgiListenerUtils
public abstract class OsgiListenerUtils
Utility class for dealing with various OSGi listeners, mainly
ServiceListener
s. This class contains common functionality such as
broadcasting events or safely registering an OSGi listener.
Constructor Summary | |
---|---|
OsgiListenerUtils()
|
Method Summary | |
---|---|
static void |
addServiceListener(BundleContext context,
ServiceListener listener,
Filter filter)
Adds a service listener to the given bundle context under the specified filter. |
static void |
addServiceListener(BundleContext context,
ServiceListener listener,
String filter)
Adds a service listener to the given bundle context under the specified filter given as a String. |
static void |
addSingleServiceListener(BundleContext context,
ServiceListener listener,
Filter filter)
Adds a service listener to the given bundle context, under the specified filter. |
static void |
addSingleServiceListener(BundleContext context,
ServiceListener listener,
String filter)
Adds a service listener to the given application context, under the specified filter given as a String. |
static boolean |
removeServiceListener(BundleContext context,
ServiceListener listener)
Removes a service listener from the given bundle context. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public OsgiListenerUtils()
Method Detail |
---|
public static void addServiceListener(BundleContext context, ServiceListener listener, Filter filter)
REGISTERED
for all existing services (that
match the given filter) as if the services were registered after the
listener registration.
This might cause problems if a service is registered between the
listener registration and the retrieval of existing services since the
listener will receive two events for the same service. For most listeners
implementations however, this should not be a problem
context
- bundle context to register the listener withlistener
- service listener to be registeredfilter
- OSGi filter (given as a Filter) for registering the
listener (can be null
)addServiceListener(BundleContext, ServiceListener, String)
public static void addServiceListener(BundleContext context, ServiceListener listener, String filter)
REGISTERED
.
This might cause problems if a service is registered between the
listener registration and the retrieval of existing services since the
listener will receive two events for the same service. For most listeners
implementations however, this should not be a problem
context
- bundle context to register the listener withlistener
- service listener to be registeredfilter
- OSGi filter (given as a String) for registering the
listener (can be null
)BundleContext.getServiceReference(String)
,
BundleContext.getServiceReferences(String, String)
public static void addSingleServiceListener(BundleContext context, ServiceListener listener, Filter filter)
REGISTERED
for the best matching
existing service as if the services were registered after the listener
registration.
This might cause problems if a service is registered between the
listener registration and the retrieval of existing services since the
listener will receive two events for the same service. For most listeners
implementations however, this should not be a problem
context
- bundle context to register the listener withlistener
- service listener to be registeredfilter
- OSGi filter (given as a Filter) for registering the
listener (can be null
)addSingleServiceListener(BundleContext, ServiceListener, String)
public static void addSingleServiceListener(BundleContext context, ServiceListener listener, String filter)
REGISTERED
. This is the only difference from
addServiceListener(BundleContext, ServiceListener, Filter)
which
considers all services, not just the best match.
This might cause problems if a service is registered between the
listener registration and the retrieval of existing services since the
listener will receive two events for the same service. For most listeners
implementations however, this should not be a problem
context
- bundle context to register the listener withlistener
- service listener to be registeredfilter
- OSGi filter (given as a String) for registering the
listener (can be null
)BundleContext.getServiceReference(String)
,
BundleContext.getServiceReferences(String, String)
public static boolean removeServiceListener(BundleContext context, ServiceListener listener)
context
- bundle context to unregister the listener fromlistener
- service listener to unregister
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |