Package eu.tneitzel.rmg.utils
Class RemoteObjectWrapper
- java.lang.Object
-
- eu.tneitzel.rmg.utils.RemoteObjectWrapper
-
- Direct Known Subclasses:
ActivatableWrapper,EmptyWrapper,UnicastWrapper
public abstract class RemoteObjectWrapper extends Object
The RemoteObjectWrapper class represents a wrapper around the ordinary RMI remote object related classes. It stores the basic information that is required to use the remote object as usual, but adds additional fields that allow to obtain meta information more easily. From remote-method-guesser v4.3.0 on, the class gets extended by the UnicastWrapper and ActivatableWrapper classes. As the names suggest, UnicastWrapper is used to wrap remote objects that contain a UnicastRef, whereas ActivatableWrapper is used for wrapping ActivatabaseRef types.- Author:
- Tobias Neitzel (@qtc_de)
-
-
Field Summary
Fields Modifier and Type Field Description StringboundNameassociated boundNameKnownEndpointknownEndpointassociated knownEndpointRemoteremoteObjectassociated Remote
-
Constructor Summary
Constructors Constructor Description RemoteObjectWrapper(String boundName)This constructor is only used for special purposes during the enum action.RemoteObjectWrapper(String boundName, Remote remoteObject)Partially initializes a wrapper.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RemoteObjectWrapper[]fromBoundNames(String[] boundNames)Creates an array of RemoteObjectWrapper from an array of bound names.static RemoteObjectWrappergetByName(String boundName, RemoteObjectWrapper[] list)Searches a supplied list of RemoteObjectWrapper objects for the Wrapper that is associated to the specified bound name.static RemoteObjectWrappergetInstance(Remote remote)Create a RemoteObjectWrapper for the specified Remote.static RemoteObjectWrappergetInstance(Remote remote, String boundName)Create a RemoteObjectWrapper for the specified Remote.StringgetInterfaceName()Return the interface name that is implemented by the remote object.UnicastWrappergetUnicastWrapper()Transform an RemoteObjectWrapper into a UnicastWrapper.static UnicastWrapper[]getUnicastWrappers(RemoteObjectWrapper[] wrappers)Transform an array of RemoteObjectWrapper into an array of UnicastWrapper.booleanisKnown()Check whether the endpoint is a known endpoint.
-
-
-
Field Detail
-
boundName
public String boundName
associated boundName
-
remoteObject
public Remote remoteObject
associated Remote
-
knownEndpoint
public KnownEndpoint knownEndpoint
associated knownEndpoint
-
-
Constructor Detail
-
RemoteObjectWrapper
public RemoteObjectWrapper(String boundName)
This constructor is only used for special purposes during the enum action. The resulting RemoteObjectWrapper is not fully functional and should not be used for other purposes than displaying the bound name.- Parameters:
boundName- as used in the RMI registry
-
RemoteObjectWrapper
public RemoteObjectWrapper(String boundName, Remote remoteObject)
Partially initializes a wrapper. This constructor goes already a little bit deeper than the previous one by also assigning the remote object, checking for the implementing class and whether it is a duplicate. However, this constructor should still only be used by subclasses that add the missing fields.- Parameters:
boundName- bound name as used in the RMI registryremoteObject- the corresponding remote object
-
-
Method Detail
-
getInstance
public static RemoteObjectWrapper getInstance(Remote remote) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException
Create a RemoteObjectWrapper for the specified Remote. See the extended version of the function below for more information.- Parameters:
remote- remote to create the wrapper for- Returns:
- RemoteObjectWrapper for the specified remote
- Throws:
IllegalArgumentException- if reflective access failsIllegalAccessException- if reflective access failsNoSuchFieldException- if reflective access failsSecurityException- if reflective access fails
-
getInstance
public static RemoteObjectWrapper getInstance(Remote remote, String boundName) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException
Create a RemoteObjectWrapper for the specified Remote. This function uses reflection to inspect the reference type of the specified Remote. If it is a UnicastRef, a UnicastWrapper is returned. Otherwise, an ActivatableWrapper is returned.- Parameters:
remote- remote to create the wrapper forboundName- bound name as specified in the RMI registry- Returns:
- RemoteObjectWrapper - Either a UnicastWrapper or a ActivatableWrapper depending on the Remote
- Throws:
IllegalArgumentException- if reflective access failsIllegalAccessException- if reflective access failsNoSuchFieldException- if reflective access failsSecurityException- if reflective access fails
-
getByName
public static RemoteObjectWrapper getByName(String boundName, RemoteObjectWrapper[] list)
Searches a supplied list of RemoteObjectWrapper objects for the Wrapper that is associated to the specified bound name.- Parameters:
boundName- associated bound name to look forlist- RemoteObjectWrapper objects to search in- Returns:
- RemoteObjectWrapper that matches the specified bound name or null
-
fromBoundNames
public static RemoteObjectWrapper[] fromBoundNames(String[] boundNames)
Creates an array of RemoteObjectWrapper from an array of bound names. The resulting RemoteObjectWrappers are dummy objects that just contain the associated bound name. This should only be used during rmg's enum action to display bound names using the Formatter class.- Parameters:
boundNames- Array of String to create the RemoteObjectWrapper from- Returns:
- Array of RemoteObjectWrapper associated to the specified bound names
-
isKnown
public boolean isKnown()
Check whether the endpoint is a known endpoint.- Returns:
- True of the endpoint is known.
-
getInterfaceName
public String getInterfaceName()
Return the interface name that is implemented by the remote object.- Returns:
- interface name implemented by the remote object
-
getUnicastWrapper
public UnicastWrapper getUnicastWrapper()
Transform an RemoteObjectWrapper into a UnicastWrapper. If the RemoteObjectWrapper is already a UnicastWrapper, it is simply returned. If it is an ActivatableWrapper instead, it is activated.- Returns:
- UnicastWrapper
-
getUnicastWrappers
public static UnicastWrapper[] getUnicastWrappers(RemoteObjectWrapper[] wrappers)
Transform an array of RemoteObjectWrapper into an array of UnicastWrapper. If an element is already a UnicastWrapper, it is simply returned. ActivatableWrappers, on the other hand, are activated to create a UnicastWrapper.- Parameters:
wrappers- RemoteObjectWrapper array- Returns:
- Array of associated UnicastWrappers
-
-