org.robokind.api.common.services
Class ServiceConnectionDirectory

java.lang.Object
  extended by org.robokind.api.common.services.ServiceConnectionDirectory

public class ServiceConnectionDirectory
extends Object

The ServiceConnectionDirectory helps locate the proper ServiceConfigurationLoader and ServiceFactory to build the right Service from the given parameters.

Author:
Matthew Stevenson

Constructor Summary
ServiceConnectionDirectory()
           
 
Method Summary
static
<ServiceClass,Param>
ServiceClass
buildService(org.osgi.framework.BundleContext context, VersionProperty serviceVersion, VersionProperty configFormat, Param param, Class<Param> paramClass, Class<ServiceClass> serviceClass)
          Locates the appropriate ServiceConfigurationLoader and ServiceFactory matching the given versions, and able to create Service instance of the ServiceClass using the given param.
static
<ServiceClass,Param>
ServiceContext<ServiceClass,?,Param>
buildServiceContext(org.osgi.framework.BundleContext context, VersionProperty serviceVersion, VersionProperty configFormat, Class<ServiceClass> serviceClass, Class<Param> paramClass)
          Locates an appropriate ServiceConfigurationLoader and ServiceFactory matching the given versions, and able to create Service instance of the ServiceClass using a parameter of the given Param Class.
static
<ServiceConfig,Param>
List<ServiceConfigurationLoader<ServiceConfig,Param>>
getConfigLoaders(org.osgi.framework.BundleContext context, VersionProperty configFormat, Class<ServiceConfig> configClass, Class<Param> paramClass)
          Retrieves all ServiceConfigurationLoaders with the given Param Class, ServiceConfig Class, and Configuration Format Version.
static
<ServiceClass>
List<ServiceFactory<ServiceClass,?>>
getServiceFactories(org.osgi.framework.BundleContext context, VersionProperty serviceVersion, Class<ServiceClass> serviceClass)
          Retrieves all ServiceFactories with the given ServiceClass and Service Version.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceConnectionDirectory

public ServiceConnectionDirectory()
Method Detail

buildService

public static <ServiceClass,Param> ServiceClass buildService(org.osgi.framework.BundleContext context,
                                                             VersionProperty serviceVersion,
                                                             VersionProperty configFormat,
                                                             Param param,
                                                             Class<Param> paramClass,
                                                             Class<ServiceClass> serviceClass)
Locates the appropriate ServiceConfigurationLoader and ServiceFactory matching the given versions, and able to create Service instance of the ServiceClass using the given param.

Type Parameters:
ServiceClass - Class of the Service built
Param - Class of the parameter required to build the Service
Parameters:
context - BundleContext used to located ServiceConfigurationLoaders and ServiceFactories
serviceVersion - Version of the Service to be built. This is used to locate the proper ServiceFactory
configFormat - Version of the ServiceConfiguration data format. This is used to locate the proper ServiceConfigurationLoader
param - Parameter to load a ServiceConfig from. This is passed to a ServiceConfigurationLoader
paramClass - Class of the Param to be read. This is needed in addition to the Param instance in order to resolve the correct class when dealing with inheritance.
serviceClass - Class of the Service to be built
Returns:
Service matching the given type and version, built from the given param

buildServiceContext

public static <ServiceClass,Param> ServiceContext<ServiceClass,?,Param> buildServiceContext(org.osgi.framework.BundleContext context,
                                                                                            VersionProperty serviceVersion,
                                                                                            VersionProperty configFormat,
                                                                                            Class<ServiceClass> serviceClass,
                                                                                            Class<Param> paramClass)
Locates an appropriate ServiceConfigurationLoader and ServiceFactory matching the given versions, and able to create Service instance of the ServiceClass using a parameter of the given Param Class.

Type Parameters:
ServiceClass - Class of the Service built
Param - Class of the parameter required to build the Service
Parameters:
context - BundleContext used to located ServiceConfigurationLoaders and ServiceFactories
serviceVersion - Version of the Service to be built. This is used to locate the proper ServiceFactory
configFormat - Version of the ServiceConfiguration data format. This is used to locate the proper ServiceConfigurationLoader
serviceClass - Class of the Service to be built
paramClass - Class of the parameter required by the ServiceConfigurationLoader
Returns:
ServiceContext containing appropriate ServiceConfigurationLoader and ServiceFactory matching the given versions, and able to create Service instance of the ServiceClass using a parameter of the given Param Class

getServiceFactories

public static <ServiceClass> List<ServiceFactory<ServiceClass,?>> getServiceFactories(org.osgi.framework.BundleContext context,
                                                                                      VersionProperty serviceVersion,
                                                                                      Class<ServiceClass> serviceClass)
Retrieves all ServiceFactories with the given ServiceClass and Service Version.

Type Parameters:
ServiceClass - Class of the Service built
Parameters:
context - BundleContext used to located the ServiceFactories
serviceVersion - Version of the Service to be built. This is used to locate the proper ServiceFactory
serviceClass - Class of the Service to be built
Returns:
all ServiceFactories with the given ServiceClass and Service Version

getConfigLoaders

public static <ServiceConfig,Param> List<ServiceConfigurationLoader<ServiceConfig,Param>> getConfigLoaders(org.osgi.framework.BundleContext context,
                                                                                                           VersionProperty configFormat,
                                                                                                           Class<ServiceConfig> configClass,
                                                                                                           Class<Param> paramClass)
Retrieves all ServiceConfigurationLoaders with the given Param Class, ServiceConfig Class, and Configuration Format Version.

Type Parameters:
ServiceConfig - Class of ServiceConfig to be returned
Param - Class of the parameter accepted by the loaders
Parameters:
context - BundleContext used to locate the loaders
configFormat - Version of the ServiceConfiguration data format. This is used to locate the proper ServiceConfigurationLoader
configClass - Class of ServiceConfig to be returned
paramClass - Class of the parameter accepted by the loaders
Returns:
all ServiceConfigurationLoaders with the given Param Class, ServiceConfig Class, and Configuration Format Version


Copyright © 2011. All Rights Reserved.