Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mortbay.naming
Class NamingContext

    java.lang.Object
      org.mortbay.naming.NamingContext

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

    public class NamingContext

extends java.lang.Object
implements javax.naming.Context, java.lang.Cloneable

NamingContext

Implementation of Context interface.

#### Notes

All Names are expected to be Compound, not Composite.

#### Usage

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

###

    Nested Class Summary

     class
    NamingContext.BindingEnumeration

              BindingEnumeration

     class
    NamingContext.NameEnumeration

              NameEnumeration

    Field Summary

    protected  java.util.Hashtable
    _bindings

    protected  java.util.Hashtable
    _env

    protected  java.lang.String
    _name

    protected  javax.naming.Context
    _parent

    protected  javax.naming.NameParser
    _parser

    static java.util.Enumeration
    EMPTY_ENUM

    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

    NamingContext()

              Constructor

    NamingContext(java.util.Hashtable env)

              Creates a new NamingContext instance.

    NamingContext(java.util.Hashtable env,
                  java.lang.String name,
                  javax.naming.Context parent,
                  javax.naming.NameParser parser)

              Constructor

    Method Summary

    protected  void
    addBinding(javax.naming.Name name,
               java.lang.Object obj)

              Add a name to object binding to this Context.

     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)

              Not supported

     void
    destroySubcontext(java.lang.String name)

              Not supported

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

              Get a name to object binding from this Context

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

              Get a name to object binding from this Context

     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

     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

    protected  void
    removeBinding(javax.naming.Name name)

     java.lang.Object
    removeFromEnvironment(java.lang.String propName)

              Remove a property from this Context's environment.

     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
    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

    EMPTY_ENUM

    public static final java.util.Enumeration EMPTY_ENUM

    _parent

    protected javax.naming.Context _parent

    _name

    protected java.lang.String _name

    _env

    protected java.util.Hashtable _env

    _bindings

    protected java.util.Hashtable _bindings

    _parser

    protected javax.naming.NameParser _parser

    Constructor Detail

    NamingContext

    public NamingContext(java.util.Hashtable env,
                         java.lang.String name,
                         javax.naming.Context parent,
                         javax.naming.NameParser parser)

    Constructor

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

    NamingContext

    public NamingContext(java.util.Hashtable env)

    Creates a new NamingContext instance.

    Parameters:env - a Hashtable value

    NamingContext

    public NamingContext()

    Constructor

    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

    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 objectobj - 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 valueobj - 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

    Not supported

    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

    Not supported

    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 valueobj - 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 valueobj - 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 valuenewName - 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 valuenewName - 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 valueprefix - 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 valueprefix - 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 addpropVal - 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

    protected void addBinding(javax.naming.Name name,
                              java.lang.Object obj)

    Add a name to object binding to this Context.

    Parameters:name - a Name valueobj - an Object value

    getBinding

    protected 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

    protected 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

    protected 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

          Overview
          Package
        Class
          Use
          Tree
          Deprecated
          Index
          Help

     PREV CLASS
     NEXT CLASS

      FRAMES
     NO FRAMES

      SUMMARY: NESTED | FIELD | CONSTR | METHOD

    DETAIL: FIELD | CONSTR | METHOD

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