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 ConfigurationLoader 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 ConfigurationLoader 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 ConfigurationLoader 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<ConfigurationLoader<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
<ServiceConfig,Param>
List<ConfigurationWriter<ServiceConfig,Param>>
getConfigWriters(org.osgi.framework.BundleContext context, VersionProperty configFormat, Class<ServiceConfig> configClass, Class<Param> paramClass)
          Finds ServiceConfigurationWriters matching the given criteria.
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)
                                 throws Exception
Locates the appropriate ConfigurationLoader 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 ConfigurationLoader
param - Parameter to load a ServiceConfig from. This is passed to a ConfigurationLoader
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
Throws:
Exception

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 ConfigurationLoader 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 ConfigurationLoader
serviceClass - Class of the Service to be built
paramClass - Class of the parameter required by the ConfigurationLoader
Returns:
ServiceContext containing appropriate ConfigurationLoader 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<ConfigurationLoader<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 ConfigurationLoader
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

getConfigWriters

public static <ServiceConfig,Param> List<ConfigurationWriter<ServiceConfig,Param>> getConfigWriters(org.osgi.framework.BundleContext context,
                                                                                                    VersionProperty configFormat,
                                                                                                    Class<ServiceConfig> configClass,
                                                                                                    Class<Param> paramClass)
Finds ServiceConfigurationWriters matching the given criteria.

Type Parameters:
ServiceConfig - type of configuration to write
Param - parameter type used for writing
Parameters:
context - BundleContext used to locate writers
configFormat - Version of the ServiceConfiguration data format
configClass - Class of ServiceConfig to be returned
paramClass - Class of the parameter accepted by the writers
Returns:
all ServiceConfigurationWriters with the given Param Class, ServiceConfig Class, and Configuration Format Version


Copyright © 2011-2013. All Rights Reserved.