Package eu.tneitzel.rmg.networking
Class RMIRegistryEndpoint
- java.lang.Object
-
- eu.tneitzel.rmg.networking.RMIEndpoint
-
- eu.tneitzel.rmg.networking.RMIRegistryEndpoint
-
public class RMIRegistryEndpoint extends RMIEndpoint
The RMIRegistryEndpoint represents an RMI Registry endpoint on the remote server. The class can be used to perform some more high level RMI registry access like list and lookup operations. However, as it extends RMIEndpoint, all low level RMI functionality is also available.- Author:
- Tobias Neitzel (@qtc_de)
-
-
Field Summary
-
Fields inherited from class eu.tneitzel.rmg.networking.RMIEndpoint
csf, host, port
-
-
Constructor Summary
Constructors Constructor Description RMIRegistryEndpoint(RMIEndpoint rmi)Alternative constructor that creates the RMIRegistryEndpoint from an already existing RMIEndpoint.RMIRegistryEndpoint(String host, int port)The main purpose of this constructor function is to setup the different socket factories.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String[]getBoundNames()If a bound name was specified on the command line, return this bound name immediately.RemotegetFromCache(String boundName)Return the Remote for the specified bound name from cache or null if it is not available.Remotelookup(String boundName)Just a wrapper around the lookup method of the RMI registry.Remote[]lookup(String[] boundNames)Performs the RMI registries lookup operation to obtain a remote reference for the specified bound names.RemotelookupWithRetries(String boundName, int maxRetries)It was observed that using --serial-version-uid option can cause an invalid transport return code exception during lookup.RemoteObjectWrapperlookupWrapper(String boundName)Same as the lookup action, but returns a RemoteObjectWrapper.RemoteObjectWrapper[]lookupWrappers(String[] boundNames)Same as the lookup action, but returns an array of RemoteObjectWrapper.-
Methods inherited from class eu.tneitzel.rmg.networking.RMIEndpoint
genericCall, genericCall, genericCall, getRemoteRef, guessingCall, unmanagedCall
-
-
-
-
Constructor Detail
-
RMIRegistryEndpoint
public RMIRegistryEndpoint(String host, int port)
The main purpose of this constructor function is to setup the different socket factories. During the initial connect to the registry, a socket factory can be specified manually and will be used. This is done by the RMIEndpoint class already. However, for the communication to looked up remote objects, the socket factory that was configured on the server side will be used. For most cases this will be either RMISocketFactory or SslRMIClientSocketFactory. To implement stuff like automatic redirection, we need to overwrite the default implementations of these classes. This is done by this constructor.- Parameters:
host- RMI registry hostport- RMI registry port
-
RMIRegistryEndpoint
public RMIRegistryEndpoint(RMIEndpoint rmi)
Alternative constructor that creates the RMIRegistryEndpoint from an already existing RMIEndpoint.- Parameters:
rmi- RMIEndpoint
-
-
Method Detail
-
getBoundNames
public String[] getBoundNames() throws NoSuchObjectException
If a bound name was specified on the command line, return this bound name immediately. Otherwise, obtain a list of bound names from the RMI registry. This is basically a wrapper around the list function of the RMI registry, but has error handling implemented.- Returns:
- String array of available bound names.
- Throws:
NoSuchObjectException- if the remote endpoint is not an RMI registry
-
lookup
public Remote[] lookup(String[] boundNames) throws UnmarshalException
Performs the RMI registries lookup operation to obtain a remote reference for the specified bound names. The main benefit of using this method is, that it performs exception handling.- Parameters:
boundNames- list of bound names to determine the classes from- Returns:
- List of remote objects looked up from the remote registry
- Throws:
UnmarshalException- if unmarshaling the return value fails
-
lookup
public Remote lookup(String boundName) throws UnmarshalException
Just a wrapper around the lookup method of the RMI registry. Performs exception handling and caches remote objects that have already been looked up.- Parameters:
boundName- name to lookup within the registry- Returns:
- Remote representing the requested remote object
- Throws:
UnmarshalException- if unmarshalling the return value fails
-
lookupWithRetries
public Remote lookupWithRetries(String boundName, int maxRetries)
It was observed that using --serial-version-uid option can cause an invalid transport return code exception during lookup. This seems to be some kind of race condition and cannot be reproduced reliably. We currently believe that RMI / Java does not clear the ObjectInput stream when reading an unknown class from it. The remaining bytes are left within the stream. Since RMI uses connection pooling, the next operation encounters the invalid bytes and fails. If this is the case, we just retry a few times.- Parameters:
boundName- the bound name to lookupmaxRetries- the maximum amount of retries to perform- Returns:
- Remote object if lookup was successful. null otherwise.
-
lookupWrapper
public RemoteObjectWrapper lookupWrapper(String boundName)
Same as the lookup action, but returns a RemoteObjectWrapper.- Parameters:
boundName- name to lookup within the registry- Returns:
- RemoteObjectWrapper for the remote object
-
lookupWrappers
public RemoteObjectWrapper[] lookupWrappers(String[] boundNames)
Same as the lookup action, but returns an array of RemoteObjectWrapper.- Parameters:
boundNames- names to lookup within the registry- Returns:
- RemoteObjectWrapper for the remote object
-
-