Package org.djutils.rmi
Class RMIUtils
- java.lang.Object
- 
- org.djutils.rmi.RMIUtils
 
- 
 public final class RMIUtils extends Object RMIUtils contains a number of utilities to help with the RMI registry.Copyright (c) 2019-2021 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. 
 BSD-style license. See DJUTILS License.- Author:
- Alexander Verbraeck
 
- 
- 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static voidbind(Registry registry, String bindingKey, Remote object)Bind an object in the RMI registry.static voidcloseRegistry(Registry registry)Unbinds all the objects from the RMI registry and closes the registry.static RegistrygetRegistry(String host, int port)Lookup or create the RMI registry.static Remotelookup(Registry registry, String bindingKey)Lookup an object in the RMI registry.static voidrebind(Registry registry, String bindingKey, Remote newObject)Rebind an object to an existing string in the RMI registry.static voidunbind(Registry registry, String bindingKey)Unbind an object from the RMI registry.
 
- 
- 
- 
Method Detail- 
getRegistrypublic static Registry getRegistry(String host, int port) throws RemoteException Lookup or create 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 created
- Returns:
- Registry; the located or created RMI registry
- Throws:
- RemoteException- when there is a problem with locating or creating the RMI registry
- NullPointerException- when host is null
- IllegalArgumentException- when port ≤ 0 or port > 65535
- AccessException- when there is an attempt to create a registry on a remote host
 
 - 
bindpublic static void bind(Registry registry, String bindingKey, Remote object) throws RemoteException, AlreadyBoundException Bind an object in the RMI registry.- Parameters:
- registry- Registry; the RMI registry where the object will be bound using the key
- bindingKey- String; the key under which the object will be bound in the RMI registry
- object- Remote; the object that will be bound
- Throws:
- RemoteException- when there is a problem with the RMI registry
- AlreadyBoundException- when there is already another object bound to the bindingKey
- NullPointerException- when registry, bindingKey or object is null
- IllegalArgumentException- when bindingKey is the empty String
 
 - 
unbindpublic static void unbind(Registry registry, String bindingKey) throws RemoteException, NotBoundException Unbind an object from the RMI registry.- Parameters:
- registry- Registry; the RMI registry where the object will be bound using the key
- bindingKey- String; the key under which the object will be bound in the RMI registry
- Throws:
- RemoteException- when there is a problem with the RMI registry
- NotBoundException- when there is no object bound to the bindingKey
- NullPointerException- when registry or bindingKey is null
- IllegalArgumentException- when bindingKey is the empty String
 
 - 
rebindpublic static void rebind(Registry registry, String bindingKey, Remote newObject) throws RemoteException Rebind an object to an existing string in the RMI registry.- Parameters:
- registry- Registry; the RMI registry where the object will be bound using the key
- bindingKey- String; the (existing) key under which the new object will be bound in the RMI registry
- newObject- Remote; the new object that will be bound
- Throws:
- RemoteException- when there is a problem with the RMI registry
- NullPointerException- when registry, bindingKey or newObject is null
- IllegalArgumentException- when bindingKey is the empty String
 
 - 
lookuppublic static Remote lookup(Registry registry, String bindingKey) throws RemoteException, NotBoundException Lookup an object in the RMI registry.- Parameters:
- registry- Registry; the RMI registry in which the object will be looked up using the key
- bindingKey- String; the key under which the object should be registered in the RMI registry
- Returns:
- Remote; the remote object that bound to the key in the RMI registry
- Throws:
- RemoteException- when there is a problem with the RMI registry
- NotBoundException- when there is no object bound to the bindingKey
- NullPointerException- when registry or bindingKey is null
- IllegalArgumentException- when bindingKey is the empty String
 
 - 
closeRegistrypublic static void closeRegistry(Registry registry) throws RemoteException Unbinds all the objects from the RMI registry and closes the registry.- Parameters:
- registry- Registry; the RMI registry that will unbind all the objects and close.
- Throws:
- RemoteException- when there is a problem with the RMI registry
- NullPointerException- when registry is null
 
 
- 
 
-