Package ucb.util

Class SimpleObjectRegistry

java.lang.Object
ucb.util.SimpleObjectRegistry

public class SimpleObjectRegistry extends Object
A kind of registry that provides a very simple means of exchanging remote objects by name. One can create a registry, allowing the constructor to select an available port. One can find a bound object by name over a sequence of port numbers and hosts.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The default values for LOWPORT and HIGHPORT arguments.
    static final int
    The default values for LOWPORT and HIGHPORT arguments.
    static final int
    The default values for LOWPORT and HIGHPORT arguments.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Same as SimpleObjectRegistry(DEFAULT_LOW_PORT, DEFAULT_HIGH_PORT).
    Return SimpleObjectRegistry(PORT, PORT).
    SimpleObjectRegistry(int lowPort, int highPort)
    Create a new SimpleObjectRegistry on one of the ports LOWPORT to HIGHPORT, if possible.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Remove all bindings from this registry, and disable it from further use.
    static Remote
    findObject(String name, String host)
    Return findObject(NAME, HOST, DEFAULT_LOW_PORT, DEFAULT_HIGH_PORT).
    static Remote
    findObject(String name, String[] hosts)
    Return findObject(NAME, HOSTS, DEFAULT_LOW_PORT, DEFAULT_HIGH_PORT).
    static Remote
    findObject(String name, String[] hosts, int lowPort, int highPort)
    Return a remote object named NAME in some registry on one of the hosts in HOSTS on some port number between LOWPORT and HIGHPORT.
    static Remote
    findObject(String name, String host, int lowPort, int highPort)
    Return a remote object named NAME in some registry on HOST on some port number between LOWPORT and HIGHPORT.
    int
    Return the port number on which this registry is exported.
    void
    rebind(String name, Remote value)
    Bind NAME to VALUE in this registry, replacing any existing binding.
    void
    Remove all bindings in this registry.
    void
    unbind(String name)
    Remove any binding of NAME in this registry.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_PORTS

      public static final int DEFAULT_PORTS
      The default values for LOWPORT and HIGHPORT arguments.
      See Also:
    • DEFAULT_LOW_PORT

      public static final int DEFAULT_LOW_PORT
      The default values for LOWPORT and HIGHPORT arguments.
      See Also:
    • DEFAULT_HIGH_PORT

      public static final int DEFAULT_HIGH_PORT
      The default values for LOWPORT and HIGHPORT arguments.
      See Also:
  • Constructor Details

    • SimpleObjectRegistry

      public SimpleObjectRegistry(int lowPort, int highPort) throws RemoteException
      Create a new SimpleObjectRegistry on one of the ports LOWPORT to HIGHPORT, if possible. Throws RemoteException if no registry can be created on any of these ports.
      Throws:
      RemoteException
    • SimpleObjectRegistry

      public SimpleObjectRegistry(int port) throws RemoteException
      Return SimpleObjectRegistry(PORT, PORT).
      Throws:
      RemoteException
    • SimpleObjectRegistry

      public SimpleObjectRegistry() throws RemoteException
      Same as SimpleObjectRegistry(DEFAULT_LOW_PORT, DEFAULT_HIGH_PORT).
      Throws:
      RemoteException
  • Method Details

    • findObject

      public static Remote findObject(String name, String host, int lowPort, int highPort) throws NotBoundException
      Return a remote object named NAME in some registry on HOST on some port number between LOWPORT and HIGHPORT. Throws NotBoundException if no such object is found for whatever reason (i.e., either because no registry is found or because NAME is unbound on all such registries.)
      Throws:
      NotBoundException
    • findObject

      public static Remote findObject(String name, String host) throws NotBoundException
      Return findObject(NAME, HOST, DEFAULT_LOW_PORT, DEFAULT_HIGH_PORT).
      Throws:
      NotBoundException
    • findObject

      public static Remote findObject(String name, String[] hosts, int lowPort, int highPort) throws NotBoundException
      Return a remote object named NAME in some registry on one of the hosts in HOSTS on some port number between LOWPORT and HIGHPORT. Throws NotBoundException if no such object is found for whatever reason (i.e., either because no registry is found or because NAME is unbound on all such registries.)
      Throws:
      NotBoundException
    • findObject

      public static Remote findObject(String name, String[] hosts) throws NotBoundException
      Return findObject(NAME, HOSTS, DEFAULT_LOW_PORT, DEFAULT_HIGH_PORT).
      Throws:
      NotBoundException
    • port

      public int port()
      Return the port number on which this registry is exported.
    • rebind

      public void rebind(String name, Remote value)
      Bind NAME to VALUE in this registry, replacing any existing binding.
    • unbind

      public void unbind(String name)
      Remove any binding of NAME in this registry.
    • unbind

      public void unbind()
      Remove all bindings in this registry.
    • close

      public void close()
      Remove all bindings from this registry, and disable it from further use.