Top Description Inners Fields Constructors Methods
org.mortbay.naming

public Class NamingContext

extends Object
implements Context, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, javax.naming.Context
Imports
java.util.Enumeration, .Hashtable, .NoSuchElementException, javax.naming.Binding, .CompoundName, .Context, .InitialContext, .LinkRef, .Name, .NameAlreadyBoundException, .NameClassPair, .NameNotFoundException, .NameParser, .NamingEnumeration, .NamingException, .NotContextException, .OperationNotSupportedException, .Reference, .Referenceable, javax.naming.spi.NamingManager, org.mortbay.log.Log

NamingContext

Implementation of Context interface.

Notes

All Names are expected to be Compound, not Composite.

Usage

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class
NamingContext.BindingEnumeration

BindingEnumeration

Implementation of NamingEnumeration

Notes

Used to return results of Context.listBindings();

Usage

public class
NamingContext.NameEnumeration

NameEnumeration

Implementation of NamingEnumeration interface.

Field Summary

Modifier and TypeField and Description
protected Hashtable<K, V>
protected Hashtable<K, V>
protected String
protected Context
protected NameParser
public static final Enumeration<E>
public static final String
public static final String

Constructor Summary

AccessConstructor and Description
public
NamingContext(Hashtable<K, V>
environment properties
env
,
String
relative name of this context
name
,
Context
immediate ancestor Context (can be null)
parent
,
NameParser
NameParser for this Context
parser
)

Constructor

public
NamingContext(Hashtable<K, V>
a Hashtable value
env
)

Creates a new NamingContext instance.

public
NamingContext()

Constructor

Method Summary

Modifier and TypeMethod and Description
protected void
addBinding(Name
a Name value
name
,
Object
an Object value
obj
)

Add a name to object binding to this Context.

public Object

Returns:

propVal or previous value of the property
addToEnvironment
(String
name of the property to add
propName
,
Object
value of the property to add
propVal
)

Implements javax.naming.Context.addToEnvironment.

Add an environment setting to this Context
public void
bind(Name
Name of the object
name
,
Object
object to bind
obj
)

Implements javax.naming.Context.bind.

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

Implements javax.naming.Context.bind.

Bind a name (as a String) to an object
public Object

Returns:

copy of this NamingContext
clone
()

Overrides java.lang.Object.clone.

Clone this NamingContext
public void
close()

Implements javax.naming.Context.close.

Do nothing
public Name

Returns:

a Name value
composeName
(Name
a Name value
name
,
Name
a Name value
prefix
)

Implements javax.naming.Context.composeName.

Join two names together.
public String

Returns:

a Name value
composeName
(String
a Name value
name
,
String
a Name value
prefix
)

Implements javax.naming.Context.composeName.

Join two names together.
public Context

Returns:

a Context value
createSubcontext
(Name
a Name value
name
)

Implements javax.naming.Context.createSubcontext.

Create a context as a child of this one
public Context

Returns:

a Context value
createSubcontext
(String
a String value
name
)

Implements javax.naming.Context.createSubcontext.

Create a Context as a child of this one
public void
destroySubcontext(String
name of subcontext to remove
name
)

Implements javax.naming.Context.destroySubcontext.

Not supported
public void
destroySubcontext(Name
name of subcontext to remove
name
)

Implements javax.naming.Context.destroySubcontext.

Not supported
protected Binding

Returns:

a Binding value
getBinding
(Name
a Name value
name
)

Get a name to object binding from this Context

protected Binding

Returns:

null or the Binding
getBinding
(String
as a String
name
)

Get a name to object binding from this Context

public Hashtable<K, V>

Returns:

a copy of the environment of this Context.
getEnvironment
()

Implements javax.naming.Context.getEnvironment.

Get the environment of this Context.
public String

Returns:

name of this Context (relative, not absolute)
getName
()

Getter for _name

public String

Returns:

the full name of this Context
getNameInNamespace
()

Implements javax.naming.Context.getNameInNamespace.

Get the full name of this Context node by visiting it's ancestors back to root.
public NameParser

Returns:

a NameParser value
getNameParser
(Name
a Name value
name
)

Implements javax.naming.Context.getNameParser.

Return a NameParser for this Context.
public NameParser

Returns:

a NameParser value
getNameParser
(String
a Name value
name
)

Implements javax.naming.Context.getNameParser.

Return a NameParser for this Context.
public Context

Returns:

parent Context
getParent
()

Getter for _parent

private boolean
public NamingEnumeration<T>

Returns:

a NamingEnumeration value
list
(Name
a Name value
name
)

Implements javax.naming.Context.list.

List all names bound at Context named by Name
public NamingEnumeration<T>

Returns:

a NamingEnumeration value
list
(String
a Name value
name
)

Implements javax.naming.Context.list.

List all names bound at Context named by Name
public NamingEnumeration<T>

Returns:

a NamingEnumeration value
listBindings
(Name
a Name value
name
)

Implements javax.naming.Context.listBindings.

List all Bindings present at Context named by Name
public NamingEnumeration<T>

Returns:

a NamingEnumeration value
listBindings
(String
a String value
name
)

Implements javax.naming.Context.listBindings.

List all Bindings at Name
public Object
lookup(Name
name of bound object
name
)

Implements javax.naming.Context.lookup.

Lookup a binding by name
public Object

Returns:

object bound to name
lookup
(String
name of bound object
name
)

Implements javax.naming.Context.lookup.

Lookup binding of an object by name
public void
rebind(Name
a Name value
name
,
Object
an Object value
obj
)

Implements javax.naming.Context.rebind.

Overwrite or create a binding
public void
rebind(String
a String value
name
,
Object
an Object value
obj
)

Implements javax.naming.Context.rebind.

Overwrite or create a binding from Name to Object
protected void
public Object

Returns:

value of property or null if it didn't exist
removeFromEnvironment
(String
name of property to remove
propName
)

Implements javax.naming.Context.removeFromEnvironment.

Remove a property from this Context's environment.
public void
rename(Name
a Name value
oldName
,
Name
a Name value
newName
)

Implements javax.naming.Context.rename.

Not supported
public void
rename(String
a Name value
oldName
,
String
a Name value
newName
)

Implements javax.naming.Context.rename.

Not supported
public void
setNameParser(NameParser parser)

Setter for _parser

public Name

Returns:

normalized name
toCanonicalName
(Name
the name to normalize
name
)

Remove leading or trailing empty components from name.

public void
unbind(String
a String value
name
)

Implements javax.naming.Context.unbind.

Not supported.
public void
unbind(Name
a String value
name
)

Implements javax.naming.Context.unbind.

Not supported.
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_bindingsback to summary
protected Hashtable<K, V> _bindings
_envback to summary
protected Hashtable<K, V> _env
_nameback to summary
protected String _name
_parentback to summary
protected Context _parent
_parserback to summary
protected NameParser _parser
EMPTY_ENUMback to summary
public static final Enumeration<E> EMPTY_ENUM
LOCK_PROPERTYback to summary
public static final String LOCK_PROPERTY
UNLOCK_PROPERTYback to summary
public static final String UNLOCK_PROPERTY

Constructor Detail

NamingContextback to summary
public NamingContext(Hashtable<K, V> env, String name, Context parent, NameParser parser)

Constructor

Parameters
env:Hashtable<K, V>

environment properties

name:String

relative name of this context

parent:Context

immediate ancestor Context (can be null)

parser:NameParser

NameParser for this Context

NamingContextback to summary
public NamingContext(Hashtable<K, V> env)

Creates a new NamingContext instance.

Parameters
env:Hashtable<K, V>

a Hashtable value

NamingContextback to summary
public NamingContext()

Constructor

Method Detail

addBindingback to summary
protected void addBinding(Name name, Object obj)

Add a name to object binding to this Context.

Parameters
name:Name

a Name value

obj:Object

an Object value

addToEnvironmentback to summary
public Object addToEnvironment(String propName, Object propVal) throws NamingException

Implements javax.naming.Context.addToEnvironment.

Add an environment setting to this Context

Parameters
propName:String

name of the property to add

propVal:Object

value of the property to add

Returns:Object

propVal or previous value of the property

Exceptions
NamingException:
if an error occurs
bindback to summary
public void bind(Name name, Object obj) throws NamingException

Implements javax.naming.Context.bind.

Bind a name to an object

Parameters
name:Name

Name of the object

obj:Object

object to bind

Exceptions
NamingException:
if an error occurs
bindback to summary
public void bind(String name, Object obj) throws NamingException

Implements javax.naming.Context.bind.

Bind a name (as a String) to an object

Parameters
name:String

a String value

obj:Object

an Object value

Exceptions
NamingException:
if an error occurs
cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides java.lang.Object.clone.

Clone this NamingContext

Returns:Object

copy of this NamingContext

Exceptions
CloneNotSupportedException:
if an error occurs
closeback to summary
public void close() throws NamingException

Implements javax.naming.Context.close.

Do nothing

Exceptions
NamingException:
if an error occurs
composeNameback to summary
public Name composeName(Name name, Name prefix) throws NamingException

Implements javax.naming.Context.composeName.

Join two names together. These are treated as CompoundNames.

Parameters
name:Name

a Name value

prefix:Name

a Name value

Returns:Name

a Name value

Exceptions
NamingException:
if an error occurs
composeNameback to summary
public String composeName(String name, String prefix) throws NamingException

Implements javax.naming.Context.composeName.

Join two names together. These are treated as CompoundNames.

Parameters
name:String

a Name value

prefix:String

a Name value

Returns:String

a Name value

Exceptions
NamingException:
if an error occurs
createSubcontextback to summary
public Context createSubcontext(Name name) throws NamingException

Implements javax.naming.Context.createSubcontext.

Create a context as a child of this one

Parameters
name:Name

a Name value

Returns:Context

a Context value

Exceptions
NamingException:
if an error occurs
createSubcontextback to summary
public Context createSubcontext(String name) throws NamingException

Implements javax.naming.Context.createSubcontext.

Create a Context as a child of this one

Parameters
name:String

a String value

Returns:Context

a Context value

Exceptions
NamingException:
if an error occurs
destroySubcontextback to summary
public void destroySubcontext(String name) throws NamingException

Implements javax.naming.Context.destroySubcontext.

Not supported

Parameters
name:String

name of subcontext to remove

Exceptions
NamingException:
if an error occurs
destroySubcontextback to summary
public void destroySubcontext(Name name) throws NamingException

Implements javax.naming.Context.destroySubcontext.

Not supported

Parameters
name:Name

name of subcontext to remove

Exceptions
NamingException:
if an error occurs
getBindingback to summary
protected Binding getBinding(Name name)

Get a name to object binding from this Context

Parameters
name:Name

a Name value

Returns:Binding

a Binding value

getBindingback to summary
protected Binding getBinding(String name)

Get a name to object binding from this Context

Parameters
name:String

as a String

Returns:Binding

null or the Binding

getEnvironmentback to summary
public Hashtable<K, V> getEnvironment()

Implements javax.naming.Context.getEnvironment.

Get the environment of this Context.

Returns:Hashtable<K, V>

a copy of the environment of this Context.

getNameback to summary
public String getName()

Getter for _name

Returns:String

name of this Context (relative, not absolute)

getNameInNamespaceback to summary
public String getNameInNamespace() throws NamingException

Implements javax.naming.Context.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:String

the full name of this Context

Exceptions
NamingException:
if an error occurs
getNameParserback to summary
public NameParser getNameParser(Name name)

Implements javax.naming.Context.getNameParser.

Return a NameParser for this Context.

Parameters
name:Name

a Name value

Returns:NameParser

a NameParser value

getNameParserback to summary
public NameParser getNameParser(String name)

Implements javax.naming.Context.getNameParser.

Return a NameParser for this Context.

Parameters
name:String

a Name value

Returns:NameParser

a NameParser value

getParentback to summary
public Context getParent()

Getter for _parent

Returns:Context

parent Context

isLockedback to summary
private boolean isLocked()
listback to summary
public NamingEnumeration<T> list(Name name) throws NamingException

Implements javax.naming.Context.list.

List all names bound at Context named by Name

Parameters
name:Name

a Name value

Returns:NamingEnumeration<T>

a NamingEnumeration value

Exceptions
NamingException:
if an error occurs
listback to summary
public NamingEnumeration<T> list(String name) throws NamingException

Implements javax.naming.Context.list.

List all names bound at Context named by Name

Parameters
name:String

a Name value

Returns:NamingEnumeration<T>

a NamingEnumeration value

Exceptions
NamingException:
if an error occurs
listBindingsback to summary
public NamingEnumeration<T> listBindings(Name name) throws NamingException

Implements javax.naming.Context.listBindings.

List all Bindings present at Context named by Name

Parameters
name:Name

a Name value

Returns:NamingEnumeration<T>

a NamingEnumeration value

Exceptions
NamingException:
if an error occurs
listBindingsback to summary
public NamingEnumeration<T> listBindings(String name) throws NamingException

Implements javax.naming.Context.listBindings.

List all Bindings at Name

Parameters
name:String

a String value

Returns:NamingEnumeration<T>

a NamingEnumeration value

Exceptions
NamingException:
if an error occurs
lookupback to summary
public Object lookup(Name name) throws NamingException

Implements javax.naming.Context.lookup.

Lookup a binding by name

Parameters
name:Name

name of bound object

Returns:Object

Doc from javax.naming.Context.lookup.

the object bound to name

Exceptions
NamingException:
if an error occurs
lookupback to summary
public Object lookup(String name) throws NamingException

Implements javax.naming.Context.lookup.

Lookup binding of an object by name

Parameters
name:String

name of bound object

Returns:Object

object bound to name

Exceptions
NamingException:
if an error occurs
rebindback to summary
public void rebind(Name name, Object obj) throws NamingException

Implements javax.naming.Context.rebind.

Overwrite or create a binding

Parameters
name:Name

a Name value

obj:Object

an Object value

Exceptions
NamingException:
if an error occurs
rebindback to summary
public void rebind(String name, Object obj) throws NamingException

Implements javax.naming.Context.rebind.

Overwrite or create a binding from Name to Object

Parameters
name:String

a String value

obj:Object

an Object value

Exceptions
NamingException:
if an error occurs
removeBindingback to summary
protected void removeBinding(Name name)
removeFromEnvironmentback to summary
public Object removeFromEnvironment(String propName) throws NamingException

Implements javax.naming.Context.removeFromEnvironment.

Remove a property from this Context's environment.

Parameters
propName:String

name of property to remove

Returns:Object

value of property or null if it didn't exist

Exceptions
NamingException:
if an error occurs
renameback to summary
public void rename(Name oldName, Name newName) throws NamingException

Implements javax.naming.Context.rename.

Not supported

Parameters
oldName:Name

a Name value

newName:Name

a Name value

Exceptions
NamingException:
if an error occurs
renameback to summary
public void rename(String oldName, String newName) throws NamingException

Implements javax.naming.Context.rename.

Not supported

Parameters
oldName:String

a Name value

newName:String

a Name value

Exceptions
NamingException:
if an error occurs
setNameParserback to summary
public void setNameParser(NameParser parser)

Setter for _parser

toCanonicalNameback to summary
public Name toCanonicalName(Name name)

Remove leading or trailing empty components from name. Eg "/comp/env/" -> "comp/env"

Parameters
name:Name

the name to normalize

Returns:Name

normalized name

unbindback to summary
public void unbind(String name) throws NamingException

Implements javax.naming.Context.unbind.

Not supported.

Parameters
name:String

a String value

Exceptions
NamingException:
if an error occurs
unbindback to summary
public void unbind(Name name) throws NamingException

Implements javax.naming.Context.unbind.

Not supported.

Parameters
name:Name

a String value

Exceptions
NamingException:
if an error occurs
org.mortbay.naming back to summary

public Class NamingContext.BindingEnumeration

extends Object
implements NamingEnumeration
Class Inheritance
All Implemented Interfaces
javax.naming.NamingEnumeration, java.util.Enumeration

BindingEnumeration

Implementation of NamingEnumeration

Notes

Used to return results of Context.listBindings();

Usage

Field Summary

Modifier and TypeField and Description
pack-priv Enumeration<E>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements javax.naming.NamingEnumeration.close.

Closes this enumeration.
public boolean
hasMore()

Implements javax.naming.NamingEnumeration.hasMore.

Determines whether there are any more elements in the enumeration.
public boolean
hasMoreElements()

Implements java.util.Enumeration.hasMoreElements.

Tests if this enumeration contains more elements.
public Object
next()

Implements javax.naming.NamingEnumeration.next.

Retrieves the next element in the enumeration.
public Object
nextElement()

Implements java.util.Enumeration.nextElement.

Returns the next element of this enumeration if this enumeration object has at least one more element to provide.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_delegateback to summary
pack-priv Enumeration<E> _delegate

Constructor Detail

BindingEnumerationback to summary
public BindingEnumeration(Enumeration<E> e)

Method Detail

closeback to summary
public void close() throws NamingException

Implements javax.naming.NamingEnumeration.close.

Doc from javax.naming.NamingEnumeration.close.

Closes this enumeration. After this method has been invoked on this enumeration, the enumeration becomes invalid and subsequent invocation of any of its methods will yield undefined results. This method is intended for aborting an enumeration to free up resources. If an enumeration proceeds to the end--that is, until hasMoreElements() or hasMore() returns false-- resources will be freed up automatically and there is no need to explicitly call close().

This method indicates to the service provider that it is free to release resources associated with the enumeration, and can notify servers to cancel any outstanding requests. The close() method is a hint to implementations for managing their resources. Implementations are encouraged to use appropriate algorithms to manage their resources when client omits the close() calls.

Exceptions
NamingException:
If a naming exception is encountered while closing the enumeration.
hasMoreback to summary
public boolean hasMore() throws NamingException

Implements javax.naming.NamingEnumeration.hasMore.

Doc from javax.naming.NamingEnumeration.hasMore.

Determines whether there are any more elements in the enumeration. This method allows naming exceptions encountered while determining whether there are more elements to be caught and handled by the application.

Returns:boolean

true if there is more in the enumeration ; false otherwise.

Exceptions
NamingException:
If a naming exception is encountered while attempting to determine whether there is another element in the enumeration. See NamingException and its subclasses for the possible naming exceptions.
hasMoreElementsback to summary
public boolean hasMoreElements()

Implements java.util.Enumeration.hasMoreElements.

Doc from java.util.Enumeration.hasMoreElements.

Tests if this enumeration contains more elements.

Returns:boolean

true if and only if this enumeration object contains at least one more element to provide; false otherwise.

nextback to summary
public Object next() throws NamingException

Implements javax.naming.NamingEnumeration.next.

Doc from javax.naming.NamingEnumeration.next.

Retrieves the next element in the enumeration. This method allows naming exceptions encountered while retrieving the next element to be caught and handled by the application.

Note that next() can also throw the runtime exception NoSuchElementException to indicate that the caller is attempting to enumerate beyond the end of the enumeration. This is different from a NamingException, which indicates that there was a problem in obtaining the next element, for example, due to a referral or server unavailability, etc.

Returns:Object

The possibly null element in the enumeration. null is only valid for enumerations that can return null (e.g. Attribute.getAll() returns an enumeration of attribute values, and an attribute value can be null).

Exceptions
NamingException:
If a naming exception is encountered while attempting to retrieve the next element. See NamingException and its subclasses for the possible naming exceptions.
nextElementback to summary
public Object nextElement()

Implements java.util.Enumeration.nextElement.

Doc from java.util.Enumeration.nextElement.

Returns the next element of this enumeration if this enumeration object has at least one more element to provide.

Returns:Object

the next element of this enumeration.

org.mortbay.naming back to summary

public Class NamingContext.NameEnumeration

extends Object
implements NamingEnumeration
Class Inheritance
All Implemented Interfaces
javax.naming.NamingEnumeration, java.util.Enumeration

NameEnumeration

Implementation of NamingEnumeration interface.

Notes

Used for returning results of Context.list();

Usage

Field Summary

Modifier and TypeField and Description
pack-priv Enumeration<E>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements javax.naming.NamingEnumeration.close.

Closes this enumeration.
public boolean
hasMore()

Implements javax.naming.NamingEnumeration.hasMore.

Determines whether there are any more elements in the enumeration.
public boolean
hasMoreElements()

Implements java.util.Enumeration.hasMoreElements.

Tests if this enumeration contains more elements.
public Object
next()

Implements javax.naming.NamingEnumeration.next.

Retrieves the next element in the enumeration.
public Object
nextElement()

Implements java.util.Enumeration.nextElement.

Returns the next element of this enumeration if this enumeration object has at least one more element to provide.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_delegateback to summary
pack-priv Enumeration<E> _delegate

Constructor Detail

NameEnumerationback to summary
public NameEnumeration(Enumeration<E> e)

Method Detail

closeback to summary
public void close() throws NamingException

Implements javax.naming.NamingEnumeration.close.

Doc from javax.naming.NamingEnumeration.close.

Closes this enumeration. After this method has been invoked on this enumeration, the enumeration becomes invalid and subsequent invocation of any of its methods will yield undefined results. This method is intended for aborting an enumeration to free up resources. If an enumeration proceeds to the end--that is, until hasMoreElements() or hasMore() returns false-- resources will be freed up automatically and there is no need to explicitly call close().

This method indicates to the service provider that it is free to release resources associated with the enumeration, and can notify servers to cancel any outstanding requests. The close() method is a hint to implementations for managing their resources. Implementations are encouraged to use appropriate algorithms to manage their resources when client omits the close() calls.

Exceptions
NamingException:
If a naming exception is encountered while closing the enumeration.
hasMoreback to summary
public boolean hasMore() throws NamingException

Implements javax.naming.NamingEnumeration.hasMore.

Doc from javax.naming.NamingEnumeration.hasMore.

Determines whether there are any more elements in the enumeration. This method allows naming exceptions encountered while determining whether there are more elements to be caught and handled by the application.

Returns:boolean

true if there is more in the enumeration ; false otherwise.

Exceptions
NamingException:
If a naming exception is encountered while attempting to determine whether there is another element in the enumeration. See NamingException and its subclasses for the possible naming exceptions.
hasMoreElementsback to summary
public boolean hasMoreElements()

Implements java.util.Enumeration.hasMoreElements.

Doc from java.util.Enumeration.hasMoreElements.

Tests if this enumeration contains more elements.

Returns:boolean

true if and only if this enumeration object contains at least one more element to provide; false otherwise.

nextback to summary
public Object next() throws NamingException

Implements javax.naming.NamingEnumeration.next.

Doc from javax.naming.NamingEnumeration.next.

Retrieves the next element in the enumeration. This method allows naming exceptions encountered while retrieving the next element to be caught and handled by the application.

Note that next() can also throw the runtime exception NoSuchElementException to indicate that the caller is attempting to enumerate beyond the end of the enumeration. This is different from a NamingException, which indicates that there was a problem in obtaining the next element, for example, due to a referral or server unavailability, etc.

Returns:Object

The possibly null element in the enumeration. null is only valid for enumerations that can return null (e.g. Attribute.getAll() returns an enumeration of attribute values, and an attribute value can be null).

Exceptions
NamingException:
If a naming exception is encountered while attempting to retrieve the next element. See NamingException and its subclasses for the possible naming exceptions.
nextElementback to summary
public Object nextElement()

Implements java.util.Enumeration.nextElement.

Doc from java.util.Enumeration.nextElement.

Returns the next element of this enumeration if this enumeration object has at least one more element to provide.

Returns:Object

the next element of this enumeration.