Class RmiObject

All Implemented Interfaces:
Serializable, Remote
Direct Known Subclasses:
RmiEventListener

public class RmiObject extends UnicastRemoteObject
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:
  • Constructor Details

    • RmiObject

      public RmiObject(URL registryURL, String bindingKey) throws RemoteException, AlreadyBoundException
      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 registry
      AlreadyBoundException - when there is already another object bound to the bindingKey
      NullPointerException - when registryURL or bindingKey is null
      AccessException - 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 created
      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 registry
      AlreadyBoundException - when there is already another object bound to the bindingKey
      NullPointerException - when host, path, or bindingKey is null
      IllegalArgumentException - when port < 0 or port > 65535
      AccessException - 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 created
      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 registry
      AlreadyBoundException - when there is already another object bound to the bindingKey
      AccessException - when there is an attempt to create a registry on a remote host
    • getRegistry

      public Registry getRegistry() throws RemoteException
      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