org.eclipse.jetty.jndi
Class NamingContext

java.lang.Object
  extended by org.eclipse.jetty.jndi.NamingContext
All Implemented Interfaces:
Cloneable, Context, Dumpable

public class NamingContext
extends Object
implements Context, Cloneable, Dumpable

NamingContext

Implementation of Context interface.

Notes

All Names are expected to be Compound, not Composite.

Usage


Nested Class Summary
 class NamingContext.BindingEnumeration
          BindingEnumeration
static interface NamingContext.Listener
          Naming Context Listener.
 class NamingContext.NameEnumeration
          NameEnumeration
 
Field Summary
protected  Map<String,Binding> _bindings
           
protected  Hashtable<String,Object> _env
           
protected  String _name
           
protected  NamingContext _parent
           
protected  NameParser _parser
           
static String LOCK_PROPERTY
           
static String UNLOCK_PROPERTY
           
 
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
NamingContext()
          Constructor
NamingContext(Hashtable<String,Object> env)
          Creates a new NamingContext instance.
NamingContext(Hashtable<String,Object> env, String name, NamingContext parent, NameParser parser)
          Constructor
 
Method Summary
protected  void addBinding(Name name, Object obj)
          Add a name to object binding to this Context.
 void addListener(NamingContext.Listener listener)
           
 Object addToEnvironment(String propName, Object propVal)
          Add an environment setting to this Context
 void bind(Name name, Object obj)
          Bind a name to an object
 void bind(String name, Object obj)
          Bind a name (as a String) to an object
 Object clone()
          Clone this NamingContext
 void close()
          Do nothing
 Name composeName(Name name, Name prefix)
          Join two names together.
 String composeName(String name, String prefix)
          Join two names together.
 Context createSubcontext(Name name)
          Create a context as a child of this one
 Context createSubcontext(String name)
          Create a Context as a child of this one
 void destroySubcontext(Name name)
          Not supported
 void destroySubcontext(String name)
          Not supported
 String dump()
           
 void dump(Appendable out, String indent)
           
protected  Binding getBinding(Name name)
          Get a name to object binding from this Context
protected  Binding getBinding(String name)
          Get a name to object binding from this Context
 Hashtable getEnvironment()
          Get the environment of this Context.
 String getName()
          Getter for _name
 String getNameInNamespace()
          Get the full name of this Context node by visiting it's ancestors back to root.
 NameParser getNameParser(Name name)
          Return a NameParser for this Context.
 NameParser getNameParser(String name)
          Return a NameParser for this Context.
 Context getParent()
          Getter for _parent
 NamingEnumeration list(Name name)
          List all names bound at Context named by Name
 NamingEnumeration list(String name)
          List all names bound at Context named by Name
 NamingEnumeration listBindings(Name name)
          List all Bindings present at Context named by Name
 NamingEnumeration listBindings(String name)
          List all Bindings at Name
 Object lookup(Name name)
          Lookup a binding by name
 Object lookup(String name)
          Lookup binding of an object by name
 Object lookupLink(Name name)
          Lookup link bound to name
 Object lookupLink(String name)
          Lookup link bound to name
 void rebind(Name name, Object obj)
          Overwrite or create a binding
 void rebind(String name, Object obj)
          Overwrite or create a binding from Name to Object
protected  void removeBinding(Name name)
           
 Object removeFromEnvironment(String propName)
          Remove a property from this Context's environment.
 boolean removeListener(NamingContext.Listener listener)
           
 void rename(Name oldName, Name newName)
          Not supported
 void rename(String oldName, String newName)
          Not supported
 void setNameParser(NameParser parser)
          Setter for _parser
 Name toCanonicalName(Name name)
          Remove leading or trailing empty components from name.
 void unbind(Name name)
          Not supported.
 void unbind(String name)
          Not supported.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCK_PROPERTY

public static final String LOCK_PROPERTY
See Also:
Constant Field Values

UNLOCK_PROPERTY

public static final String UNLOCK_PROPERTY
See Also:
Constant Field Values

_env

protected final Hashtable<String,Object> _env

_bindings

protected Map<String,Binding> _bindings

_parent

protected NamingContext _parent

_name

protected String _name

_parser

protected NameParser _parser
Constructor Detail

NamingContext

public NamingContext(Hashtable<String,Object> env,
                     String name,
                     NamingContext parent,
                     NameParser parser)
Constructor

Parameters:
env - environment properties
name - relative name of this context
parent - immediate ancestor Context (can be null)
parser - NameParser for this Context

NamingContext

public NamingContext(Hashtable<String,Object> env)
Creates a new NamingContext instance.

Parameters:
env - a Hashtable value

NamingContext

public NamingContext()
Constructor

Method Detail

clone

public Object clone()
             throws CloneNotSupportedException
Clone this NamingContext

Overrides:
clone in class Object
Returns:
copy of this NamingContext
Throws:
CloneNotSupportedException - if an error occurs

getName

public String getName()
Getter for _name

Returns:
name of this Context (relative, not absolute)

getParent

public Context getParent()
Getter for _parent

Returns:
parent Context

setNameParser

public void setNameParser(NameParser parser)
Setter for _parser


bind

public void bind(Name name,
                 Object obj)
          throws NamingException
Bind a name to an object

Specified by:
bind in interface Context
Parameters:
name - Name of the object
obj - object to bind
Throws:
NamingException - if an error occurs

bind

public void bind(String name,
                 Object obj)
          throws NamingException
Bind a name (as a String) to an object

Specified by:
bind in interface Context
Parameters:
name - a String value
obj - an Object value
Throws:
NamingException - if an error occurs

createSubcontext

public Context createSubcontext(Name name)
                         throws NamingException
Create a context as a child of this one

Specified by:
createSubcontext in interface Context
Parameters:
name - a Name value
Returns:
a Context value
Throws:
NamingException - if an error occurs

createSubcontext

public Context createSubcontext(String name)
                         throws NamingException
Create a Context as a child of this one

Specified by:
createSubcontext in interface Context
Parameters:
name - a String value
Returns:
a Context value
Throws:
NamingException - if an error occurs

destroySubcontext

public void destroySubcontext(String name)
                       throws NamingException
Not supported

Specified by:
destroySubcontext in interface Context
Parameters:
name - name of subcontext to remove
Throws:
NamingException - if an error occurs

destroySubcontext

public void destroySubcontext(Name name)
                       throws NamingException
Not supported

Specified by:
destroySubcontext in interface Context
Parameters:
name - name of subcontext to remove
Throws:
NamingException - if an error occurs

lookup

public Object lookup(Name name)
              throws NamingException
Lookup a binding by name

Specified by:
lookup in interface Context
Parameters:
name - name of bound object
Throws:
NamingException - if an error occurs

lookup

public Object lookup(String name)
              throws NamingException
Lookup binding of an object by name

Specified by:
lookup in interface Context
Parameters:
name - name of bound object
Returns:
object bound to name
Throws:
NamingException - if an error occurs

lookupLink

public Object lookupLink(Name name)
                  throws NamingException
Lookup link bound to name

Specified by:
lookupLink in interface Context
Parameters:
name - name of link binding
Returns:
LinkRef or plain object bound at name
Throws:
NamingException - if an error occurs

lookupLink

public Object lookupLink(String name)
                  throws NamingException
Lookup link bound to name

Specified by:
lookupLink in interface Context
Parameters:
name - name of link binding
Returns:
LinkRef or plain object bound at name
Throws:
NamingException - if an error occurs

list

public NamingEnumeration list(Name name)
                       throws NamingException
List all names bound at Context named by Name

Specified by:
list in interface Context
Parameters:
name - a Name value
Returns:
a NamingEnumeration value
Throws:
NamingException - if an error occurs

list

public NamingEnumeration list(String name)
                       throws NamingException
List all names bound at Context named by Name

Specified by:
list in interface Context
Parameters:
name - a Name value
Returns:
a NamingEnumeration value
Throws:
NamingException - if an error occurs

listBindings

public NamingEnumeration listBindings(Name name)
                               throws NamingException
List all Bindings present at Context named by Name

Specified by:
listBindings in interface Context
Parameters:
name - a Name value
Returns:
a NamingEnumeration value
Throws:
NamingException - if an error occurs

listBindings

public NamingEnumeration listBindings(String name)
                               throws NamingException
List all Bindings at Name

Specified by:
listBindings in interface Context
Parameters:
name - a String value
Returns:
a NamingEnumeration value
Throws:
NamingException - if an error occurs

rebind

public void rebind(Name name,
                   Object obj)
            throws NamingException
Overwrite or create a binding

Specified by:
rebind in interface Context
Parameters:
name - a Name value
obj - an Object value
Throws:
NamingException - if an error occurs

rebind

public void rebind(String name,
                   Object obj)
            throws NamingException
Overwrite or create a binding from Name to Object

Specified by:
rebind in interface Context
Parameters:
name - a String value
obj - an Object value
Throws:
NamingException - if an error occurs

unbind

public void unbind(String name)
            throws NamingException
Not supported.

Specified by:
unbind in interface Context
Parameters:
name - a String value
Throws:
NamingException - if an error occurs

unbind

public void unbind(Name name)
            throws NamingException
Not supported.

Specified by:
unbind in interface Context
Parameters:
name - a String value
Throws:
NamingException - if an error occurs

rename

public void rename(Name oldName,
                   Name newName)
            throws NamingException
Not supported

Specified by:
rename in interface Context
Parameters:
oldName - a Name value
newName - a Name value
Throws:
NamingException - if an error occurs

rename

public void rename(String oldName,
                   String newName)
            throws NamingException
Not supported

Specified by:
rename in interface Context
Parameters:
oldName - a Name value
newName - a Name value
Throws:
NamingException - if an error occurs

composeName

public Name composeName(Name name,
                        Name prefix)
                 throws NamingException
Join two names together. These are treated as CompoundNames.

Specified by:
composeName in interface Context
Parameters:
name - a Name value
prefix - a Name value
Returns:
a Name value
Throws:
NamingException - if an error occurs

composeName

public String composeName(String name,
                          String prefix)
                   throws NamingException
Join two names together. These are treated as CompoundNames.

Specified by:
composeName in interface Context
Parameters:
name - a Name value
prefix - a Name value
Returns:
a Name value
Throws:
NamingException - if an error occurs

close

public void close()
           throws NamingException
Do nothing

Specified by:
close in interface Context
Throws:
NamingException - if an error occurs

getNameParser

public NameParser getNameParser(Name name)
Return a NameParser for this Context.

Specified by:
getNameParser in interface Context
Parameters:
name - a Name value
Returns:
a NameParser value

getNameParser

public NameParser getNameParser(String name)
Return a NameParser for this Context.

Specified by:
getNameParser in interface Context
Parameters:
name - a Name value
Returns:
a NameParser value

getNameInNamespace

public String getNameInNamespace()
                          throws NamingException
Get the full name of this Context node by visiting it's ancestors back to root. NOTE: if this Context has a URL namespace then the URL prefix will be missing

Specified by:
getNameInNamespace in interface Context
Returns:
the full name of this Context
Throws:
NamingException - if an error occurs

addToEnvironment

public Object addToEnvironment(String propName,
                               Object propVal)
                        throws NamingException
Add an environment setting to this Context

Specified by:
addToEnvironment in interface Context
Parameters:
propName - name of the property to add
propVal - value of the property to add
Returns:
propVal or previous value of the property
Throws:
NamingException - if an error occurs

removeFromEnvironment

public Object removeFromEnvironment(String propName)
                             throws NamingException
Remove a property from this Context's environment.

Specified by:
removeFromEnvironment in interface Context
Parameters:
propName - name of property to remove
Returns:
value of property or null if it didn't exist
Throws:
NamingException - if an error occurs

getEnvironment

public Hashtable getEnvironment()
Get the environment of this Context.

Specified by:
getEnvironment in interface Context
Returns:
a copy of the environment of this Context.

addBinding

protected void addBinding(Name name,
                          Object obj)
                   throws NameAlreadyBoundException
Add a name to object binding to this Context.

Parameters:
name - a Name value
obj - an Object value
Throws:
NameAlreadyBoundException

getBinding

protected Binding getBinding(Name name)
Get a name to object binding from this Context

Parameters:
name - a Name value
Returns:
a Binding value

getBinding

protected Binding getBinding(String name)
Get a name to object binding from this Context

Parameters:
name - as a String
Returns:
null or the Binding

removeBinding

protected void removeBinding(Name name)

toCanonicalName

public Name toCanonicalName(Name name)
Remove leading or trailing empty components from name. Eg "/comp/env/" -> "comp/env"

Parameters:
name - the name to normalize
Returns:
normalized name

dump

public String dump()
Specified by:
dump in interface Dumpable

dump

public void dump(Appendable out,
                 String indent)
          throws IOException
Specified by:
dump in interface Dumpable
Throws:
IOException

addListener

public void addListener(NamingContext.Listener listener)

removeListener

public boolean removeListener(NamingContext.Listener listener)


Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.