org.softamis.cluster4spring.rmi.support
Class RmiEndpoint<SI extends java.io.Serializable>

java.lang.Object
  extended by org.softamis.cluster4spring.support.Endpoint<SI>
      extended by org.softamis.cluster4spring.rmi.support.RmiEndpoint<SI>
Type Parameters:
SI - - information about service

public class RmiEndpoint<SI extends java.io.Serializable>
extends Endpoint<SI>

Implementation of Endpoint that is used in RMI based cluster4spring.

Author:
Andrew Sazonov

Field Summary
protected  java.rmi.Remote fRemote
          Remote object used by endpoint fpr remote service invocation
 
Fields inherited from class org.softamis.cluster4spring.support.Endpoint
fAttributes, fEndpointKey, fLastAccessTime, fLog, fRemoteInvocationFactory, fServiceInfo
 
Constructor Summary
RmiEndpoint(org.springframework.remoting.support.RemoteInvocationFactory aRemoteInvocationFactory, java.lang.String aEndpointKey, SI aServiceInfo, java.rmi.Remote aRemote)
          Creates RMI endpoint.
 
Method Summary
protected  java.lang.Object doInvoke(org.aopalliance.intercept.MethodInvocation aMethodInvocation)
          Performs invocation of given MehodInvocation.
protected  java.lang.Object doInvokeInternal(org.aopalliance.intercept.MethodInvocation aMethodInvocation, org.springframework.remoting.rmi.RmiInvocationHandler aInvocationHandler)
          Apply the given AOP method invocation to the given RmiInvocationHandler.
 java.rmi.Remote getRemote()
          Returns remote object used by endpoint
protected  java.lang.Object invokeUsingInvocationHandler(org.aopalliance.intercept.MethodInvocation aInvocation)
          Invokes given method invocation using RMI invoker
protected  java.lang.Object invokeUsingRmiStub(org.aopalliance.intercept.MethodInvocation aInvocation)
          Invokes given method invocation using traditional RMI stub.
 void setRemote(java.rmi.Remote aRemote)
          Sets remote object used by endpoint
 
Methods inherited from class org.softamis.cluster4spring.support.Endpoint
createRemoteInvocation, getAttributes, getEndpointKey, getLastAccessTime, getServiceInfo, invoke, setAttributes, setEndpointKey, setLastAccessTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fRemote

protected java.rmi.Remote fRemote
Remote object used by endpoint fpr remote service invocation

Constructor Detail

RmiEndpoint

public RmiEndpoint(org.springframework.remoting.support.RemoteInvocationFactory aRemoteInvocationFactory,
                   java.lang.String aEndpointKey,
                   SI aServiceInfo,
                   java.rmi.Remote aRemote)
Creates RMI endpoint.

Parameters:
aRemoteInvocationFactory - factory used to create remote invocation
aEndpointKey - key used to identity endpoint
aServiceInfo - information need to locate service
aRemote - remote object
Method Detail

doInvoke

protected java.lang.Object doInvoke(org.aopalliance.intercept.MethodInvocation aMethodInvocation)
                             throws java.lang.Throwable
Performs invocation of given MehodInvocation. Method analyzes whether passed invocation is RmiInvocationHandler or regular RMI stub and invokes them accordingly.

Specified by:
doInvoke in class Endpoint<SI extends java.io.Serializable>
Parameters:
aMethodInvocation - method invocation to invoke
Returns:
result of invocation, if any
Throws:
java.lang.Throwable - exception that could occur during invocation
See Also:
invokeUsingInvocationHandler(org.aopalliance.intercept.MethodInvocation), invokeUsingRmiStub(org.aopalliance.intercept.MethodInvocation)

invokeUsingRmiStub

protected java.lang.Object invokeUsingRmiStub(org.aopalliance.intercept.MethodInvocation aInvocation)
                                       throws java.lang.Throwable
Invokes given method invocation using traditional RMI stub.

Parameters:
aInvocation - method invocation to invoke
Returns:
result of invocation, if any
Throws:
java.lang.Throwable - exception that could occur during invocation

invokeUsingInvocationHandler

protected java.lang.Object invokeUsingInvocationHandler(org.aopalliance.intercept.MethodInvocation aInvocation)
                                                 throws java.lang.Throwable
Invokes given method invocation using RMI invoker

Parameters:
aInvocation - method invocation to invoke
Returns:
result of invocation, if any
Throws:
java.lang.Throwable - exception that could occur during invocation

doInvokeInternal

protected java.lang.Object doInvokeInternal(org.aopalliance.intercept.MethodInvocation aMethodInvocation,
                                            org.springframework.remoting.rmi.RmiInvocationHandler aInvocationHandler)
                                     throws java.rmi.RemoteException,
                                            java.lang.NoSuchMethodException,
                                            java.lang.IllegalAccessException,
                                            java.lang.reflect.InvocationTargetException
Apply the given AOP method invocation to the given RmiInvocationHandler. The default implementation calls invoke with a plain RemoteInvocation.

Can be overridden in subclasses to provide custom RemoteInvocation subclasses, containing additional invocation parameters like user credentials. Can also process the returned result object.

Parameters:
aMethodInvocation - the current AOP method invocation
aInvocationHandler - the RmiInvocationHandler to apply the invocation to
Returns:
the invocation result
Throws:
java.lang.NoSuchMethodException - if the method name could not be resolved
java.lang.IllegalAccessException - if the method could not be accessed
java.lang.reflect.InvocationTargetException - if the method invocation resulted in an exception
java.rmi.RemoteException
See Also:
RemoteInvocation

getRemote

public java.rmi.Remote getRemote()
Returns remote object used by endpoint

Returns:
remote object used by endpoint

setRemote

public void setRemote(java.rmi.Remote aRemote)
Sets remote object used by endpoint

Parameters:
aRemote - remote object used by endpoint