Cytoscape 3.0.1 API

org.cytoscape.service.util
Interface CyServiceRegistrar


public interface CyServiceRegistrar

An interface to hide the OSGi dependencies needed to register services dynamically at runtime. This provides similar methods to 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.


Cytoscape Backwards Compatibility (API Interface): We expect that this interface will be used but not implemented by developers using this interface. As such, we reserve the right to add methods to the interface as part of minor version upgrades. We will not remove methods for any changes other than major version upgrades.

Method Summary
<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.
 

Method Detail

getService

<S> S getService(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:
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

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

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.

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

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.

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

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.

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

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.

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

registerService

void registerService(Object service,
                     Class<?> serviceClass,
                     Properties props)
This method registers an object as an OSGi service with the specified service interface and properties.

Parameters:
service - The object to be registered as a service.
serviceClass - The service interface the object should be registered as.
props - The service properties.

unregisterService

void unregisterService(Object service,
                       Class serviceClass)
This method unregisters an object as an OSGi service for the specified service interface.

Parameters:
service - The object to be unregistered as a service.
serviceClass - The service interface the object should be unregistered as.

registerAllServices

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. 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:
service - The object to be registered as a service for all interfaces that the object implements.
props - The service properties.

unregisterAllServices

void unregisterAllServices(Object service)
This method unregisters an object as all OSGi service interfaces that the object implements.

Parameters:
service - The object to be unregistered for services it provides.

Cytoscape 3.0.1 API

Copyright 2011 Cytoscape Consortium. All rights reserved.