org.springframework.remoting.rmi
Class RmiClientInterceptorUtils

java.lang.Object
  extended byorg.springframework.remoting.rmi.RmiClientInterceptorUtils

public abstract class RmiClientInterceptorUtils
extends java.lang.Object

Factored-out methods for performing invocations within an RMI client. Can handle both RMI and non-RMI service interfaces working on an RMI stub.

Since:
1.1
Author:
Juergen Hoeller

Constructor Summary
RmiClientInterceptorUtils()
           
 
Method Summary
static java.lang.Exception convertRmiAccessException(java.lang.reflect.Method method, java.rmi.RemoteException ex, java.lang.String serviceName)
          Convert the given RemoteException that happened during remote access to Spring's RemoteAccessException if the method signature does not support RemoteException.
static java.lang.Exception convertRmiAccessException(java.lang.reflect.Method method, java.lang.Throwable ex, java.lang.String message)
          Wrap the given arbitrary exception that happened during remote access in either a RemoteException or a Spring RemoteAccessException (if the method signature does not support RemoteException).
static java.lang.Object doInvoke(org.aopalliance.intercept.MethodInvocation invocation, java.rmi.Remote stub)
          Perform a raw method invocation on the given RMI stub, letting reflection exceptions through as-is.
static java.lang.Object invoke(org.aopalliance.intercept.MethodInvocation invocation, java.rmi.Remote stub, java.lang.String serviceName)
          Apply the given method invocation to the given RMI stub.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RmiClientInterceptorUtils

public RmiClientInterceptorUtils()
Method Detail

invoke

public static java.lang.Object invoke(org.aopalliance.intercept.MethodInvocation invocation,
                                      java.rmi.Remote stub,
                                      java.lang.String serviceName)
                               throws java.lang.Throwable
Apply the given method invocation to the given RMI stub.

Delegate to the corresponding method if the RMI stub does not directly implemented the invoked method. This typically happens when a non-RMI service interface is used for an RMI service. The methods of such a service interface have to match the RMI stub methods, but they typically don't declare java.rmi.RemoteException: A RemoteException thrown by the RMI stub will be automatically converted to Spring's RemoteAccessException.

Parameters:
invocation - the AOP MethodInvocation
stub - the RMI stub
serviceName - the name of the service (for debugging purposes)
Returns:
the invocation result, if any
Throws:
java.lang.Throwable - exception to be thrown to the caller
See Also:
RemoteException, RemoteAccessException

doInvoke

public static java.lang.Object doInvoke(org.aopalliance.intercept.MethodInvocation invocation,
                                        java.rmi.Remote stub)
                                 throws java.lang.NoSuchMethodException,
                                        java.lang.IllegalAccessException,
                                        java.lang.reflect.InvocationTargetException
Perform a raw method invocation on the given RMI stub, letting reflection exceptions through as-is.

Parameters:
invocation - the AOP MethodInvocation
stub - the RMI stub
Returns:
the invocation result, if any
Throws:
java.lang.NoSuchMethodException - if thrown by reflection
java.lang.IllegalAccessException - if thrown by reflection
java.lang.reflect.InvocationTargetException - if thrown by reflection

convertRmiAccessException

public static java.lang.Exception convertRmiAccessException(java.lang.reflect.Method method,
                                                            java.rmi.RemoteException ex,
                                                            java.lang.String serviceName)
Convert the given RemoteException that happened during remote access to Spring's RemoteAccessException if the method signature does not support RemoteException. Else, return the original RemoteException.

Parameters:
method - the invoked method
ex - the RemoteException that happended
serviceName - the name of the service (for debugging purposes)
Returns:
the exception to be thrown to the caller

convertRmiAccessException

public static java.lang.Exception convertRmiAccessException(java.lang.reflect.Method method,
                                                            java.lang.Throwable ex,
                                                            java.lang.String message)
Wrap the given arbitrary exception that happened during remote access in either a RemoteException or a Spring RemoteAccessException (if the method signature does not support RemoteException).

Only call this for remote access exceptions, not for exceptions thrown by the target service itself!

Parameters:
method - the invoked method
ex - the exception that happened, to be used as cause for the RemoteAccessException respectively RemoteException
message - the message for the RemoteAccessException respectively RemoteException
Returns:
the exception to be thrown to the caller


Copyright (C) 2003-2004 The Spring Framework Project.