Package org.djutils.rmi
Class RmiObject
java.lang.Object
java.rmi.server.RemoteObject
java.rmi.server.RemoteServer
java.rmi.server.UnicastRemoteObject
org.djutils.rmi.RmiObject
- All Implemented Interfaces:
Serializable
,Remote
- Direct Known Subclasses:
RmiEventListener
The RMIObject is an object that registers iteself in the RMI registry using a key by which it can be found. The class creates
the RMI registry when it does not exist yet.
Copyright (c) 2020-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUTILS License.
- Author:
- Alexander Verbraeck
- See Also:
-
Field Summary
Fields inherited from class java.rmi.server.RemoteObject
ref
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the registry in which this object has been bound, e.g., to look up other objects in the registry.protected void
Register this object in the RMI registry.Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, exportObject, exportObject, unexportObject
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
-
Constructor Details
-
RmiObject
Register this object in the RMI registry. When the host has not been specified in the URL, 127.0.0.1 will be used. When the port has not been specified in the URL, the default RMI port 1099 will be used. When the RMI registry does not exist yet, it will be created, but only on the local host. Remote creation of a registry on another computer is not possible. Any attempt to do so will cause an AccessException to be fired.- Parameters:
registryURL
- URL; the URL of the registry, e.g., "http://localhost:1099" or "http://130.161.185.14:28452"bindingKey
- String; the key under which this object will be bound in the RMI registry- Throws:
RemoteException
- when there is a problem with the RMI registryAlreadyBoundException
- when there is already another object bound to the bindingKeyNullPointerException
- when registryURL or bindingKey is nullAccessException
- when there is an attempt to create a registry on a remote host
-
RmiObject
public RmiObject(String host, int port, String bindingKey) throws RemoteException, AlreadyBoundException Register this object in the RMI registry. When the RMI registry does not exist yet, it will be created, but only on the local host. Remote creation of a registry on another computer is not possible. Any attempt to do so will cause an AccessException to be fired.- Parameters:
host
- String; the host where the RMI registry resides or will be created. Creation is only possible on localhost.port
- int; the port where the RMI registry can be found or will be createdbindingKey
- String; the key under which this object will be bound in the RMI registry- Throws:
RemoteException
- when there is a problem with the RMI registryAlreadyBoundException
- when there is already another object bound to the bindingKeyNullPointerException
- when host, path, or bindingKey is nullIllegalArgumentException
- when port < 0 or port > 65535AccessException
- when there is an attempt to create a registry on a remote host
-
-
Method Details
-
register
protected void register(String host, int port, String bindingKey) throws RemoteException, AlreadyBoundException Register this object in the RMI registry. When the RMI registry does not exist yet, it will be created, but only on the local host. Remote creation of a registry on another computer is not possible. Any attempt to do so will cause an AccessException to be fired.- Parameters:
host
- String; the host where the RMI registry resides or will be created. Creation is only possible on localhost.port
- int; the port where the RMI registry can be found or will be createdbindingKey
- String; the key under which this object will be bound in the RMI registry- Throws:
RemoteException
- when there is a problem with the RMI registryAlreadyBoundException
- when there is already another object bound to the bindingKeyAccessException
- when there is an attempt to create a registry on a remote host
-
getRegistry
Returns the registry in which this object has been bound, e.g., to look up other objects in the registry.- Returns:
- Registry; the registry in which this object has been bound
- Throws:
RemoteException
- on network error
-