com.codemonster.surinam.routing
Class FullyDynamicCachingInvocationRouterImpl

java.lang.Object
  extended by com.codemonster.surinam.routing.FullyDynamicCachingInvocationRouterImpl
All Implemented Interfaces:
InterceptorLifecycle, ServiceInvocationRouter, InvocationHandler

public class FullyDynamicCachingInvocationRouterImpl
extends Object
implements ServiceInvocationRouter

This is the primary interceptor for the framework; as the name implies, this InvocationRouter caches a reference to the Service and will refresh that reference in response to Service Graph reshaping activity.


Constructor Summary
FullyDynamicCachingInvocationRouterImpl(ServiceBlock serviceBlock, Class serviceInterface)
          This is a very important constructor since it includes code that performs an initial service lookup which will be a cached reference to the invocation target.
FullyDynamicCachingInvocationRouterImpl(ServiceBlock serviceBlock, String serviceInterfaceName)
           
 
Method Summary
 String getInvocationTargetName()
          Primarily for testing purposes, this will give us a view of the cached target.
 void invalidateReferences()
          Since this interceptor holds a static reference to the Service, we will refresh the reference when reshaping of the Service Graph occurs.
 Object invoke(Object proxy, Method method, Object[] args)
          This signature is dictated by Java for interception.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FullyDynamicCachingInvocationRouterImpl

public FullyDynamicCachingInvocationRouterImpl(ServiceBlock serviceBlock,
                                               Class serviceInterface)
                                        throws UnknownServiceException,
                                               UnavailableServiceException,
                                               InvocationTargetException
This is a very important constructor since it includes code that performs an initial service lookup which will be a cached reference to the invocation target.

Parameters:
serviceBlock - The Service Block that this interceptor is integrated with.
serviceInterface - The service interface is the unique identifier that specifies the service we want to use.
Throws:
UnknownServiceException - Thrown if we are asking for a service that is not registered.
UnavailableServiceException - Thrown if we are asking for a service that is not available.
InvocationTargetException - Thrown if there is an internal problem.

FullyDynamicCachingInvocationRouterImpl

public FullyDynamicCachingInvocationRouterImpl(ServiceBlock serviceBlock,
                                               String serviceInterfaceName)
                                        throws UnknownServiceException,
                                               UnavailableServiceException,
                                               InvocationTargetException,
                                               ClassNotFoundException
Parameters:
serviceBlock - The Service Block that this interceptor is integrated with.
serviceInterfaceName - The service interface is the unique identifier that specifies the service we want.
Throws:
UnknownServiceException - Thrown if we are asking for a service that is not registered.
UnavailableServiceException - Thrown if we are asking for a service that is not available.
InvocationTargetException - Thrown if there is an internal problem.
ClassNotFoundException - Thrown if the given class name cannot be converted to a Class object.
Method Detail

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws UnknownServiceException,
                     InvocationTargetException,
                     UnavailableServiceException,
                     IllegalAccessException
This signature is dictated by Java for interception. Note that Surinam does not require that interfaces (i.e. Software Service Contracts) declare these exceptions for every invocation... they are possible.

Specified by:
invoke in interface InvocationHandler
Parameters:
proxy - This is the object upon which the original invocation was made, which we ignore.
method - this is the method that we want to call.
args - these are the parameters for the invocation.
Returns:
returns whatever this method call normally returns.
Throws:
UnknownServiceException - thrown if the service being retrieved is unknown to the system.
InvocationTargetException - thrown if there is a problem with the mechanics of the invocation.
UnavailableServiceException - thrown if the service is offline.
IllegalAccessException - thrown by Java if there is a security violation.

invalidateReferences

public void invalidateReferences()
Since this interceptor holds a static reference to the Service, we will refresh the reference when reshaping of the Service Graph occurs.

Specified by:
invalidateReferences in interface InterceptorLifecycle

getInvocationTargetName

public String getInvocationTargetName()
Primarily for testing purposes, this will give us a view of the cached target.

Returns:
Returns the result of calling toString() on the cached invocation target.


Copyright © 2010. All Rights Reserved.