Package eu.tneitzel.rmg.utils
Class SpringRemotingWrapper
- java.lang.Object
-
- eu.tneitzel.rmg.utils.RemoteObjectWrapper
-
- eu.tneitzel.rmg.utils.UnicastWrapper
-
- eu.tneitzel.rmg.utils.SpringRemotingWrapper
-
public class SpringRemotingWrapper extends UnicastWrapper
SpringRemoting represents a wrapper around regular Java RMI. Exposed methods are not directly available via RemoteObjects, but are invoked using a dispatcher object that supports an invoke method. This class contains functions to convert an ordinary RMI method call into a SpringRemoting call.- Author:
- Tobias Neitzel (@qtc_de)
-
-
Field Summary
Fields Modifier and Type Field Description static StringinvocationHandlerClassclass name of the RmiInvocationHandler classstatic StringmethodGetStrmethod signature of the getTargetInterfaceName methodstatic StringmethodInvokeStrmethod signature of the invoke method-
Fields inherited from class eu.tneitzel.rmg.utils.UnicastWrapper
csf, duplicates, endpoint, objID, ssf, unicastRef
-
Fields inherited from class eu.tneitzel.rmg.utils.RemoteObjectWrapper
boundName, knownEndpoint, remoteObject
-
-
Constructor Summary
Constructors Constructor Description SpringRemotingWrapper(Remote remoteObject, String boundName, sun.rmi.server.UnicastRef ref)Within it's constructor, SpringRemotingWrapper already sends an RMI call to the server using the getTargetInterfaceName method.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static org.springframework.remoting.support.RemoteInvocationbuildRemoteInvocation(MethodCandidate targetMethod, Object[] args)Prepare a RemoteInvocation object from a MethodCandidate and the user specified arguments.static booleancontainsSpringRemotingClient(UnicastWrapper[] wrappers)Helper function that checks whether a list of UnicastWrapper objects contains a SpringRemotingWrapper (which is a child class of UnicastWrapper).StringgetInterfaceName()Return the interface name of the underlying interface class that can be accessed via spring remoting.static MethodCandidategetInterfaceNameMethod()Return a MethodCandidate for the getTargetInterfaceName method that is exposed by the RmiInvocationHandler remote object.static Set<RemoteInvocationHolder>getInvocationHolders(Set<MethodCandidate> candidates)Transform a set of MethodCandidate to a set of RemoteInvocationHolders.static MethodCandidategetInvokeMethod()Return a MethodCandidate for the invoke method that is exposed by the RmiInvocationHandler remote object.static StringgetSignature(MethodCandidate method)Returns a method signature for the specified MethodCandidate that lacks the return value.booleanisRemotingCall(MethodCandidate targetMethod)Determines whether the method to call is a known spring remoting method, that needs to be processed by the remoting wrapper itself, or whether it is an RMI method implemented by the underlying object.-
Methods inherited from class eu.tneitzel.rmg.utils.UnicastWrapper
addDuplicate, fromRef, getDuplicateBoundNames, getHost, getPort, getTarget, handleDuplicates, hasDuplicates, hasDuplicates
-
Methods inherited from class eu.tneitzel.rmg.utils.RemoteObjectWrapper
fromBoundNames, getByName, getInstance, getInstance, getUnicastWrapper, getUnicastWrappers, isKnown
-
-
-
-
Field Detail
-
invocationHandlerClass
public static final String invocationHandlerClass
class name of the RmiInvocationHandler class- See Also:
- Constant Field Values
-
methodGetStr
public static final String methodGetStr
method signature of the getTargetInterfaceName method- See Also:
- Constant Field Values
-
methodInvokeStr
public static final String methodInvokeStr
method signature of the invoke method- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SpringRemotingWrapper
public SpringRemotingWrapper(Remote remoteObject, String boundName, sun.rmi.server.UnicastRef ref) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException
Within it's constructor, SpringRemotingWrapper already sends an RMI call to the server using the getTargetInterfaceName method. This is required to tell remote-method-guesser what the underlying interface class is. This information is displayed within the enum output and used for identifying potentialy known endpoints.- Parameters:
remoteObject- the spring remoting remoteObject obtained from the registryboundName- the boundName that is associated with the remoteObjectref- a UnicastRef that can be used to call methods on the remoteObject- Throws:
IllegalArgumentException- if reflective access failsIllegalAccessException- if reflective access failsNoSuchFieldException- if reflective access failsSecurityException- if reflective access fails
-
-
Method Detail
-
getInterfaceNameMethod
public static MethodCandidate getInterfaceNameMethod()
Return a MethodCandidate for the getTargetInterfaceName method that is exposed by the RmiInvocationHandler remote object.- Returns:
- method candidate for the getTargetInterfaceName method
-
getInvokeMethod
public static MethodCandidate getInvokeMethod()
Return a MethodCandidate for the invoke method that is exposed by the RmiInvocationHandler remote object.- Returns:
- method candidate for the invoke method
-
isRemotingCall
public boolean isRemotingCall(MethodCandidate targetMethod)
Determines whether the method to call is a known spring remoting method, that needs to be processed by the remoting wrapper itself, or whether it is an RMI method implemented by the underlying object.- Parameters:
targetMethod- the method to check- Returns:
- true if the method needs to be dispatched using spring remoting
-
getInterfaceName
public String getInterfaceName()
Return the interface name of the underlying interface class that can be accessed via spring remoting.- Overrides:
getInterfaceNamein classRemoteObjectWrapper- Returns:
- interface name implemented by the underlying remote object
-
buildRemoteInvocation
public static org.springframework.remoting.support.RemoteInvocation buildRemoteInvocation(MethodCandidate targetMethod, Object[] args)
Prepare a RemoteInvocation object from a MethodCandidate and the user specified arguments. The resulting object can be passed to the spring remoting endpoint in order to call the specified MethodCandidate.- Parameters:
targetMethod- method that should be called via spring remotingargs- arguments that should be used for the call- Returns:
- RemoteInvocation that can be passed to the spring remoting server
-
getInvocationHolders
public static Set<RemoteInvocationHolder> getInvocationHolders(Set<MethodCandidate> candidates)
Transform a set of MethodCandidate to a set of RemoteInvocationHolders.- Parameters:
candidates- v set of MethodCandidate to transform- Returns:
- set of RemoteInvocationHolders
-
getSignature
public static String getSignature(MethodCandidate method)
Returns a method signature for the specified MethodCandidate that lacks the return value. The return value is replaced with three question marks. The reason is that spring remoting treats similar methods with different return values the same. Therefore, it is not possible to determine the return value of a successfully guessed method.- Parameters:
method- MethodCandidate to obtain the modified signature from- Returns:
- modified signature without a return value
-
containsSpringRemotingClient
public static boolean containsSpringRemotingClient(UnicastWrapper[] wrappers)
Helper function that checks whether a list of UnicastWrapper objects contains a SpringRemotingWrapper (which is a child class of UnicastWrapper).- Parameters:
wrappers- list of UnicastWrapper objects- Returns:
- true if at least one SpringRemotingWrapper is contained within the list
-
-