Package eu.tneitzel.rmg.utils
Class UnicastWrapper
- java.lang.Object
-
- eu.tneitzel.rmg.utils.RemoteObjectWrapper
-
- eu.tneitzel.rmg.utils.UnicastWrapper
-
- Direct Known Subclasses:
SpringRemotingWrapper
public class UnicastWrapper extends RemoteObjectWrapper
The UnicastWrapper class extends RemoteObjectWrapper and is used for wrapping UnicastRef.- Author:
- Tobias Neitzel (@qtc_de)
-
-
Field Summary
Fields Modifier and Type Field Description RMIClientSocketFactorycsfassociated RMIClientSocketFactoryList<UnicastWrapper>duplicateslist of bound names implementing the same interfacesun.rmi.transport.tcp.TCPEndpointendpointassociated TCPEndpointObjIDobjIDassociated ObjIDRMIServerSocketFactoryssfassociated RMIServerSocketFactorysun.rmi.server.UnicastRefunicastRefassociated UnicastRef-
Fields inherited from class eu.tneitzel.rmg.utils.RemoteObjectWrapper
boundName, knownEndpoint, remoteObject
-
-
Constructor Summary
Constructors Constructor Description UnicastWrapper(Remote remoteObject, String boundName, sun.rmi.server.UnicastRef ref)Create a new UnicastWrapper from a RemoteObject.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDuplicate(UnicastWrapper o)Add a duplicate to the UnicastWrapper.static UnicastWrapperfromRef(sun.rmi.server.UnicastRef unicastRef, Class<?> intf)Create a new UnicastWrapper from a RemoteRef.String[]getDuplicateBoundNames()Iterates over the list of registered duplicates and returns the associated bound names as an array.StringgetHost()Returns the host name associated with the UnicastWrapper.intgetPort()Returns the port number associated with the UnicastWrapper.StringgetTarget()Returns a string that combines the host name and port in the 'host:port' notation.static UnicastWrapper[]handleDuplicates(UnicastWrapper[] list)Takes a list of UnicastWrapper and looks for duplicates within it.booleanhasDuplicates()Checks whether the Wrapper has any duplicates (other remote objects that implement the same remote interface).static booleanhasDuplicates(UnicastWrapper[] list)Takes a list of UnicastWrapper and checks whether one of them contains duplicates.-
Methods inherited from class eu.tneitzel.rmg.utils.RemoteObjectWrapper
fromBoundNames, getByName, getInstance, getInstance, getInterfaceName, getUnicastWrapper, getUnicastWrappers, isKnown
-
-
-
-
Field Detail
-
objID
public final ObjID objID
associated ObjID
-
endpoint
public final sun.rmi.transport.tcp.TCPEndpoint endpoint
associated TCPEndpoint
-
unicastRef
public final sun.rmi.server.UnicastRef unicastRef
associated UnicastRef
-
csf
public final RMIClientSocketFactory csf
associated RMIClientSocketFactory
-
ssf
public final RMIServerSocketFactory ssf
associated RMIServerSocketFactory
-
duplicates
public List<UnicastWrapper> duplicates
list of bound names implementing the same interface
-
-
Constructor Detail
-
UnicastWrapper
public UnicastWrapper(Remote remoteObject, String boundName, sun.rmi.server.UnicastRef ref) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException
Create a new UnicastWrapper from a RemoteObject. The third argument seems superfluous, as the UnicastRef is already contained within the remote object. However, UnicastWrappers should be created by using the getInstance method of RemoteObjectWrapper. This one extracts the reference from the remote object anyway to check whether it is a UnicastRef or ActivatableRef. Therefore, we can reuse this extracted ref instead of performing another extraction.- Parameters:
remoteObject- Incoming RemoteObject, usually obtained by an RMI lookup callboundName- The bound name that the remoteObject uses inside the RMI registryref- UnicastRef to build the wrapper around- Throws:
IllegalArgumentException- if reflective access failsIllegalAccessException- if reflective access failsNoSuchFieldException- if reflective access failsSecurityException- if reflective access fails
-
-
Method Detail
-
getHost
public String getHost()
Returns the host name associated with the UnicastWrapper.- Returns:
- host name the Wrapper is pointing to
-
getPort
public int getPort()
Returns the port number associated with the UnicastWrapper.- Returns:
- port number the Wrapper is pointing to
-
getTarget
public String getTarget()
Returns a string that combines the host name and port in the 'host:port' notation.- Returns:
- host:port the Wrapper is pointing to
-
hasDuplicates
public boolean hasDuplicates()
Checks whether the Wrapper has any duplicates (other remote objects that implement the same remote interface).- Returns:
- true if duplicates are present
-
addDuplicate
public void addDuplicate(UnicastWrapper o)
Add a duplicate to the UnicastWrapper. This should be a wrapper that implements the same remote interface as the original wrapper.- Parameters:
o- duplicate UnicastWrapper that implements the same remote interface
-
getDuplicateBoundNames
public String[] getDuplicateBoundNames()
Iterates over the list of registered duplicates and returns the associated bound names as an array.- Returns:
- array of String that contains duplicate bound names
-
fromRef
public static UnicastWrapper fromRef(sun.rmi.server.UnicastRef unicastRef, Class<?> intf) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException
Create a new UnicastWrapper from a RemoteRef. This function creates a Proxy that implements the specified interface and uses a RemoteObjectInvocationHandler to forward method invocations to the specified RemoteRef. The boundname property that is part of each UnicastWrapper is set to the ObjID of the remote object.- Parameters:
unicastRef- UnicastRef to the targeted RemoteObjectintf- Interface that is implemented by the RemoteObject- Returns:
- UnicastWrapper created from the specified UnicastRef
- Throws:
IllegalArgumentException- if reflective access failsIllegalAccessException- if reflective access failsNoSuchFieldException- if reflective access failsSecurityException- if reflective access fails
-
handleDuplicates
public static UnicastWrapper[] handleDuplicates(UnicastWrapper[] list)
Takes a list of UnicastWrapper and looks for duplicates within it. The return value is a list of unique UnicastWrapper that have the corresponding duplicates assigned.- Parameters:
list- UnicastWrapper to search for duplicates- Returns:
- Unique UnicastWrapper with duplicates assigned
-
hasDuplicates
public static boolean hasDuplicates(UnicastWrapper[] list)
Takes a list of UnicastWrapper and checks whether one of them contains duplicates.- Parameters:
list- UnicastWrapper to check for duplicates- Returns:
- true if at least one UnicastWrapper contains a duplicate
-
-