Cytoscape 3.0.1 API

org.cytoscape.service.util
Class AbstractCyActivator

java.lang.Object
  extended by org.cytoscape.service.util.AbstractCyActivator

public abstract class AbstractCyActivator
extends Object

A simple BundleActivator with convenience methods for registering OSGi services and either getting references to single services or registering interest in all services of a specified type. Users should extend this class and implement the start(BundleContext bc) method.


Cytoscape Backwards Compatibility (Abstract Class): This class is abstract and meant to be extended by users. This means that we may add methods for minor version updates. Methods will only be removed for major version updates.

Constructor Summary
AbstractCyActivator()
          Constructor.
 
Method Summary
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, 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, Properties props)
          A utility method that registers the specified service object as an OSGi service of the specified type.
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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCyActivator

public AbstractCyActivator()
Constructor.

Method Detail

stop

public final 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. If you register a service, get a service, or listen for services outside yourself using normal calls to the OSGi API, you will need to clean everything up yourself!


getService

protected final <S> S getService(BundleContext bc,
                                 Class<S> serviceClass)
A method that attempts to get a service of the specified type. If an appropriate service is not found, an exception will be thrown.

Type Parameters:
S - The generic type of the class defining the type of service desired.
Parameters:
bc - The BundleContext used to find services.
serviceClass - The class defining the type of service desired.
Returns:
A reference to a service of type serviceClass.
Throws:
RuntimeException - If the requested service can't be found.

getService

protected final <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. If an appropriate service is not found, an exception will be thrown.

Type Parameters:
S - The generic type of the class defining the type of service desired.
Parameters:
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.
Returns:
A reference to a service of type serviceClass that passes the specified filter.
Throws:
RuntimeException - If the requested service can't be found.

registerServiceListener

protected final 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.

Parameters:
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 services

registerServiceListener

protected final 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.

Parameters:
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.

registerServiceListener

protected final 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.

Parameters:
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 services

registerServiceListener

protected final 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.

Parameters:
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.

registerAllServices

protected final 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. Note that this method will NOT register services for any packages with names that begin with "java", which is an effort to avoid registering meaningless services for core Java APIs.

Parameters:
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.

registerService

protected final 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.

Parameters:
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.

Cytoscape 3.0.1 API

Copyright 2011 Cytoscape Consortium. All rights reserved.