org.spicefactory.cinnamon.config
Class ServiceConfig

java.lang.Object
  extended by org.spicefactory.cinnamon.config.ServiceConfig

public class ServiceConfig
extends Object

Represents a single service configuration. Each service is defined by a unique name, a service interface and a set of operations. Optionally a service implementation can be specified (some ServiceFactories like the SpringServiceFactory do not need that information).

Author:
Jens Halm

Constructor Summary
ServiceConfig(String name, String scope, Class<?> serviceInterface, Class<?> implementation, List<OperationConfig> operations, boolean processAnnotations)
          Creates a new service configuration.
 
Method Summary
 void addOperation(OperationConfig operation)
          Adds an operation that can be invoked by clients to this service.
 ServiceFactory getFactory()
          Returns the ServiceFactory that should be used to handle requests for this service.
 String getName()
          Returns the name of this service.
 List<OperationConfig> getOperations()
          Returns the list of operations that can be invoked by clients.
 boolean getProcessAnnotations()
          Check if annotations should be processed for this service.
 String getScope()
          Returns the scope of this service.
 Class<?> getServiceApi()
          Returns the API of the service, which usually is the interface of the service, or the implementation if no interface was specified.
 Class<?> getServiceImplementation()
          Returns the class that implements this service.
 Class<?> getServiceInterface()
          Returns the service interface.
 void setFactory(ServiceFactory factory)
          Sets the factory that should be used to handle requests for this service.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServiceConfig

public ServiceConfig(String name,
                     String scope,
                     Class<?> serviceInterface,
                     Class<?> implementation,
                     List<OperationConfig> operations,
                     boolean processAnnotations)
Creates a new service configuration.

Parameters:
name - the name of the service
scope - the scope (optional parameter, not used by all ServiceFactories)
serviceInterface - the service interface (optional if implementation is specified)
implementation - the service implementation (optional parameter, not used by all ServiceFactories)
operations - the list of operations that can be invoked by clients
processAnnotations - whether annotations in the service interface should be processed
Method Detail

getName

public String getName()
Returns the name of this service.

Returns:
the name of this service.

getScope

public String getScope()
Returns the scope of this service. This is an optional parameter. ServiceFactories like the SpringServiceFactory have their own way for defining scopes. Of Cinnamons builtin ServiceFactories only PlainJavaServiceFactory needs this property. Usually one of the values request, session or application.

Returns:
the scope of this service or null if it has not been set

getServiceApi

public Class<?> getServiceApi()
Returns the API of the service, which usually is the interface of the service, or the implementation if no interface was specified.

Returns:
the service API.

getServiceInterface

public Class<?> getServiceInterface()
Returns the service interface.

Returns:
the service interface.

getServiceImplementation

public Class<?> getServiceImplementation()
Returns the class that implements this service. This is an optional parameter. ServiceFactories like the SpringServiceFactory have their own way for defining the implementation class. Of Cinnamons builtin ServiceFactories only PlainJavaServiceFactory needs this property. Must be a class implementing the service interface.

Returns:
the class that implements this service

getOperations

public List<OperationConfig> getOperations()
Returns the list of operations that can be invoked by clients.

Returns:
the list of operations that can be invoked by clients

addOperation

public void addOperation(OperationConfig operation)
Adds an operation that can be invoked by clients to this service.

Parameters:
operation - an operation that can be invoked by clients

getProcessAnnotations

public boolean getProcessAnnotations()
Check if annotations should be processed for this service.

Returns:
true if annotations should be processed for this service

getFactory

public ServiceFactory getFactory()
Returns the ServiceFactory that should be used to handle requests for this service.

Returns:
the ServiceFactory that should be used to handle requests for this service

setFactory

public void setFactory(ServiceFactory factory)
Sets the factory that should be used to handle requests for this service.

Parameters:
factory - the factory that should be used to handle requests for this service

toString

public String toString()
Overrides:
toString in class Object