org.sapia.regis.remote
Class RegistryExporter

java.lang.Object
  extended by org.sapia.regis.remote.RegistryExporter
All Implemented Interfaces:
RemoteConsts, org.sapia.ubik.mcast.AsyncEventListener

public class RegistryExporter
extends Object
implements RemoteConsts, org.sapia.ubik.mcast.AsyncEventListener

An instance of this class exports a Registry as a remote object.

The Registry that his held by an instance of this class will internally be made available through the network upon one of the bind() methods being called.

To lookup a Registry that has been bound by an instance of this class, applications can use a RegistryImporter, or a RemoteRegistryFactory.

See Also:
bind(int), bind(String, Properties), RegistryImporter, RemoteRegistryFactory

Field Summary
static String DISCO
           
static String PUBLISH
           
 
Fields inherited from interface org.sapia.regis.remote.RemoteConsts
BOOTSTRAP, DEBUG, DEFAULT_PASSWORD, DEFAULT_USERNAME, PASSWORD, PEER_TO_PEER, SERVER_JNDI_NAME, SERVER_PORT, USERNAME
 
Constructor Summary
RegistryExporter(Registry reg, Properties bootstrapProps)
           
RegistryExporter(String username, String password, Registry reg, Properties bootstrapProps)
           
 
Method Summary
 void bind(int port)
          This method bind the Registry held by this instance on the network, on the given port.
 void bind(String jndiName, Properties props)
          This method binds the Registry held by this instance to the JNDI service that corresponds to the given properties, under the given JNDI name.
 void close()
          Closes this instance (which releases all system resources it holds).
 void onAsyncEvent(org.sapia.ubik.mcast.RemoteEvent evt)
           
 void setDomain(String domain)
           
 void setPeerToPeer(boolean peerToPeer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PUBLISH

public static final String PUBLISH
See Also:
Constant Field Values

DISCO

public static final String DISCO
See Also:
Constant Field Values
Constructor Detail

RegistryExporter

public RegistryExporter(Registry reg,
                        Properties bootstrapProps)

RegistryExporter

public RegistryExporter(String username,
                        String password,
                        Registry reg,
                        Properties bootstrapProps)
Method Detail

setPeerToPeer

public void setPeerToPeer(boolean peerToPeer)
Parameters:
peerToPeer - indicates if this instance should behave as peer in a network of registries - by default, this instance is not in peer-to-peer mode.

setDomain

public void setDomain(String domain)
Parameters:
domain - the name of the domain to which this instance belongs.

close

public void close()
Closes this instance (which releases all system resources it holds).


bind

public void bind(int port)
          throws Exception
This method bind the Registry held by this instance on the network, on the given port. The registry thus becomes available as a remote object.

Clients can connect to the registry through the Ubik Hub:

   // connects on the given host, port
   Registry reg = (Registry)Hub.connect("192.168.0.101", 40000);
 

Note that Ubik runtime attempts to bind servers on addresses that match the value of the ubik.rmi.address-pattern system property. If that property is not defined, then the address used will be the first that DOES NOT correspond to "localhost" or 127.0.0.1. If no such address exists, then "localhost" is internally used.

If "localhost" must be used (for testing purposes for example), then the ubik.rmi.address-pattern system property should be set, with localhost as a value.

Parameters:
port - a port
Throws:
Exception - if the registry could not be exported

bind

public void bind(String jndiName,
                 Properties props)
          throws Exception
This method binds the Registry held by this instance to the JNDI service that corresponds to the given properties, under the given JNDI name.

The properties passed in correspond to the ones expected by Ubik's JNDI provider (see the tutorial)

Client applications can lookup a registry exported by this instance using a RegistryImporter, or a RemoteRegistryFactory.

For more info concerning the properties defined above, see the javadoc for the Const class.

Parameters:
jndiName - the JNDI name under which the registry should be bound in the Ubik JNDI service.
props - must hold Ubik JNDI properties
Throws:
Exception - if the registry could not be bound to the JNDI service.
See Also:
RegistryImporter

onAsyncEvent

public void onAsyncEvent(org.sapia.ubik.mcast.RemoteEvent evt)
Specified by:
onAsyncEvent in interface org.sapia.ubik.mcast.AsyncEventListener


Copyright © 2006 Sapia Open Community, Inc. All Rights Reserved.