org.robokind.api.common.services
Class ServiceContext<ServiceClass,ServiceConfig,Param>

java.lang.Object
  extended by org.robokind.api.common.services.ServiceContext<ServiceClass,ServiceConfig,Param>
Type Parameters:
ServiceClass - Class of Service created in this ServiceContext
ServiceConfig - Class of ServiceConfig used in this ServiceContext
Param - Class of the parameter used by this ServiceContext

public class ServiceContext<ServiceClass,ServiceConfig,Param>
extends Object

An ServiceContext keeps track of an attempt to create a new Service. It contains a complementary pair of ServiceConfigurationLoader and ServiceFactory where: the loader takes the given Param type the loader and connector share the same ServiceConfig class the connector returns the given Service class

Author:
Matthew Stevenson

Constructor Summary
ServiceContext()
          Creates an empty ServiceContext
ServiceContext(ServiceConfigurationLoader<ServiceConfig,Param> loader, ServiceFactory<ServiceClass,ServiceConfig> connector)
          Creates a new ServiceContext from the given ServiceConfigurationLoader and ServiceFactory.
 
Method Summary
 void buildService()
          Builds a Service using the ServiceFactory and ServiceConfig.
 Param getLoadParameter()
          Returns the load parameter.
 ServiceClass getService()
          Returns the Service from this context
 ServiceConfig getServiceConfiguration()
          Returns the ServiceConfig loaded from the LoadParameter.
 ServiceConfigurationLoader<ServiceConfig,Param> getServiceConfigurationLoader()
          Returns the ServiceConfigurationLoader for this ServiceContext.
 ServiceFactory<ServiceClass,ServiceConfig> getServiceFactory()
          Return the ServiceFactory used by this ServiceContext.
 void loadConfiguration()
          Loads the ServiceConfig using the ServiceConfigurationLoader and LoadParameter.
 void setLoadParameter(Param param)
          Sets the load parameter.
 void setServiceConfigurationLoader(ServiceConfigurationLoader<ServiceConfig,Param> loader)
          Sets the ServiceConfigurationLoader for this ServiceContext.
 void setServiceConnector(ServiceFactory<ServiceClass,ServiceConfig> factory)
          Sets the ServiceFactory to be used by this ServiceContext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceContext

public ServiceContext()
Creates an empty ServiceContext


ServiceContext

public ServiceContext(ServiceConfigurationLoader<ServiceConfig,Param> loader,
                      ServiceFactory<ServiceClass,ServiceConfig> connector)
Creates a new ServiceContext from the given ServiceConfigurationLoader and ServiceFactory.

Parameters:
loader - ServiceConfigurationLoader of the correct type
connector - ServiceFactory of the correct type
Method Detail

getServiceConfigurationLoader

public ServiceConfigurationLoader<ServiceConfig,Param> getServiceConfigurationLoader()
Returns the ServiceConfigurationLoader for this ServiceContext.

Returns:
ServiceConfigurationLoader for this ServiceContext

setServiceConfigurationLoader

public void setServiceConfigurationLoader(ServiceConfigurationLoader<ServiceConfig,Param> loader)
Sets the ServiceConfigurationLoader for this ServiceContext.

Parameters:
loader - ServiceConfigurationLoader to use

getServiceFactory

public ServiceFactory<ServiceClass,ServiceConfig> getServiceFactory()
Return the ServiceFactory used by this ServiceContext.

Returns:
ServiceFactory used by this ServiceContext

setServiceConnector

public void setServiceConnector(ServiceFactory<ServiceClass,ServiceConfig> factory)
Sets the ServiceFactory to be used by this ServiceContext.

Parameters:
factory - ServiceFactory to be used by this ServiceContext

getLoadParameter

public Param getLoadParameter()
Returns the load parameter.

Returns:
load parameter

setLoadParameter

public void setLoadParameter(Param param)
Sets the load parameter. This is passed to the ServiceConfigurationLoader to load the ServiceConfig.

Parameters:
param - parameter passed to the ServiceConfigurationLoader to load the ServiceConfig

loadConfiguration

public void loadConfiguration()
Loads the ServiceConfig using the ServiceConfigurationLoader and LoadParameter.


getServiceConfiguration

public ServiceConfig getServiceConfiguration()
Returns the ServiceConfig loaded from the LoadParameter.

Returns:
ServiceConfig loaded from the LoadParameter

buildService

public void buildService()
Builds a Service using the ServiceFactory and ServiceConfig. Attempts to load the ServiceConfig if it has not been loaded.


getService

public ServiceClass getService()
Returns the Service from this context

Returns:
Service from this context


Copyright © 2011. All Rights Reserved.