org.spicefactory.cinnamon.service
Class DefaultServiceInvoker

java.lang.Object
  extended by org.spicefactory.cinnamon.service.DefaultServiceInvoker
All Implemented Interfaces:
ServiceInvoker

public class DefaultServiceInvoker
extends Object
implements ServiceInvoker

The default ServiceInvoker implementation that reflectively invokes a method on the target instance associated with a particular service.

Author:
Jens Halm

Constructor Summary
DefaultServiceInvoker(ServiceRequest request, Object targetInstance, List<MethodInvoker> operationCandidates)
          Creates a new ServiceInvoker instance.
 
Method Summary
 Object invoke()
          Invokes the service and returns the result, usually the return value of a method invocation
protected  Object invokeService(MethodInvoker invoker)
          Invokes the service and returns the result.
protected  MethodInvoker selectMethodInvoker()
          Selects the MethodInvoker to be used for this request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultServiceInvoker

public DefaultServiceInvoker(ServiceRequest request,
                             Object targetInstance,
                             List<MethodInvoker> operationCandidates)
Creates a new ServiceInvoker instance.

Parameters:
request - the request to process
targetInstance - the target instance that should be invoked
operationCandidates - list of methods, usually only more than one if the method is overloaded
Method Detail

invoke

public Object invoke()
Description copied from interface: ServiceInvoker
Invokes the service and returns the result, usually the return value of a method invocation

Specified by:
invoke in interface ServiceInvoker
Returns:
the result of the service invocation

selectMethodInvoker

protected MethodInvoker selectMethodInvoker()
Selects the MethodInvoker to be used for this request. Selection will be based on the number and types of parameters that most closely matches the required parameters of the target method.

Returns:
the MethodInvoker to be used for this request

invokeService

protected Object invokeService(MethodInvoker invoker)
Invokes the service and returns the result.

Parameters:
invoker - the MethodInvoker to use
Returns:
the result of the method invocation