public interface CyServiceRegistrar
AbstractCyActivator
, but you should only use CyServiceRegistrar
if you need to register services outside of AbstractCyActivator
's
start
method.
This class differs in one important way from AbstractCyActivator
.
AbstractCyActivator
maintains a list of requested services. When
the bundle is stopped, AbstractCyActivator
releases
these services. CyServiceRegistrar
also maintains a list
of requested services, but this list is separate from AbstractCyActivator
.
Services requested through this class must be released using one of
the unregisterService
methods when the bundle is stopped.Module: service-api
To use this in your app, include the following dependency in your POM:
<dependency> <groupId>org.cytoscape</groupId> <artifactId>service-api</artifactId> </dependency>
Modifier and Type | Method and Description |
---|---|
<S> S |
getService(Class<S> serviceClass)
A method that attempts to get a service of the specified type.
|
<S> S |
getService(Class<S> serviceClass,
String filter)
A method that attempts to get a service of the specified type and that
passes the specified filter.
|
void |
registerAllServices(Object service,
Properties props)
This method registers an object as an OSGi service
for all interfaces that the object implements
and with the specified properties.
|
void |
registerService(Object service,
Class<?> serviceClass,
Properties props)
This method registers an object as an OSGi service
with the specified service interface and properties.
|
void |
registerServiceListener(Object listener,
String registerMethodName,
String unregisterMethodName,
Class<?> serviceClass)
A method that will cause the specified register/unregister methods on the listener
object to be called any time that a service of the specified type is registered or
unregistered.
|
void |
registerServiceListener(Object listener,
String registerMethodName,
String unregisterMethodName,
Class<?> serviceClass,
Class<?> methodClass)
A method that will cause the specified register/unregister methods on the listener
object to be called any time that a service of the specified type is registered or
unregistered.
|
void |
registerServiceListener(Object listener,
String registerMethodName,
String unregisterMethodName,
Class<?> serviceClass,
Class<?> methodClass,
String additionalFilter)
A method that will cause the specified register/unregister methods on the listener
object to be called any time that a service of the specified type is registered or
unregistered.
|
void |
registerServiceListener(Object listener,
String registerMethodName,
String unregisterMethodName,
Class<?> serviceClass,
String additionalFilter)
A method that will cause the specified register/unregister methods on the listener
object to be called any time that a service of the specified type is registered or
unregistered.
|
void |
unregisterAllServices(Object service)
This method unregisters an object as all OSGi service
interfaces that the object implements.
|
void |
unregisterService(Object service,
Class serviceClass)
This method unregisters an object as an OSGi service
for the specified service interface.
|
<S> S getService(Class<S> serviceClass)
S
- The generic type of the class defining the type of service desired.serviceClass
- The class defining the type of service desired.RuntimeException
- If the requested service can't be found.<S> S getService(Class<S> serviceClass, String filter)
S
- The generic type of the class defining the type of service desired.serviceClass
- The class defining the type of service desired.filter
- The string defining the filter the service must pass. See OSGi's
service filtering syntax for more detail.RuntimeException
- If the requested service can't be found.void registerServiceListener(Object listener, String registerMethodName, String unregisterMethodName, Class<?> serviceClass, Class<?> methodClass, String additionalFilter)
listener
- Your object listening for service registrations.registerMethodName
- The name of the method to be called when a service is registered.unregisterMethodName
- The name of the method to be called when a service is unregistered.serviceClass
- The class defining the type of service desired.methodClass
- There are situations where, because of the use of generics and type
erasure that the serviceClass is a subclass of the class used by the registration method,
in which case, this extra argument allows that class to be specified.additionalFilter
- An additional filter to be applied to the OSGi servicesvoid registerServiceListener(Object listener, String registerMethodName, String unregisterMethodName, Class<?> serviceClass)
listener
- Your object listening for service registrations.registerMethodName
- The name of the method to be called when a service is registered.unregisterMethodName
- The name of the method to be called when a service is unregistered.serviceClass
- The class defining the type of service desired.void registerServiceListener(Object listener, String registerMethodName, String unregisterMethodName, Class<?> serviceClass, String additionalFilter)
listener
- Your object listening for service registrations.registerMethodName
- The name of the method to be called when a service is registered.unregisterMethodName
- The name of the method to be called when a service is unregistered.serviceClass
- The class defining the type of service desired.additionalFilter
- An additional filter to be applied to the OSGi servicesvoid registerServiceListener(Object listener, String registerMethodName, String unregisterMethodName, Class<?> serviceClass, Class<?> methodClass)
listener
- Your object listening for service registrations.registerMethodName
- The name of the method to be called when a service is registered.unregisterMethodName
- The name of the method to be called when a service is unregistered.serviceClass
- The class defining the type of service desired.methodClass
- There are situations where, because of the use of generics and type
erasure that the serviceClass is a subclass of the class used by the registration method,
in which case, this extra argument allows that class to be specified.void registerService(Object service, Class<?> serviceClass, Properties props)
service
- The object to be registered as a service.serviceClass
- The service interface the object should be registered as.props
- The service properties.void unregisterService(Object service, Class serviceClass)
service
- The object to be unregistered as a service.serviceClass
- The service interface the object should be unregistered as.void registerAllServices(Object service, Properties props)
service
- The object to be registered as a service for all
interfaces that the object implements.props
- The service properties.void unregisterAllServices(Object service)
service
- The object to be unregistered for services it provides.Copyright 2011-2015 Cytoscape Consortium. All rights reserved.