org.spicefactory.cinnamon.service
Interface ServiceFactory

All Known Implementing Classes:
AbstractMethodInvocationServiceFactory, PlainJavaServiceFactory, SpringServiceFactory

public interface ServiceFactory

A ServiceFactory implementation is responsible for creating ServiceInvoker instances for particular ServiceRequests. Cinnamon initially comes with two builtin ServiceFactories for Spring managed beans and for plain Java classes. Later releases may include further implementations to integrate with other technologies and frameworks. Alternatively you can easily create your own implementations for custom integration requirements.

Author:
Jens Halm

Method Summary
 void addServiceConfig(ServiceConfig config)
          Add a configuration for a service that should be handled by this factory.
 ServiceInvoker getServiceInvoker(ServiceRequest request)
          Create a ServiceInvoker instance for a particular ServiceRequest.
 void init(Map<String,String> initMap, Map<String,Object> applicationMap, CinnamonConfig config)
          Initializes the ServiceFactory.
 

Method Detail

init

void init(Map<String,String> initMap,
          Map<String,Object> applicationMap,
          CinnamonConfig config)
Initializes the ServiceFactory. Will only be called once by the framework at application startup.

Parameters:
initMap - the initialisation parameters (taken from ServletConfig in a web application)
applicationMap - the application attributes (taken from ServletContext in a web application)
config - the Cinnamon configuration

addServiceConfig

void addServiceConfig(ServiceConfig config)
Add a configuration for a service that should be handled by this factory. This method will be invoked once at application startup for every service configuration associated with this factory and before any ServiceInvoker will be requested from this factory.

Parameters:
config - a configuration for a service that should be handled by this factory

getServiceInvoker

ServiceInvoker getServiceInvoker(ServiceRequest request)
Create a ServiceInvoker instance for a particular ServiceRequest. This usually involves analyzing the ServiceRequest instance to locate the service and operation to be invoked and wrap it in a ServiceInvoker instance. Implementations should take into account that the created ServiceInvoker may never be used, for example if a ServiceInterceptor prematurely completed the request.

Parameters:
request - the request to be processed
Returns:
the ServiceInvoker to be used for the given request