nl.tudelft.simulation.naming
Class InitialEventContext

java.lang.Object
  extended by nl.tudelft.simulation.naming.InitialEventContext
All Implemented Interfaces:
Context, EventContext

public class InitialEventContext
extends Object
implements EventContext

This class is the starting context for performing naming operations.

(c) copyright 2002-2005 Delft University of Technology , the Netherlands.
See for project information www.simulation.tudelft.nl
License of use: Lesser General Public License (LGPL) , no warranty.

Since:
1.3
Version:
1.2 2004-03-24
Author:
Peter Jacobs

Field Summary
protected  EventContext defaultInitCtx
          Field holding the result of calling NamingManager.getInitialContext().
protected  boolean gotDefault
          Field indicating whether the initial context has been obtained by calling NamingManager.getInitialContext().
protected  Hashtable myProps
          the properties of the initialEventContext
 
Fields inherited from interface javax.naming.event.EventContext
OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE
 
Fields inherited from interface javax.naming.Context
APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES
 
Constructor Summary
  InitialEventContext()
          Constructs an initial context.
protected InitialEventContext(boolean lazy)
          Constructs an initial context with the option of not initializing it.
  InitialEventContext(Hashtable environment)
          Constructs an initial context using the supplied environment.
 
Method Summary
 void addNamingListener(Name target, int scope, NamingListener l)
           
 void addNamingListener(String target, int scope, NamingListener l)
           
 Object addToEnvironment(String propName, Object propVal)
           
 void bind(Name name, Object obj)
           
 void bind(String name, Object obj)
           
 void close()
           
 Name composeName(Name name, Name prefix)
          Composes the name of this context with a name relative to this context.
 String composeName(String name, String prefix)
          Composes the name of this context with a name relative to this context.
 Context createSubcontext(Name name)
           
 Context createSubcontext(String name)
           
 void destroySubcontext(Name name)
           
 void destroySubcontext(String name)
           
protected  EventContext getDefaultInitCtx()
          Retrieves the initial context by calling NamingManager.getInitialContext() and cache it in defaultInitCtx.
 Hashtable getEnvironment()
           
 String getNameInNamespace()
           
 NameParser getNameParser(Name name)
           
 NameParser getNameParser(String name)
           
protected  Context getURLOrDefaultInitCtx(Name name)
           
protected  Context getURLOrDefaultInitCtx(String name)
          Retrieves a context for resolving the string name name.
protected  void init(Hashtable environment)
          Initializes the initial context using the supplied environment.
 NamingEnumeration list(Name name)
           
 NamingEnumeration list(String name)
           
 NamingEnumeration listBindings(Name name)
           
 NamingEnumeration listBindings(String name)
           
 Object lookup(Name name)
           
 Object lookup(String name)
           
 Object lookupLink(Name name)
           
 Object lookupLink(String name)
           
 void rebind(Name name, Object obj)
           
 void rebind(String name, Object obj)
           
 Object removeFromEnvironment(String propName)
           
 void removeNamingListener(NamingListener l)
           
 void rename(Name oldName, Name newName)
           
 void rename(String oldName, String newName)
           
 boolean targetMustExist()
           
 void unbind(Name name)
           
 void unbind(String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myProps

protected Hashtable myProps
the properties of the initialEventContext


defaultInitCtx

protected EventContext defaultInitCtx
Field holding the result of calling NamingManager.getInitialContext(). It is set by getDefaultInitCtx() the first time getDefaultInitCtx() is called. Subsequent invocations of getDefaultInitCtx() return the value of defaultInitCtx.


gotDefault

protected boolean gotDefault
Field indicating whether the initial context has been obtained by calling NamingManager.getInitialContext(). If true, its result is in defaultInitCtx.

Constructor Detail

InitialEventContext

protected InitialEventContext(boolean lazy)
                       throws NamingException
Constructs an initial context with the option of not initializing it. This may be used by a constructor in a subclass when the value of the environment parameter is not yet known at the time the InitialContext constructor is called. The subclass's constructor will call this constructor, compute the value of the environment, and then call init() before returning.

Parameters:
lazy - true means do not initialize the initial context; false is equivalent to calling new InitialContext()
Throws:
NamingException - if a naming exception is encountered
Since:
1.3
See Also:
init(Hashtable)

InitialEventContext

public InitialEventContext()
                    throws NamingException
Constructs an initial context. No environment properties are supplied. Equivalent to new InitialContext(null).

Throws:
NamingException - if a naming exception is encountered

InitialEventContext

public InitialEventContext(Hashtable environment)
                    throws NamingException
Constructs an initial context using the supplied environment. Environment properties are discussed in the class description.

This constructor will not modify environment or save a reference to it, but may save a clone.

Parameters:
environment - environment used to create the initial context. Null indicates an empty environment.
Throws:
NamingException - if a naming exception is encountered
Method Detail

init

protected void init(Hashtable environment)
             throws NamingException
Initializes the initial context using the supplied environment. Environment properties are discussed in the class description.

This method will modify environment and save a reference to it. The caller may no longer modify it.

Parameters:
environment - environment used to create the initial context. Null indicates an empty environment.
Throws:
NamingException - if a naming exception is encountered
Since:
1.3

getDefaultInitCtx

protected EventContext getDefaultInitCtx()
                                  throws NamingException
Retrieves the initial context by calling NamingManager.getInitialContext() and cache it in defaultInitCtx. Set gotDefault so that we know we've tried this before.

Returns:
The non-null cached initial context.
Throws:
NamingException - If a naming exception was encountered.

getURLOrDefaultInitCtx

protected Context getURLOrDefaultInitCtx(String name)
                                  throws NamingException
Retrieves a context for resolving the string name name. If name name is a URL string, then attempt to find a URL context for it. If none is found, or if name is not a URL string, then return getDefaultInitCtx().

See getURLOrDefaultInitCtx(Name) for description of how a subclass should use this method.

Parameters:
name - The non-null name for which to get the context.
Returns:
A URL context for name or the cached initial context. The result cannot be null.
Throws:
NamingException - on exception

getURLOrDefaultInitCtx

protected Context getURLOrDefaultInitCtx(Name name)
                                  throws NamingException
Parameters:
name - The non-null name for which to get the context.
Returns:
A URL context for name
Throws:
NamingException - In a naming exception is encountered.

lookup

public Object lookup(String name)
              throws NamingException
Specified by:
lookup in interface Context
Throws:
NamingException
See Also:
Context.lookup(java.lang.String)

lookup

public Object lookup(Name name)
              throws NamingException
Specified by:
lookup in interface Context
Throws:
NamingException
See Also:
Context.lookup(javax.naming.Name)

bind

public void bind(String name,
                 Object obj)
          throws NamingException
Specified by:
bind in interface Context
Throws:
NamingException
See Also:
Context.bind(java.lang.String, java.lang.Object)

bind

public void bind(Name name,
                 Object obj)
          throws NamingException
Specified by:
bind in interface Context
Throws:
NamingException
See Also:
Context.bind(javax.naming.Name, java.lang.Object)

rebind

public void rebind(String name,
                   Object obj)
            throws NamingException
Specified by:
rebind in interface Context
Throws:
NamingException
See Also:
Context.rebind(java.lang.String, java.lang.Object)

rebind

public void rebind(Name name,
                   Object obj)
            throws NamingException
Specified by:
rebind in interface Context
Throws:
NamingException
See Also:
Context.rebind(javax.naming.Name, java.lang.Object)

unbind

public void unbind(String name)
            throws NamingException
Specified by:
unbind in interface Context
Throws:
NamingException
See Also:
Context.unbind(java.lang.String)

unbind

public void unbind(Name name)
            throws NamingException
Specified by:
unbind in interface Context
Throws:
NamingException
See Also:
Context.unbind(javax.naming.Name)

rename

public void rename(String oldName,
                   String newName)
            throws NamingException
Specified by:
rename in interface Context
Throws:
NamingException
See Also:
Context.rename(java.lang.String, java.lang.String)

rename

public void rename(Name oldName,
                   Name newName)
            throws NamingException
Specified by:
rename in interface Context
Throws:
NamingException
See Also:
Context.rename(javax.naming.Name, javax.naming.Name)

list

public NamingEnumeration list(String name)
                       throws NamingException
Specified by:
list in interface Context
Throws:
NamingException
See Also:
Context.list(java.lang.String)

list

public NamingEnumeration list(Name name)
                       throws NamingException
Specified by:
list in interface Context
Throws:
NamingException
See Also:
Context.list(javax.naming.Name)

listBindings

public NamingEnumeration listBindings(String name)
                               throws NamingException
Specified by:
listBindings in interface Context
Throws:
NamingException
See Also:
Context.listBindings(java.lang.String)

listBindings

public NamingEnumeration listBindings(Name name)
                               throws NamingException
Specified by:
listBindings in interface Context
Throws:
NamingException
See Also:
Context.listBindings(javax.naming.Name)

destroySubcontext

public void destroySubcontext(String name)
                       throws NamingException
Specified by:
destroySubcontext in interface Context
Throws:
NamingException
See Also:
Context.destroySubcontext(java.lang.String)

destroySubcontext

public void destroySubcontext(Name name)
                       throws NamingException
Specified by:
destroySubcontext in interface Context
Throws:
NamingException
See Also:
Context.destroySubcontext(javax.naming.Name)

createSubcontext

public Context createSubcontext(String name)
                         throws NamingException
Specified by:
createSubcontext in interface Context
Throws:
NamingException
See Also:
Context.createSubcontext(java.lang.String)

createSubcontext

public Context createSubcontext(Name name)
                         throws NamingException
Specified by:
createSubcontext in interface Context
Throws:
NamingException
See Also:
Context.createSubcontext(javax.naming.Name)

lookupLink

public Object lookupLink(String name)
                  throws NamingException
Specified by:
lookupLink in interface Context
Throws:
NamingException
See Also:
Context.lookupLink(java.lang.String)

lookupLink

public Object lookupLink(Name name)
                  throws NamingException
Specified by:
lookupLink in interface Context
Throws:
NamingException
See Also:
Context.lookupLink(javax.naming.Name)

getNameParser

public NameParser getNameParser(String name)
                         throws NamingException
Specified by:
getNameParser in interface Context
Throws:
NamingException
See Also:
Context.getNameParser(java.lang.String)

getNameParser

public NameParser getNameParser(Name name)
                         throws NamingException
Specified by:
getNameParser in interface Context
Throws:
NamingException
See Also:
Context.getNameParser(javax.naming.Name)

composeName

public String composeName(String name,
                          String prefix)
                   throws NamingException
Composes the name of this context with a name relative to this context. Since an initial context may never be named relative to any context other than itself, the value of the prefix parameter must be an empty name ("").

Specified by:
composeName in interface Context
Parameters:
name - the name
prefix - the prefix
Returns:
String
Throws:
NamingException - on exception

composeName

public Name composeName(Name name,
                        Name prefix)
                 throws NamingException
Composes the name of this context with a name relative to this context. Since an initial context may never be named relative to any context other than itself, the value of the prefix parameter must be an empty name.

Specified by:
composeName in interface Context
Parameters:
name - the name
prefix - the prefix
Returns:
Name
Throws:
NamingException - on exception

addToEnvironment

public Object addToEnvironment(String propName,
                               Object propVal)
                        throws NamingException
Specified by:
addToEnvironment in interface Context
Throws:
NamingException
See Also:
#addToEnvironment(java.lang.String, java.lang.Object)

removeFromEnvironment

public Object removeFromEnvironment(String propName)
                             throws NamingException
Specified by:
removeFromEnvironment in interface Context
Throws:
NamingException
See Also:
Context.removeFromEnvironment(java.lang.String)

getEnvironment

public Hashtable getEnvironment()
                         throws NamingException
Specified by:
getEnvironment in interface Context
Throws:
NamingException
See Also:
Context.getEnvironment()

close

public void close()
           throws NamingException
Specified by:
close in interface Context
Throws:
NamingException
See Also:
Context.close()

getNameInNamespace

public String getNameInNamespace()
                          throws NamingException
Specified by:
getNameInNamespace in interface Context
Throws:
NamingException
See Also:
Context.getNameInNamespace()

addNamingListener

public void addNamingListener(Name target,
                              int scope,
                              NamingListener l)
                       throws NamingException
Specified by:
addNamingListener in interface EventContext
Throws:
NamingException
See Also:
#addNamingListener(javax.naming.Name, int, NamingListener)

addNamingListener

public void addNamingListener(String target,
                              int scope,
                              NamingListener l)
                       throws NamingException
Specified by:
addNamingListener in interface EventContext
Throws:
NamingException
See Also:
#addNamingListener(java.lang.String, int, NamingListener)

removeNamingListener

public void removeNamingListener(NamingListener l)
                          throws NamingException
Specified by:
removeNamingListener in interface EventContext
Throws:
NamingException
See Also:
#removeNamingListener(javax.naming.event.NamingListener)

targetMustExist

public boolean targetMustExist()
                        throws NamingException
Specified by:
targetMustExist in interface EventContext
Throws:
NamingException
See Also:
EventContext.targetMustExist()


Copyright © 2002-2011 Delft University of Technology, the Netherlands. All Rights Reserved.