public abstract class AbstractCyActivator extends Object
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>
Constructor and Description |
---|
AbstractCyActivator()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected <S> S |
getService(BundleContext bc,
Class<S> serviceClass)
A method that attempts to get a service of the specified type.
|
protected <S> S |
getService(BundleContext bc,
Class<S> serviceClass,
String filter)
A method that attempts to get a service of the specified type and that
passes the specified filter.
|
protected void |
registerAllServices(BundleContext bc,
Object service) |
protected void |
registerAllServices(BundleContext bc,
Object service,
Properties props)
A utility method that registers the specified service object as an OSGi service for
all interfaces that the object implements.
|
protected void |
registerService(BundleContext bc,
Object service,
Class<?> serviceClass) |
protected void |
registerService(BundleContext bc,
Object service,
Class<?> serviceClass,
Properties props)
A utility method that registers the specified service object as an OSGi service of
the specified type.
|
protected <S> void |
registerServiceListener(BundleContext bc,
BiConsumer<S,Map<String,String>> registerConsumer,
BiConsumer<S,Map<String,String>> unregisterConsumer,
Class<S> 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.
|
protected <S> void |
registerServiceListener(BundleContext bc,
BiConsumer<S,Map<String,String>> registerConsumer,
BiConsumer<S,Map<String,String>> unregisterConsumer,
Class<S> 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.
|
protected void |
registerServiceListener(BundleContext bc,
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.
|
protected void |
registerServiceListener(BundleContext bc,
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.
|
protected void |
registerServiceListener(BundleContext bc,
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.
|
protected void |
registerServiceListener(BundleContext bc,
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 |
shutDown()
Cleans up resources used by the app.
|
void |
stop(BundleContext bc)
A default implementation of the BundleActivator.stop() method that cleans
up any services registered, services gotten, or services being listened
for as determined by calls to the utility methods provided by this class.
|
public final void stop(BundleContext bc)
public void shutDown()
protected final <S> S getService(BundleContext bc, Class<S> serviceClass)
S
- The generic type of the class defining the type of service desired.bc
- The BundleContext used to find services.serviceClass
- The class defining the type of service desired.RuntimeException
- If the requested service can't be found.protected final <S> S getService(BundleContext bc, Class<S> serviceClass, String filter)
S
- The generic type of the class defining the type of service desired.bc
- The BundleContext used to find services.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.protected final void registerServiceListener(BundleContext bc, Object listener, String registerMethodName, String unregisterMethodName, Class<?> serviceClass, Class<?> methodClass, String additionalFilter)
bc
- The BundleContext used to find services.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 servicesprotected final void registerServiceListener(BundleContext bc, Object listener, String registerMethodName, String unregisterMethodName, Class<?> serviceClass)
bc
- The BundleContext used to find services.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.protected final void registerServiceListener(BundleContext bc, Object listener, String registerMethodName, String unregisterMethodName, Class<?> serviceClass, String additionalFilter)
bc
- The BundleContext used to find services.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 servicesprotected <S> void registerServiceListener(BundleContext bc, BiConsumer<S,Map<String,String>> registerConsumer, BiConsumer<S,Map<String,String>> unregisterConsumer, Class<S> serviceClass)
public class MyServiceListener { public void addService(MyService s, Map<String,String> props) { ... } public void removeService(MyService s, Map<String,String> props { ... } } registerServiceListener(bc, myServiceListener::addService, myServiceListener::removeService, MyService.class);
bc
- The BundleContext used to find services.registerConsumer
- A reference to the method to be called when a service is registered.unregisterConsumer
- A reference to the method to be called when a service is unregistered.serviceClass
- The class defining the type of service desired.protected <S> void registerServiceListener(BundleContext bc, BiConsumer<S,Map<String,String>> registerConsumer, BiConsumer<S,Map<String,String>> unregisterConsumer, Class<S> serviceClass, String additionalFilter)
public class MyServiceListener { public void addService(MyService s, Map<String,String< props) { ... } public void removeService(MyService s, Map<String,String> props { ... } } registerServiceListener(bc, myServiceListener::addService, myServiceListener::removeService, MyService.class);
bc
- The BundleContext used to find services.registerConsumer
- A reference to the method to be called when a service is registered.unregisterConsumer
- A reference to 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 servicesprotected final void registerServiceListener(BundleContext bc, Object listener, String registerMethodName, String unregisterMethodName, Class<?> serviceClass, Class<?> methodClass)
bc
- The BundleContext used to find services.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.protected final void registerAllServices(BundleContext bc, Object service, Properties props)
bc
- The BundleContext used to find services.service
- The object to be registered as one or more services.props
- The service properties to be registered with each service.protected final void registerAllServices(BundleContext bc, Object service)
protected final void registerService(BundleContext bc, Object service, Class<?> serviceClass, Properties props)
bc
- The BundleContext used to find services.service
- The object to be registered as one or more services.serviceClass
- The class defining the type of service to be registered.props
- The service properties to be registered with each service.Copyright 2011-2015 Cytoscape Consortium. All rights reserved.