org.mortbay.jndi

Class NamingContext

public class NamingContext extends Object implements Context, Cloneable

NamingContext

Implementation of Context interface.

Notes

All Names are expected to be Compound, not Composite.

Usage

   
Nested Class Summary
classNamingContext.BindingEnumeration
BindingEnumeration

Implementation of NamingEnumeration

Notes

Used to return results of Context.listBindings();

Usage

classNamingContext.NameEnumeration
NameEnumeration

Implementation of NamingEnumeration interface.

Field Summary
static EnumerationEMPTY_ENUM
static StringIMMUTABLE_PROPERTY
protected Hashtable_bindings
protected Hashtable_env
protected String_name
protected Context_parent
protected NameParser_parser
Constructor Summary
NamingContext(Hashtable env, String name, Context parent, NameParser parser)
Constructor
NamingContext(Hashtable env)
Creates a new NamingContext instance.
NamingContext()
Constructor
Method Summary
protected voidaddBinding(Name name, Object obj)
Add a name to object binding to this Context.
ObjectaddToEnvironment(String propName, Object propVal)
Add an environment setting to this Context
voidbind(Name name, Object obj)
Bind a name to an object
voidbind(String name, Object obj)
Bind a name (as a String) to an object
Objectclone()
Clone this NamingContext
voidclose()
Do nothing
NamecomposeName(Name name, Name prefix)
Join two names together.
StringcomposeName(String name, String prefix)
Join two names together.
ContextcreateSubcontext(Name name)
Create a context as a child of this one
ContextcreateSubcontext(String name)
Create a Context as a child of this one
voiddestroySubcontext(String name)
Not supported
voiddestroySubcontext(Name name)
Not supported
protected BindinggetBinding(Name name)
Get a name to object binding from this Context
protected BindinggetBinding(String name)
Get a name to object binding from this Context
HashtablegetEnvironment()
Get the environment of this Context.
StringgetName()
Getter for _name
StringgetNameInNamespace()
Get the full name of this Context node by visiting it's ancestors back to root.
NameParsergetNameParser(Name name)
Return a NameParser for this Context.
NameParsergetNameParser(String name)
Return a NameParser for this Context.
ContextgetParent()
Getter for _parent
NamingEnumerationlist(Name name)
List all names bound at Context named by Name
NamingEnumerationlist(String name)
List all names bound at Context named by Name
NamingEnumerationlistBindings(Name name)
List all Bindings present at Context named by Name
NamingEnumerationlistBindings(String name)
List all Bindings at Name
Objectlookup(Name name)
Lookup a binding by name
Objectlookup(String name)
Lookup binding of an object by name
ObjectlookupLink(Name name)
Lookup link bound to name
ObjectlookupLink(String name)
Lookup link bound to name
voidrebind(Name name, Object obj)
Overwrite or create a binding
voidrebind(String name, Object obj)
Overwrite or create a binding from Name to Object
ObjectremoveFromEnvironment(String propName)
Remove a property from this Context's environment.
voidrename(Name oldName, Name newName)
Not supported
voidrename(String oldName, String newName)
Not supported
voidsetNameParser(NameParser parser)
Setter for _parser
NametoCanonicalName(Name name)
Remove leading or trailing empty components from name.
voidunbind(String name)
Not supported.
voidunbind(Name name)
Not supported.

Field Detail

EMPTY_ENUM

public static final Enumeration EMPTY_ENUM

IMMUTABLE_PROPERTY

public static final String IMMUTABLE_PROPERTY

_bindings

protected Hashtable _bindings

_env

protected Hashtable _env

_name

protected String _name

_parent

protected Context _parent

_parser

protected NameParser _parser

Constructor Detail

NamingContext

public NamingContext(Hashtable env, String name, Context 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 env)
Creates a new NamingContext instance.

Parameters: env a Hashtable value

NamingContext

public NamingContext()
Constructor

Method Detail

addBinding

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

Parameters: name a Name value obj an Object value

addToEnvironment

public Object addToEnvironment(String propName, Object propVal)
Add an environment setting to this 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

bind

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

Parameters: name Name of the object obj object to bind

Throws: NamingException if an error occurs

bind

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

Parameters: name a String value obj an Object value

Throws: NamingException if an error occurs

clone

public Object clone()
Clone this NamingContext

Returns: copy of this NamingContext

Throws: CloneNotSupportedException if an error occurs

close

public void close()
Do nothing

Throws: NamingException if an error occurs

composeName

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

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)
Join two names together. These are treated as CompoundNames.

Parameters: name a Name value prefix a Name value

Returns: a Name value

Throws: NamingException if an error occurs

createSubcontext

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

Parameters: name a Name value

Returns: a Context value

Throws: NamingException if an error occurs

createSubcontext

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

Parameters: name a String value

Returns: a Context value

Throws: NamingException if an error occurs

destroySubcontext

public void destroySubcontext(String name)
Not supported

Parameters: name name of subcontext to remove

Throws: NamingException if an error occurs

destroySubcontext

public void destroySubcontext(Name name)
Not supported

Parameters: name name of subcontext to remove

Throws: NamingException if an error occurs

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

getEnvironment

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

Returns: a copy of the environment of this Context.

getName

public String getName()
Getter for _name

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

getNameInNamespace

public String getNameInNamespace()
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

Returns: the full name of this Context

Throws: NamingException if an error occurs

getNameParser

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

Parameters: name a Name value

Returns: a NameParser value

getNameParser

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

Parameters: name a Name value

Returns: a NameParser value

getParent

public Context getParent()
Getter for _parent

Returns: parent Context

list

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

Parameters: name a Name value

Returns: a NamingEnumeration value

Throws: NamingException if an error occurs

list

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

Parameters: name a Name value

Returns: a NamingEnumeration value

Throws: NamingException if an error occurs

listBindings

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

Parameters: name a Name value

Returns: a NamingEnumeration value

Throws: NamingException if an error occurs

listBindings

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

Parameters: name a String value

Returns: a NamingEnumeration value

Throws: NamingException if an error occurs

lookup

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

Parameters: name name of bound object

Throws: NamingException if an error occurs

lookup

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

Parameters: name name of bound object

Returns: object bound to name

Throws: NamingException if an error occurs

lookupLink

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

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)
Lookup link bound to name

Parameters: name name of link binding

Returns: LinkRef or plain object bound at name

Throws: NamingException if an error occurs

rebind

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

Parameters: name a Name value obj an Object value

Throws: NamingException if an error occurs

rebind

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

Parameters: name a String value obj an Object value

Throws: NamingException if an error occurs

removeFromEnvironment

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

Parameters: propName name of property to remove

Returns: value of property or null if it didn't exist

Throws: NamingException if an error occurs

rename

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

Parameters: oldName a Name value newName a Name value

Throws: NamingException if an error occurs

rename

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

Parameters: oldName a Name value newName a Name value

Throws: NamingException if an error occurs

setNameParser

public void setNameParser(NameParser parser)
Setter for _parser

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

unbind

public void unbind(String name)
Not supported.

Parameters: name a String value

Throws: NamingException if an error occurs

unbind

public void unbind(Name name)
Not supported.

Parameters: name a String value

Throws: NamingException if an error occurs

Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.