org.eclipse.jetty.jndi

## Class NamingContext

- java.lang.Object
- - org.eclipse.jetty.jndi.NamingContext

- All Implemented Interfaces:
    java.lang.Cloneable, javax.naming.Context, Dumpable

      public class NamingContext
      extends java.lang.Object
      implements javax.naming.Context, java.lang.Cloneable, Dumpable

  NamingContext

  Implementation of Context interface.

  #### Notes

  All Names are expected to be Compound, not Composite.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `NamingContext.Listener` Naming Context Listener.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.Map<java.lang.String,javax.naming.Binding>` | `_bindings`
    `protected java.util.Hashtable<java.lang.String,java.lang.Object>` | `_env`
    `protected java.lang.String` | `_name`
    `protected NamingContext` | `_parent`
    `protected javax.naming.NameParser` | `_parser`
    `static java.lang.String` | `LOCK_PROPERTY`
    `static java.lang.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

    Constructors
    Constructor and Description
    `NamingContext(java.util.Hashtable<java.lang.String,java.lang.Object> env, java.lang.String name, NamingContext parent, javax.naming.NameParser parser)` Constructor

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addBinding(javax.naming.Name name, java.lang.Object obj)` Add a name to object binding to this Context.
    `void` | `addListener(NamingContext.Listener listener)`
    `java.lang.Object` | `addToEnvironment(java.lang.String propName, java.lang.Object propVal)` Add an environment setting to this Context
    `void` | `bind(javax.naming.Name name, java.lang.Object obj)` Bind a name to an object
    `void` | `bind(java.lang.String name, java.lang.Object obj)` Bind a name (as a String) to an object
    `java.lang.Object` | `clone()` Clone this NamingContext
    `void` | `close()` Do nothing
    `javax.naming.Name` | `composeName(javax.naming.Name name, javax.naming.Name prefix)` Join two names together.
    `java.lang.String` | `composeName(java.lang.String name, java.lang.String prefix)` Join two names together.
    `javax.naming.Context` | `createSubcontext(javax.naming.Name name)` Create a context as a child of this one
    `javax.naming.Context` | `createSubcontext(java.lang.String name)` Create a Context as a child of this one
    `void` | `destroySubcontext(javax.naming.Name name)`
    `void` | `destroySubcontext(java.lang.String name)`
    `java.lang.String` | `dump()`
    `void` | `dump(java.lang.Appendable out, java.lang.String indent)`
    `javax.naming.Binding` | `getBinding(javax.naming.Name name)` Get a name to object binding from this Context
    `javax.naming.Binding` | `getBinding(java.lang.String name)` Get a name to object binding from this Context
    `java.util.Map<java.lang.String,javax.naming.Binding>` | `getBindings()`
    `java.util.Hashtable` | `getEnvironment()` Get the environment of this Context.
    `java.lang.String` | `getName()` Getter for _name
    `java.lang.String` | `getNameInNamespace()` Get the full name of this Context node by visiting it's ancestors back to root.
    `javax.naming.NameParser` | `getNameParser(javax.naming.Name name)` Return a NameParser for this Context.
    `javax.naming.NameParser` | `getNameParser(java.lang.String name)` Return a NameParser for this Context.
    `javax.naming.Context` | `getParent()` Getter for _parent
    `boolean` | `isLocked()`
    `javax.naming.NamingEnumeration` | `list(javax.naming.Name name)` List all names bound at Context named by Name
    `javax.naming.NamingEnumeration` | `list(java.lang.String name)` List all names bound at Context named by Name
    `javax.naming.NamingEnumeration` | `listBindings(javax.naming.Name name)` List all Bindings present at Context named by Name
    `javax.naming.NamingEnumeration` | `listBindings(java.lang.String name)` List all Bindings at Name
    `java.lang.Object` | `lookup(javax.naming.Name name)` Lookup a binding by name
    `java.lang.Object` | `lookup(java.lang.String name)` Lookup binding of an object by name
    `java.lang.Object` | `lookupLink(javax.naming.Name name)` Lookup link bound to name
    `java.lang.Object` | `lookupLink(java.lang.String name)` Lookup link bound to name
    `void` | `rebind(javax.naming.Name name, java.lang.Object obj)` Overwrite or create a binding
    `void` | `rebind(java.lang.String name, java.lang.Object obj)` Overwrite or create a binding from Name to Object
    `void` | `removeBinding(javax.naming.Name name)`
    `java.lang.Object` | `removeFromEnvironment(java.lang.String propName)` Remove a property from this Context's environment.
    `boolean` | `removeListener(NamingContext.Listener listener)`
    `void` | `rename(javax.naming.Name oldName, javax.naming.Name newName)` Not supported
    `void` | `rename(java.lang.String oldName, java.lang.String newName)` Not supported
    `void` | `setBindings(java.util.Map<java.lang.String,javax.naming.Binding> bindings)`
    `void` | `setEnv(java.util.Hashtable<java.lang.String,java.lang.Object> env)`
    `void` | `setNameParser(javax.naming.NameParser parser)` Setter for _parser
    `javax.naming.Name` | `toCanonicalName(javax.naming.Name name)` Remove leading or trailing empty components from name.
    `void` | `unbind(javax.naming.Name name)` Not supported.
    `void` | `unbind(java.lang.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 java.lang.String LOCK_PROPERTY

      See Also:
        Constant Field Values

    - #### UNLOCK_PROPERTY

          public static final java.lang.String UNLOCK_PROPERTY

      See Also:
        Constant Field Values

    - #### _env

          protected final java.util.Hashtable<java.lang.String,java.lang.Object> _env

    - #### _bindings

          protected java.util.Map<java.lang.String,javax.naming.Binding> _bindings

    - #### _parent

          protected NamingContext _parent

    - #### _name

          protected java.lang.String _name

    - #### _parser

          protected javax.naming.NameParser _parser

  - ### Constructor Detail

    - #### NamingContext

          public NamingContext(java.util.Hashtable<java.lang.String,java.lang.Object> env,
                       java.lang.String name,
                       NamingContext parent,
                       javax.naming.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

  - ### Method Detail

    - #### clone

          public java.lang.Object clone()
                                 throws java.lang.CloneNotSupportedException

      Clone this NamingContext
      Overrides:
        `clone` in class `java.lang.Object`
      Returns:
        copy of this NamingContext
      Throws:
        `java.lang.CloneNotSupportedException` - if an error occurs

    - #### getName

          public java.lang.String getName()

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

    - #### getParent

          public javax.naming.Context getParent()

      Getter for _parent
      Returns:
        parent Context

    - #### setNameParser

          public void setNameParser(javax.naming.NameParser parser)

      Setter for _parser

    - #### setEnv

          public void setEnv(java.util.Hashtable<java.lang.String,java.lang.Object> env)

    - #### getBindings

          public java.util.Map<java.lang.String,javax.naming.Binding> getBindings()

    - #### setBindings

          public void setBindings(java.util.Map<java.lang.String,javax.naming.Binding> bindings)

    - #### bind

          public void bind(javax.naming.Name name,
                  java.lang.Object obj)
                    throws javax.naming.NamingException

      Bind a name to an object
      Specified by:
        `bind` in interface `javax.naming.Context`
      Parameters:
        `name` - Name of the object
        `obj` - object to bind
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### bind

          public void bind(java.lang.String name,
                  java.lang.Object obj)
                    throws javax.naming.NamingException

      Bind a name (as a String) to an object
      Specified by:
        `bind` in interface `javax.naming.Context`
      Parameters:
        `name` - a `String` value
        `obj` - an `Object` value
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### createSubcontext

          public javax.naming.Context createSubcontext(javax.naming.Name name)
                                                throws javax.naming.NamingException

      Create a context as a child of this one
      Specified by:
        `createSubcontext` in interface `javax.naming.Context`
      Parameters:
        `name` - a `Name` value
      Returns:
        a `Context` value
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### createSubcontext

          public javax.naming.Context createSubcontext(java.lang.String name)
                                                throws javax.naming.NamingException

      Create a Context as a child of this one
      Specified by:
        `createSubcontext` in interface `javax.naming.Context`
      Parameters:
        `name` - a `String` value
      Returns:
        a `Context` value
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### destroySubcontext

          public void destroySubcontext(java.lang.String name)
                                 throws javax.naming.NamingException

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

    - #### destroySubcontext

          public void destroySubcontext(javax.naming.Name name)
                                 throws javax.naming.NamingException

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

    - #### lookup

          public java.lang.Object lookup(javax.naming.Name name)
                                  throws javax.naming.NamingException

      Lookup a binding by name
      Specified by:
        `lookup` in interface `javax.naming.Context`
      Parameters:
        `name` - name of bound object
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### lookup

          public java.lang.Object lookup(java.lang.String name)
                                  throws javax.naming.NamingException

      Lookup binding of an object by name
      Specified by:
        `lookup` in interface `javax.naming.Context`
      Parameters:
        `name` - name of bound object
      Returns:
        object bound to name
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### lookupLink

          public java.lang.Object lookupLink(javax.naming.Name name)
                                      throws javax.naming.NamingException

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

    - #### lookupLink

          public java.lang.Object lookupLink(java.lang.String name)
                                      throws javax.naming.NamingException

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

    - #### list

          public javax.naming.NamingEnumeration list(javax.naming.Name name)
                                              throws javax.naming.NamingException

      List all names bound at Context named by Name
      Specified by:
        `list` in interface `javax.naming.Context`
      Parameters:
        `name` - a `Name` value
      Returns:
        a `NamingEnumeration` value
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### list

          public javax.naming.NamingEnumeration list(java.lang.String name)
                                              throws javax.naming.NamingException

      List all names bound at Context named by Name
      Specified by:
        `list` in interface `javax.naming.Context`
      Parameters:
        `name` - a `Name` value
      Returns:
        a `NamingEnumeration` value
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### listBindings

          public javax.naming.NamingEnumeration listBindings(javax.naming.Name name)
                                                      throws javax.naming.NamingException

      List all Bindings present at Context named by Name
      Specified by:
        `listBindings` in interface `javax.naming.Context`
      Parameters:
        `name` - a `Name` value
      Returns:
        a `NamingEnumeration` value
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### listBindings

          public javax.naming.NamingEnumeration listBindings(java.lang.String name)
                                                      throws javax.naming.NamingException

      List all Bindings at Name
      Specified by:
        `listBindings` in interface `javax.naming.Context`
      Parameters:
        `name` - a `String` value
      Returns:
        a `NamingEnumeration` value
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### rebind

          public void rebind(javax.naming.Name name,
                    java.lang.Object obj)
                      throws javax.naming.NamingException

      Overwrite or create a binding
      Specified by:
        `rebind` in interface `javax.naming.Context`
      Parameters:
        `name` - a `Name` value
        `obj` - an `Object` value
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### rebind

          public void rebind(java.lang.String name,
                    java.lang.Object obj)
                      throws javax.naming.NamingException

      Overwrite or create a binding from Name to Object
      Specified by:
        `rebind` in interface `javax.naming.Context`
      Parameters:
        `name` - a `String` value
        `obj` - an `Object` value
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### unbind

          public void unbind(java.lang.String name)
                      throws javax.naming.NamingException

      Not supported.
      Specified by:
        `unbind` in interface `javax.naming.Context`
      Parameters:
        `name` - a `String` value
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### unbind

          public void unbind(javax.naming.Name name)
                      throws javax.naming.NamingException

      Not supported.
      Specified by:
        `unbind` in interface `javax.naming.Context`
      Parameters:
        `name` - a `String` value
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### rename

          public void rename(javax.naming.Name oldName,
                    javax.naming.Name newName)
                      throws javax.naming.NamingException

      Not supported
      Specified by:
        `rename` in interface `javax.naming.Context`
      Parameters:
        `oldName` - a `Name` value
        `newName` - a `Name` value
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### rename

          public void rename(java.lang.String oldName,
                    java.lang.String newName)
                      throws javax.naming.NamingException

      Not supported
      Specified by:
        `rename` in interface `javax.naming.Context`
      Parameters:
        `oldName` - a `Name` value
        `newName` - a `Name` value
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### composeName

          public javax.naming.Name composeName(javax.naming.Name name,
                                      javax.naming.Name prefix)
                                        throws javax.naming.NamingException

      Join two names together. These are treated as CompoundNames.
      Specified by:
        `composeName` in interface `javax.naming.Context`
      Parameters:
        `name` - a `Name` value
        `prefix` - a `Name` value
      Returns:
        a `Name` value
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### composeName

          public java.lang.String composeName(java.lang.String name,
                                     java.lang.String prefix)
                                       throws javax.naming.NamingException

      Join two names together. These are treated as CompoundNames.
      Specified by:
        `composeName` in interface `javax.naming.Context`
      Parameters:
        `name` - a `Name` value
        `prefix` - a `Name` value
      Returns:
        a `Name` value
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### close

          public void close()
                     throws javax.naming.NamingException

      Do nothing
      Specified by:
        `close` in interface `javax.naming.Context`
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### getNameParser

          public javax.naming.NameParser getNameParser(javax.naming.Name name)

      Return a NameParser for this Context.
      Specified by:
        `getNameParser` in interface `javax.naming.Context`
      Parameters:
        `name` - a `Name` value
      Returns:
        a `NameParser` value

    - #### getNameParser

          public javax.naming.NameParser getNameParser(java.lang.String name)

      Return a NameParser for this Context.
      Specified by:
        `getNameParser` in interface `javax.naming.Context`
      Parameters:
        `name` - a `Name` value
      Returns:
        a `NameParser` value

    - #### getNameInNamespace

          public java.lang.String getNameInNamespace()
                                              throws javax.naming.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 `javax.naming.Context`
      Returns:
        the full name of this Context
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### addToEnvironment

          public java.lang.Object addToEnvironment(java.lang.String propName,
                                          java.lang.Object propVal)
                                            throws javax.naming.NamingException

      Add an environment setting to this Context
      Specified by:
        `addToEnvironment` in interface `javax.naming.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:
        `javax.naming.NamingException` - if an error occurs

    - #### removeFromEnvironment

          public java.lang.Object removeFromEnvironment(java.lang.String propName)
                                                 throws javax.naming.NamingException

      Remove a property from this Context's environment.
      Specified by:
        `removeFromEnvironment` in interface `javax.naming.Context`
      Parameters:
        `propName` - name of property to remove
      Returns:
        value of property or null if it didn't exist
      Throws:
        `javax.naming.NamingException` - if an error occurs

    - #### getEnvironment

          public java.util.Hashtable getEnvironment()

      Get the environment of this Context.
      Specified by:
        `getEnvironment` in interface `javax.naming.Context`
      Returns:
        a copy of the environment of this Context.

    - #### addBinding

          public void addBinding(javax.naming.Name name,
                        java.lang.Object obj)
                          throws javax.naming.NameAlreadyBoundException

      Add a name to object binding to this Context.
      Parameters:
        `name` - a `Name` value
        `obj` - an `Object` value
      Throws:
        `javax.naming.NameAlreadyBoundException`

    - #### getBinding

          public javax.naming.Binding getBinding(javax.naming.Name name)

      Get a name to object binding from this Context
      Parameters:
        `name` - a `Name` value
      Returns:
        a `Binding` value

    - #### getBinding

          public javax.naming.Binding getBinding(java.lang.String name)

      Get a name to object binding from this Context
      Parameters:
        `name` - as a String
      Returns:
        null or the Binding

    - #### removeBinding

          public void removeBinding(javax.naming.Name name)

    - #### toCanonicalName

          public javax.naming.Name toCanonicalName(javax.naming.Name name)

      Remove leading or trailing empty components from name. Eg "/comp/env/" -> "comp/env"
      Parameters:
        `name` - the name to normalize
      Returns:
        normalized name

    - #### isLocked

          public boolean isLocked()

    - #### dump

          public java.lang.String dump()

      Specified by:
        `dump` in interface `Dumpable`

    - #### dump

          public void dump(java.lang.Appendable out,
                  java.lang.String indent)
                    throws java.io.IOException

      Specified by:
        `dump` in interface `Dumpable`
      Throws:
        `java.io.IOException`

    - #### addListener

          public void addListener(NamingContext.Listener listener)

    - #### removeListener

          public boolean removeListener(NamingContext.Listener listener)

Copyright © 2013 FuseSource, Corp.. All Rights Reserved.