java.rmi.registry

Class LocateRegistry


public final class LocateRegistry
extends Object

LocateRegistry is used to obtain a reference to a bootstrap remote object registry on a particular host (including the local host), or to create a remote object registry that accepts calls on a specific port.

Note that a getRegistry call does not actually make a connection to the remote host. It simply creates a local reference to the remote registry and will succeed even if no registry is running on the remote host. Therefore, a subsequent method invocation to a remote registry returned as a result of this method may fail.

Since:
JDK1.1
See Also:
Registry

Method Summary

static Registry
createRegistry(int port)
Creates and exports a Registry instance on the local host that accepts requests on the specified port.
static Registry
createRegistry(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf)
Creates and exports a Registry instance on the local host that uses custom socket factories for communication with that instance.
static Registry
getRegistry()
Returns a reference to the the remote object Registry for the local host on the default registry port of 1099.
static Registry
getRegistry(int port)
Returns a reference to the the remote object Registry for the local host on the specified port.
static Registry
getRegistry(String host)
Returns a reference to the remote object Registry on the specified host on the default registry port of 1099.
static Registry
getRegistry(String host, int port)
Returns a reference to the remote object Registry on the specified host and port.
static Registry
getRegistry(String host, int port, RMIClientSocketFactory csf)
Returns a locally created remote reference to the remote object Registry on the specified host and port.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Details

createRegistry

public static Registry createRegistry(int port)
            throws RemoteException
Creates and exports a Registry instance on the local host that accepts requests on the specified port.

The Registry instance is exported as if the static UnicastRemoteObject.exportObject method is invoked, passing the Registry instance and the specified port as arguments, except that the Registry instance is exported with a well-known object identifier, an ObjID instance constructed with the value ObjID.REGISTRY_ID.

Parameters:
port - the port on which the registry accepts requests
Returns:
the registry
Throws:
RemoteException - if the registry could not be exported
Since:
JDK1.1
Usages and Demos :

View More Examples of createRegistry(int port)
   1: 
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.server.ExportException;
   4:         ...
   5:         try {
   6:             LocateRegistry.createRegistry(getPort());
   7:         } catch (ExportException e) {
   8:             logger().debug("Registry probably created: " + e.getMessage());
   9:         }

View Full Code Here
   1: import java.rmi.Naming;
   2: import java.rmi.registry.LocateRegistry;
   3: 
   4:         ...
   5: 
   6:     LocateRegistry.createRegistry(1099);
   7: 
   8:     Searcher multiSearcher = new MultiSearcher(searchables);
   9:     RemoteSearchable multiImpl =

View Full Code Here
   1: import java.rmi.*;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.server.UnicastRemoteObject;
   4:         ...
   5:     private static void startRegistry() throws RemoteException {
   6:         LocateRegistry.createRegistry(1099);
   7:         System.out.println("RMI registry ready.");
   8:     }
   9:     

View Full Code Here
   1:         {
   2:             LocateRegistry.createRegistry(port);
   3: 
   4:             ChatServer server = new ChatServer();
   5:             System.out.println("chat server registered");

View Full Code Here
   1:         {
   2:             java.rmi.registry.LocateRegistry.createRegistry( 1099 );
   3:             System.out.println( "Service bound to registry, awaiting requests" );
   4:         }
   5:         catch( Exception e )

View Full Code Here

createRegistry

public static Registry createRegistry(int port,
                                      RMIClientSocketFactory csf,
                                      RMIServerSocketFactory ssf)
            throws RemoteException
Creates and exports a Registry instance on the local host that uses custom socket factories for communication with that instance. The registry that is created listens for incoming requests on the given port using a ServerSocket created from the supplied RMIServerSocketFactory.

The Registry instance is exported as if the static UnicastRemoteObject.exportObject method is invoked, passing the Registry instance, the specified port, the specified RMIClientSocketFactory, and the specified RMIServerSocketFactory as arguments, except that the Registry instance is exported with a well-known object identifier, an ObjID instance constructed with the value ObjID.REGISTRY_ID.

Parameters:
port - port on which the registry accepts requests
csf - client-side Socket factory used to make connections to the registry
ssf - server-side ServerSocket factory used to accept connections to the registry
Returns:
the registry
Throws:
RemoteException - if the registry could not be exported
Since:
1.2
Usages and Demos :

View More Examples of createRegistry(int port,RMIClientSocketFactory csf,RMIServerSocketFactory ssf)
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5:             }
   6:             Registry reg = LocateRegistry.getRegistry(registryHost, registryPort, clientSocketFactory);
   7:             testRegistry(reg);
   8:         ...
   9:             try {
  10:                 Registry reg = LocateRegistry.getRegistry(null, registryPort, clientSocketFactory);
  11:                 testRegistry(reg);
  12:         ...
  13:                 this.created = true;
  14:                 return LocateRegistry.createRegistry(registryPort, clientSocketFactory, serverSocketFactory);

View Full Code Here
   1: import java.rmi.Remote;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5:     try {
   6:       r = LocateRegistry.createRegistry(port, rsf, rsf);
   7:     } catch (Exception e2) {
   8:         ...
   9:     try {
  10:       r = LocateRegistry.getRegistry(host, port, rsf);

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5:             }
   6:             Registry reg = LocateRegistry.getRegistry(registryHost, registryPort, clientSocketFactory);
   7:             testRegistry(reg);
   8:         ...
   9:             try {
  10:                 Registry reg = LocateRegistry.getRegistry(null, registryPort, clientSocketFactory);
  11:                 testRegistry(reg);
  12:         ...
  13:                 logger.warn("Could not detect RMI registry - creating new one");
  14:                 return LocateRegistry.createRegistry(registryPort, clientSocketFactory, serverSocketFactory);

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5: 
   6:                 reg = LocateRegistry.createRegistry(rmiPort, null, sf);
   7: 
   8:         ...
   9:                 try {
  10:                     reg = LocateRegistry.getRegistry(rmiHost, rmiPort);
  11:                 } catch (RemoteException re) {

View Full Code Here

getRegistry

public static Registry getRegistry()
            throws RemoteException
Returns a reference to the the remote object Registry for the local host on the default registry port of 1099.
Returns:
reference (a stub) to the remote object registry
Throws:
RemoteException - if the reference could not be created
Since:
JDK1.1
Usages and Demos :

View More Examples of getRegistry()
   1: 
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5:   {
   6:     Registry registry = LocateRegistry.getRegistry();
   7:     Adder adder = (Adder) registry.lookup( "Adder" );
   8:     System.out.println( adder.add( 47, 11 ) );
   9:   }

View Full Code Here
   1: 
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5: 
   6:     Registry registry = LocateRegistry.getRegistry();
   7:     registry.rebind( "Adder", stub );
   8: 
   9:     System.out.println( "Adder angemeldet" );

View Full Code Here
   1: import java.rmi.registry.Registry;
   2: import java.rmi.registry.LocateRegistry;
   3: 
   4:         ...
   5:   public Account getAccount(String name) throws RemoteException {
   6:     Registry reg = LocateRegistry.getRegistry();
   7:     Account a = null;
   8:         ...
   9:   public boolean newAccount(Account a) throws RemoteException {
  10:     Registry reg = LocateRegistry.getRegistry();
  11:     System.out.print("Registering new account...");

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5:                 try {
   6:                     return LocateRegistry.getRegistry();
   7:                 } catch (RemoteException e) {
   8:                     return null;
   9:                 }

View Full Code Here
   1:             System.out.println("Registry ------------------------------------");
   2:             Registry registry = LocateRegistry.getRegistry();
   3:             System.out.println("- " + registry);
   4:             String[] list = registry.list();
   5:             System.out.println("- size=" + list.length);

View Full Code Here

getRegistry

public static Registry getRegistry(int port)
            throws RemoteException
Returns a reference to the the remote object Registry for the local host on the specified port.
Parameters:
port - port on which the registry accepts requests
Returns:
reference (a stub) to the remote object registry
Throws:
RemoteException - if the reference could not be created
Since:
JDK1.1
Usages and Demos :

View More Examples of getRegistry(int port)
   1:       Registry registry =
   2:         LocateRegistry.getRegistry(getRegistryHost(), getRegistryPort());
   3:       return (DaytimeServer)registry.lookup(getRegistryName());
   4:     }
   5:     catch (Exception e) {

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5:                 if (port >= 0) {
   6:                     registry = LocateRegistry.createRegistry(port);
   7:                     Runtime.getRuntime().addShutdownHook(new Thread() {
   8:         ...
   9:         try {
  10:             LocateRegistry.getRegistry(port).list();   
  11:         } catch (RemoteException re) {

View Full Code Here
   1: import java.rmi.activation.ActivationSystem;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5: 
   6:           Registry r = LocateRegistry.getRegistry(ACTIVATION_REGISTRY_PORT);
   7:           ActivationSystem system = (ActivationSystem) r.lookup(ACTIVATION_SYSTEM_NAME);
   8:           return system;
   9:         }

View Full Code Here
   1:                          Registry.REGISTRY_PORT);
   2:         registry = LocateRegistry.getRegistry(getHostName(), port);
   3: 
   4:         process = (ProcessOp)registry.lookup(Processor.PROCESS);
   5:     }

View Full Code Here
   1: import javax.resource.spi.ResourceAdapterInternalException;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5:       try {
   6:         Registry reg = LocateRegistry.getRegistry(_port);
   7:         if (log.isLoggable(Level.CONFIG))
   8:         ...
   9:         
  10:         LocateRegistry.createRegistry(_port);
  11:       }

View Full Code Here

getRegistry

public static Registry getRegistry(String host)
            throws RemoteException
Returns a reference to the remote object Registry on the specified host on the default registry port of 1099. If host is null, the local host is used.
Parameters:
host - host for the remote registry
Returns:
reference (a stub) to the remote object registry
Throws:
RemoteException - if the reference could not be created
Since:
JDK1.1
Usages and Demos :

View More Examples of getRegistry(String host)
   1:       Registry registry =
   2:         LocateRegistry.getRegistry(getRegistryHost(), getRegistryPort());
   3:       return (DaytimeServer)registry.lookup(getRegistryName());
   4:     }
   5:     catch (Exception e) {

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5:                 if (port >= 0) {
   6:                     registry = LocateRegistry.createRegistry(port);
   7:                     Runtime.getRuntime().addShutdownHook(new Thread() {
   8:         ...
   9:         try {
  10:             LocateRegistry.getRegistry(port).list();   
  11:         } catch (RemoteException re) {

View Full Code Here
   1: import java.rmi.activation.ActivationSystem;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5: 
   6:           Registry r = LocateRegistry.getRegistry(ACTIVATION_REGISTRY_PORT);
   7:           ActivationSystem system = (ActivationSystem) r.lookup(ACTIVATION_SYSTEM_NAME);
   8:           return system;
   9:         }

View Full Code Here
   1:                          Registry.REGISTRY_PORT);
   2:         registry = LocateRegistry.getRegistry(getHostName(), port);
   3: 
   4:         process = (ProcessOp)registry.lookup(Processor.PROCESS);
   5:     }

View Full Code Here
   1: import javax.resource.spi.ResourceAdapterInternalException;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5:       try {
   6:         Registry reg = LocateRegistry.getRegistry(_port);
   7:         if (log.isLoggable(Level.CONFIG))
   8:         ...
   9:         
  10:         LocateRegistry.createRegistry(_port);
  11:       }

View Full Code Here

getRegistry

public static Registry getRegistry(String host,
                                   int port)
            throws RemoteException
Returns a reference to the remote object Registry on the specified host and port. If host is null, the local host is used.
Parameters:
host - host for the remote registry
port - port on which the registry accepts requests
Returns:
reference (a stub) to the remote object registry
Throws:
RemoteException - if the reference could not be created
Since:
JDK1.1
Usages and Demos :

View More Examples of getRegistry(String host,int port)
   1: 
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5:     try {
   6:       reg = LocateRegistry.getRegistry(hostName, hostPort);
   7:     } catch (Exception e) {
   8:         ...
   9:     Registry registry = 
  10:       LocateRegistry.createRegistry(
  11:           port);

View Full Code Here
   1:         Registry host_reg =
   2:         LocateRegistry.getRegistry(url, port_nb);
   3:         tsh = (TaskShellHandle) host_reg.lookup(textifyDarxName());
   4:     } catch (DarxException e) {
   5:         System.out.println("Shell handle for replicant "+ textifyDarxPath()

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5:             {
   6:                 return LocateRegistry.getRegistry( host, port, clientSocketFactory );
   7:             }
   8:         ...
   9:             {
  10:                 return LocateRegistry.getRegistry( host, port );
  11:             }

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.util.ArrayList;
   4:         ...
   5:             try{
   6:                 LocateRegistry.createRegistry(rmiRegistryPort);
   7: 
   8:             }catch(RemoteException e){
   9:                 logger.severe("Could not found rmiRegistry : "+e.getMessage());

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5:             SFNetworkContext nc = securityEnv.getNetworkContext();
   6:             return LocateRegistry.
   7:                 createRegistry(port,
   8:         ...
   9:         } else {
  10:             return LocateRegistry.createRegistry(port);
  11:         }
  12:         ...
  13:         } else {
  14:             return LocateRegistry.getRegistry(host, port);

View Full Code Here

getRegistry

public static Registry getRegistry(String host,
                                   int port,
                                   RMIClientSocketFactory csf)
            throws RemoteException
Returns a locally created remote reference to the remote object Registry on the specified host and port. Communication with this remote registry will use the supplied RMIClientSocketFactory csf to create Socket connections to the registry on the remote host and port.
Parameters:
host - host for the remote registry
port - port on which the registry accepts requests
csf - client-side Socket factory used to make connections to the registry. If csf is null, then the default client-side Socket factory will be used in the registry stub.
Returns:
reference (a stub) to the remote registry
Throws:
RemoteException - if the reference could not be created
Since:
1.2
Usages and Demos :

View More Examples of getRegistry(String host,int port,RMIClientSocketFactory csf)
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5:             {
   6:                 return LocateRegistry.getRegistry( host, port, clientSocketFactory );
   7:             }
   8:         ...
   9:             {
  10:                 return LocateRegistry.getRegistry( host, port );
  11:             }

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5:             }
   6:             Registry reg = LocateRegistry.getRegistry(registryHost, registryPort, clientSocketFactory);
   7:             testRegistry(reg);
   8:         ...
   9:             try {
  10:                 Registry reg = LocateRegistry.getRegistry(null, registryPort, clientSocketFactory);
  11:                 testRegistry(reg);
  12:         ...
  13:                 this.created = true;
  14:                 return LocateRegistry.createRegistry(registryPort, clientSocketFactory, serverSocketFactory);

View Full Code Here
   1: import java.rmi.Remote;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5:     try {
   6:       r = LocateRegistry.createRegistry(port, rsf, rsf);
   7:     } catch (Exception e2) {
   8:         ...
   9:     try {
  10:       r = LocateRegistry.getRegistry(host, port, rsf);

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3: import java.rmi.registry.Registry;
   4:         ...
   5:             }
   6:             Registry reg = LocateRegistry.getRegistry(registryHost, registryPort, clientSocketFactory);
   7:             testRegistry(reg);
   8:         ...
   9:             try {
  10:                 Registry reg = LocateRegistry.getRegistry(null, registryPort, clientSocketFactory);
  11:                 testRegistry(reg);
  12:         ...
  13:                 logger.warn("Could not detect RMI registry - creating new one");
  14:                 return LocateRegistry.createRegistry(registryPort, clientSocketFactory, serverSocketFactory);

View Full Code Here