This class is the main enclosing coordinator for RMI connections.
An instance of this class can be created using the RMIOptions class.
The connection class holds information required for the RMI runtime to operate, and is the main representation of the local endpoint of a RMI connection.
Objects in an RMI connection can be used via the RMIVariables class which provide the functionality for
creating remote objects and invoking methods. New or existing instances of variable contexts can be retrieved via the
newVariables() or getVariables(
Context variables can be added to an RMI connection, which are basically named global variables present in a
connection. Clients of a connection can use these names to retrieve objects from the other endpoin. This is often
useful when an RMI server provides a specific functionality via an interface and clients want to get the remote
object to call the given functions on. See putContextVariable(
The RMI connections need to be closed after being used. The closing may be synchronous or asynchronous based on the caller. If the close() method is being called through and RMI invocation, then the connection will be closed asynchronously.
I/O error listener interface to get notified about connection errors.
|public static final int|
The protocol version of the first RMI library release.
|public static final short|
PROTOCOL_VERSION_LATEST = (short)1
The latest protocol version.
Adds an I/O error listener to this connection.
Marks the RMI connection as closed.
Closes the RMI connection and waits for the pending requests to be finished.
Gets the ClassLoaderResolver instance used by this RMI connection.
Gets a previously set named variable on this side of the RMI connection.
Gets or creates a variables context for the given name.
Checks if this connection is about to be closed, and should no longer be used.
Check if the connection is still in a valid state.
|public static boolean|
Checks if the argument is a remote proxy object.
|public static boolean|
Checks if the argument objects are both remote proxies and are used with the same RMI variables context.
Creates a new unnamed variables context in this connection.
Sets a named variable for this RMI connection.
Removes a previously added error listener.
The listener is called when I/O errors are detected in the connection.
If an I/O error was already detected, then the listener will be called before this method returns.
When an I/O error occurs, the listeners are called, and this connection will remove all installed listeners.
Closing an RMI connection does not happen immediately, calling this method only signals the connection to be closed when the last pending request finishes.
To wait for the pending requests to finish, call closeWait().
If any request is made to any of the proxy objects in this connection after closing, the request may succeed, or an appropriate RMIRuntimeException may be thrown.
Callers should ensure that no requests are running in the system before calling this method. This often requires external synchronization by the user.
Only local variables are retrieved and no RMI request is made to the other endpoint.
nullif it is not set.
Named variables are present on both endpoint with a specific name. They can be used to access predetermined variables to encapsulate different parts of code.
The returned variables instance need to be closed for each call of getVariables(
If a named variables has been retrieved, and later closed, a new instance for the name can be retrieved again. I.e. the names are reuseable.
A connection is aborting, if there were any I/O errors, or it was explicitly closed, but the closing cannot be done synchronously.
trueif the connection is aborting.
This method will return false if any I/O errors are detected, or the connection has been closed.
This method checks if the object is created by the RMI library, and calls to it will be dispatched over an RMI connection. As this is a static method, it doesn't check if it belongs to any specific RMI connection, but only checks if the objects is remote.
Calling this method has the same performance cost as an
trueif the argument is a remote proxy.
trueif both objects are remote, and bound to the same RMI variables context.
Named variables can be used to retrieve pre-defined objects remotely. If a connection is supposed to be utilized for a specific task then setting a variable on the server side can make it easy for the client to establish the communication.
Any previously set variable with the same name will be overwritten. Setting
null will remove the
It is recommended that context variables have an interface which can be used to retrieve on the other side.
nullto remove the current object.