Package org.springframework.remoting.rmi
Class RmiClientInterceptorUtils
- java.lang.Object
- org.springframework.remoting.rmi.RmiClientInterceptorUtils
public abstract class RmiClientInterceptorUtils extends 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.Note: This is an SPI class, not intended to be used by applications.
- Since:
- 1.1
- Author:
- Juergen Hoeller
Constructor Summary
Constructors Constructor Description RmiClientInterceptorUtils()
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Exception
convertRmiAccessException(Method method, Throwable ex, 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 Exception
convertRmiAccessException(Method method, RemoteException ex, boolean isConnectFailure, String serviceName)
Convert the given RemoteException that happened during remote access to Spring's RemoteAccessException if the method signature does not support RemoteException.static Exception
convertRmiAccessException(Method method, RemoteException ex, String serviceName)
Convert the given RemoteException that happened during remote access to Spring's RemoteAccessException if the method signature does not support RemoteException.static Object
invokeRemoteMethod(MethodInvocation invocation, Object stub)
Perform a raw method invocation on the given RMI stub, letting reflection exceptions through as-is.static boolean
isConnectFailure(RemoteException ex)
Determine whether the given RMI exception indicates a connect failure.
Constructor Detail
RmiClientInterceptorUtils
public RmiClientInterceptorUtils()
Method Detail
invokeRemoteMethod
@Nullable public static Object invokeRemoteMethod(MethodInvocation invocation, Object stub) throws InvocationTargetException
Perform a raw method invocation on the given RMI stub, letting reflection exceptions through as-is.- Parameters:
invocation
- the AOP MethodInvocationstub
- the RMI stub- Returns:
- the invocation result, if any
- Throws:
InvocationTargetException
- if thrown by reflection
convertRmiAccessException
public static Exception convertRmiAccessException(Method method, Throwable ex, 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 methodex
- the exception that happened, to be used as cause for the RemoteAccessException or RemoteExceptionmessage
- the message for the RemoteAccessException respectively RemoteException- Returns:
- the exception to be thrown to the caller
convertRmiAccessException
public static Exception convertRmiAccessException(Method method, RemoteException ex, 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 methodex
- the RemoteException that happenedserviceName
- the name of the service (for debugging purposes)- Returns:
- the exception to be thrown to the caller
convertRmiAccessException
public static Exception convertRmiAccessException(Method method, RemoteException ex, boolean isConnectFailure, 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 methodex
- the RemoteException that happenedisConnectFailure
- whether the given exception should be considered a connect failureserviceName
- the name of the service (for debugging purposes)- Returns:
- the exception to be thrown to the caller
isConnectFailure
public static boolean isConnectFailure(RemoteException ex)
Determine whether the given RMI exception indicates a connect failure.Treats RMI's ConnectException, ConnectIOException, UnknownHostException, NoSuchObjectException and StubNotFoundException as connect failure.
- Parameters:
ex
- the RMI exception to check- Returns:
- whether the exception should be treated as connect failure
- See Also:
ConnectException
,ConnectIOException
,UnknownHostException
,NoSuchObjectException
,StubNotFoundException