org.sapia.ubik.rmi.naming.remote
Class RemoteInitialContextFactory
java.lang.Object
org.sapia.ubik.rmi.naming.remote.RemoteInitialContextFactory
- All Implemented Interfaces:
- javax.naming.spi.InitialContextFactory, Consts
public class RemoteInitialContextFactory
- extends java.lang.Object
- implements javax.naming.spi.InitialContextFactory, Consts
Implements a factory that allows to register ServiceDiscoveryListeners
that are notified when a service is bound to the JNDI servers.
Usage:
Properties props = new Properties();
// IMPORTANT: the following line of code sets the domain name
// to which this client (or rather, to which the JNDI context
// thereafter acquired) belongs. Service discovery notifications
// will only be received from the JNDI servers that belong to the
// same domain as the thus acquired JNDI context.
props.setProperty("ubik.jndi.domain", "someDomain");
// If the above is not specified, the domain will be 'default'.
props.setProperty(InitialContext.PROVIDER_URL, "ubik://localhost:1098/");
// IMPORTANT: do not set the wrong factory, otherwise the code
// further below will break...
props.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY,
RemoteInitialContextFactory.class.getName());
InitialContext ctx = new InitialContext(props);
MyServiceDiscoveryListener listener = new MyServiceDiscoveryListener();
ReliableLocalContext rctx = ReliableLocalContext.currentContext();
rctx.addServiceDiscoListener(listener);
// IMPORTANT: from then on, the listener will be notified if a new service
// is bound to the domain, for AS LONG AS THE close() METHOD IS NOT CALLED
// ON THE CONTEXT!!!
// ... So do the following only when the acquired initial context must
// be disposed of - the added listeners will not receive notifications
// anymore:
ctx.close();
An instance of this class instantiates an EventChannel to receive
notifications from the Ubik JNDI servers on the network, through UDP multicast.
The multicast address and port can be specified through the following properties:
- ubik.rmi.naming.mcast.address
- ubik.rmi.naming.mcast.port
These properties must be specified (and passed to an instance of this class) as
demonstrated below:
Properties props = new Properties();
props.setProperty("ubik.rmi.naming.mcast.address", "224.0.0.10");
props.setProperty("ubik.rmi.naming.mcast.port", "6565");
props.setProperty(InitialContext.PROVIDER_URL, "ubik://localhost:1098/");
props.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY,
ReliableInitialContextFactory.class.getName());
props.setProperty(
InitialContext ctx = new InitialContext(props);
If not specified, the following are used for multicast address and port, respectively:
- Author:
- Yanick Duchesne
- Copyright:
- Copyright © 2002-2003 Sapia Open Source Software. All Rights Reserved.
- License:
- Read the license.txt file of the jar or visit the
license page at the Sapia OSS web site
- See Also:
ReliableLocalContext
| Fields inherited from interface org.sapia.ubik.rmi.Consts |
ALLOW_CODE_DOWNLOAD, CALLBACK_ENABLED, CLIENT_CALLBACK_TIMEOUT, CLIENT_GC_BATCHSIZE, CLIENT_GC_INTERVAL, CLIENT_GC_THRESHOLD, DEFAULT_DOMAIN, DEFAULT_MCAST_ADDR, DEFAULT_MCAST_PORT, IP_PATTERN_KEY, JMX_ENABLED, LOG_LEVEL, MARSHALLING, MCAST_ADDR_KEY, MCAST_BUFSIZE_KEY, MCAST_HEARTBEAT_INTERVAL, MCAST_HEARTBEAT_TIMEOUT, MCAST_PORT_KEY, OBJECT_TABLE_INITCAPACITY, OBJECT_TABLE_LOAD_FACTOR, SERVER_CALLBACK_MAX_THREADS, SERVER_GC_INTERVAL, SERVER_GC_TIMEOUT, SERVER_MAX_THREADS, SERVER_RESET_INTERVAL, STATS_DUMP_INTERVAL, STATS_ENABLED, TRANSPORT_PROVIDER, TRANSPORT_TYPE, UBIK_DOMAIN_NAME |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RemoteInitialContextFactory
public RemoteInitialContextFactory()
RemoteInitialContextFactory
public RemoteInitialContextFactory(java.lang.String serviceLocatorScheme)
getInitialContext
public javax.naming.Context getInitialContext(java.util.Hashtable props)
throws javax.naming.NamingException
- Specified by:
getInitialContext in interface javax.naming.spi.InitialContextFactory
- Throws:
javax.naming.NamingException- See Also:
InitialContextFactory.getInitialContext(Hashtable)
doGetResolver
protected ContextResolver doGetResolver()
Copyright © 2010 Sapia OSS. All Rights Reserved.