Rio Project 4.2 API Documentation



org.rioproject.associations
Class AssociationProxySupport<T>

java.lang.Object
  extended by org.rioproject.associations.AssociationProxySupport<T>
All Implemented Interfaces:
AssociationListener<T>, AssociationProxy<T>

public class AssociationProxySupport<T>
extends Object
implements AssociationProxy<T>

Provides support for an AssociationProxy

Author:
Dennis Reedy

Nested Class Summary
 class AssociationProxySupport.Interceptor
           
 class AssociationProxySupport.LocalCallbackFilter
           
 class AssociationProxySupport.LocalInterceptor
           
 
Constructor Summary
AssociationProxySupport()
           
 
Method Summary
 void broken(Association<T> association, T service)
          Notification that an Association is broken
 void changed(Association<T> association, T service)
          Notification that an Association has changed
 void discovered(Association<T> association, T service)
          Notification that an Association has been discovered
 Object doInvokeService(Association<T> a, Method method, Object[] args)
           
 Association getAssociation()
          Get the association
 net.sf.cglib.proxy.CallbackFilter getCallbackFilter(Association<T> association)
          Create a CallbackFilter
 net.sf.cglib.proxy.Callback[] getCallbacks(Association<T> association)
          Create an array of Callback
 net.sf.cglib.proxy.Dispatcher getDispatcher(Association<T> association)
          Create a Dispatcher
 long getInvocationCount()
          Get the number of times the associated service(s) were invoked using this proxy
 InvocationHandler getInvocationHandler(Association<T> association)
          Create an InvocationHandler
 ServiceSelectionStrategy<T> getServiceSelectionStrategy()
          Get the ServiceSelectionStrategy
 Class getSuperClass()
          Get the super-class when creating a concrete CGLIB proxy
protected  boolean isProxyMethod(Method method)
          Ceck if the methos is found in the generated proxy
 void setProxyInterfaces(Class[] classes)
          Set the classes the proxy will support
 void setServiceSelectionStrategy(ServiceSelectionStrategy<T> strategy)
          Set the strategy for selecting services
 void terminate()
          Clean up any resources allocated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AssociationProxySupport

public AssociationProxySupport()
Method Detail

getInvocationHandler

public InvocationHandler getInvocationHandler(Association<T> association)
Create an InvocationHandler

Specified by:
getInvocationHandler in interface AssociationProxy<T>
Parameters:
association - The Association to use
Returns:
An InvocationHandler for use with a dynamic JDK proxy. This method returns a AssociationProxySupport.AssociationInvocationHandler instance

getCallbacks

public net.sf.cglib.proxy.Callback[] getCallbacks(Association<T> association)
Create an array of Callback

Specified by:
getCallbacks in interface AssociationProxy<T>
Parameters:
association - The Association to use
Returns:
An array of Callback for use with a generated CGLIB proxy. This method returns a AssociationProxySupport.LocalInterceptor as the first Callback, followed by the AssociationProxySupport.Interceptor class. This method can be overriden to return a different array of Callback instances if required.

getCallbackFilter

public net.sf.cglib.proxy.CallbackFilter getCallbackFilter(Association<T> association)
Create a CallbackFilter

Specified by:
getCallbackFilter in interface AssociationProxy<T>
Parameters:
association - The Association to use
Returns:
An array of CallbackFilter for use with a generated CGLIB proxy. This method returns a AssociationProxySupport.LocalCallbackFilter. This method can be overriden to return a different CallbackFilter if required.

getDispatcher

public net.sf.cglib.proxy.Dispatcher getDispatcher(Association<T> association)
Create a Dispatcher

Specified by:
getDispatcher in interface AssociationProxy<T>
Parameters:
association - The Association to use
Returns:
A Dispatcher for use with a generated CGLIB proxy. This method returna a null. If the underlying proxy requires a Dispatcher, this method should be overriden.

getAssociation

public Association getAssociation()
Description copied from interface: AssociationProxy
Get the association

Specified by:
getAssociation in interface AssociationProxy<T>
Returns:
The Association

getServiceSelectionStrategy

public ServiceSelectionStrategy<T> getServiceSelectionStrategy()
Get the ServiceSelectionStrategy

Specified by:
getServiceSelectionStrategy in interface AssociationProxy<T>
Returns:
The ServiceSelectionStrategy

setServiceSelectionStrategy

public void setServiceSelectionStrategy(ServiceSelectionStrategy<T> strategy)
Set the strategy for selecting services

Specified by:
setServiceSelectionStrategy in interface AssociationProxy<T>
Parameters:
strategy - The ServiceSelectionStrategy. Must not be null.

discovered

public void discovered(Association<T> association,
                       T service)
Notification that an Association has been discovered

Specified by:
discovered in interface AssociationListener<T>
Parameters:
association - The Association
service - The associated service that has been discovered

changed

public void changed(Association<T> association,
                    T service)
Notification that an Association has changed

Specified by:
changed in interface AssociationListener<T>
Parameters:
association - The Association
service - The service that was removed, changing the endpoint

broken

public void broken(Association<T> association,
                   T service)
Notification that an Association is broken

Specified by:
broken in interface AssociationListener<T>
Parameters:
association - The Association.
service - The service that was removed, causing the Association to be broken

terminate

public void terminate()
Clean up any resources allocated

Specified by:
terminate in interface AssociationProxy<T>

doInvokeService

public Object doInvokeService(Association<T> a,
                              Method method,
                              Object[] args)
                       throws Throwable
Throws:
Throwable

isProxyMethod

protected boolean isProxyMethod(Method method)
Ceck if the methos is found in the generated proxy

Parameters:
method - The Method to check
Returns:
true if the method is local to the proxy

getSuperClass

public Class getSuperClass()
Get the super-class when creating a concrete CGLIB proxy

Specified by:
getSuperClass in interface AssociationProxy<T>
Returns:
The super class to use when creating a concrete CGLIB proxy. If interfaces are being used, return null (as this default implementation does).

setProxyInterfaces

public void setProxyInterfaces(Class[] classes)
Description copied from interface: AssociationProxy
Set the classes the proxy will support

Specified by:
setProxyInterfaces in interface AssociationProxy<T>
Parameters:
classes - Array of interface classes

getInvocationCount

public long getInvocationCount()
Description copied from interface: AssociationProxy
Get the number of times the associated service(s) were invoked using this proxy

Specified by:
getInvocationCount in interface AssociationProxy<T>
Returns:
The number of time the associated services were invoked using this proxy. The returned count will represent the total number of invocations across all associated services, and include only successful invocation attempts (attempts that did not result in an exception).

Copyright © Rio Project.

Copyright © 2006-2011 Rio Project. All Rights Reserved.