public abstract class

PartialCompositeContext

extends Object
implements Context Resolver
java.lang.Object
   ↳ com.sun.jndi.toolkit.ctx.PartialCompositeContext
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

PartialCompositeContext implements Context operations on composite names using implementations of the p_ interfaces defined by its subclasses. The main purpose provided by this class is that it deals with partial resolutions and continuations, so that callers of the Context operation don't have to. Types of clients that will be direct subclasses of PartialCompositeContext may be service providers that implement one of the JNDI protocols, but which do not deal with continuations. Usually, service providers will be using one of the subclasses of PartialCompositeContext.

Summary

Constants
int _ATOMIC
int _COMPONENT
int _PARTIAL
[Expand]
Inherited Constants
From interface javax.naming.Context
Fields
protected int _contextType
Protected Constructors
PartialCompositeContext()
Public Methods
void bind(Name name, Object newObj)
Binds a name to an object.
void bind(String name, Object newObj)
Binds a name to an object.
String composeName(String name, String prefix)
Composes the name of this context with a name relative to this context.
Name composeName(Name name, Name prefix)
This default implementation simply concatenates the two names.
Context createSubcontext(Name name)
Creates and binds a new context.
Context createSubcontext(String name)
Creates and binds a new context.
void destroySubcontext(Name name)
Destroys the named context and removes it from the namespace.
void destroySubcontext(String name)
Destroys the named context and removes it from the namespace.
NameParser getNameParser(Name name)
Retrieves the parser associated with the named context.
NameParser getNameParser(String name)
Retrieves the parser associated with the named context.
NamingEnumeration<NameClassPair> list(String name)
Enumerates the names bound in the named context, along with the class names of objects bound to them.
NamingEnumeration<NameClassPair> list(Name name)
Enumerates the names bound in the named context, along with the class names of objects bound to them.
NamingEnumeration<Binding> listBindings(Name name)
Enumerates the names bound in the named context, along with the objects bound to them.
NamingEnumeration<Binding> listBindings(String name)
Enumerates the names bound in the named context, along with the objects bound to them.
Object lookup(String name)
Retrieves the named object.
Object lookup(Name name)
Retrieves the named object.
Object lookupLink(String name)
Retrieves the named object, following links except for the terminal atomic component of the name.
Object lookupLink(Name name)
Retrieves the named object, following links except for the terminal atomic component of the name.
void rebind(String name, Object newObj)
Binds a name to an object, overwriting any existing binding.
void rebind(Name name, Object newObj)
Binds a name to an object, overwriting any existing binding.
void rename(String oldName, String newName)
Binds a new name to the object bound to an old name, and unbinds the old name.
void rename(Name oldName, Name newName)
Binds a new name to the object bound to an old name, and unbinds the old name.
ResolveResult resolveToClass(Name name, Class<? extends Context> contextType)
Partially resolves a name.
ResolveResult resolveToClass(String name, Class<? extends Context> contextType)
Partially resolves a name.
void unbind(Name name)
Unbinds the named object.
void unbind(String name)
Unbinds the named object.
Protected Methods
static boolean allEmpty(Name name)
Tests whether a name contains a nonempty component.
static PartialCompositeContext getPCContext(Continuation cont)
Retrieves a PartialCompositeContext for the resolved object in cont.
abstract void p_bind(Name name, Object obj, Continuation cont)
abstract Context p_createSubcontext(Name name, Continuation cont)
abstract void p_destroySubcontext(Name name, Continuation cont)
Hashtable p_getEnvironment()
A cheap way of getting the environment.
abstract NameParser p_getNameParser(Name name, Continuation cont)
abstract NamingEnumeration p_list(Name name, Continuation cont)
abstract NamingEnumeration p_listBindings(Name name, Continuation cont)
abstract Object p_lookup(Name name, Continuation cont)
abstract Object p_lookupLink(Name name, Continuation cont)
abstract void p_rebind(Name name, Object obj, Continuation cont)
abstract void p_rename(Name oldname, Name newname, Continuation cont)
abstract ResolveResult p_resolveToClass(Name name, Class contextType, Continuation cont)
abstract void p_unbind(Name name, Continuation cont)
[Expand]
Inherited Methods
From class java.lang.Object
From interface javax.naming.Context
From interface javax.naming.spi.Resolver

Constants

protected static final int _ATOMIC

Constant Value: 3 (0x00000003)

protected static final int _COMPONENT

Constant Value: 2 (0x00000002)

protected static final int _PARTIAL

Constant Value: 1 (0x00000001)

Fields

protected int _contextType

Protected Constructors

protected PartialCompositeContext ()

Public Methods

public void bind (Name name, Object newObj)

Binds a name to an object. All intermediate contexts and the target context (that named by all but terminal atomic component of the name) must already exist.

Parameters
name the name to bind; may not be empty
newObj the object to bind; possibly null

public void bind (String name, Object newObj)

Binds a name to an object. See bind(Name, Object) for details.

Parameters
name the name to bind; may not be empty
newObj the object to bind; possibly null

public String composeName (String name, String prefix)

Composes the name of this context with a name relative to this context. See composeName(Name, Name) for details.

Parameters
name a name relative to this context
prefix the name of this context relative to one of its ancestors
Returns
  • the composition of prefix and name

public Name composeName (Name name, Name prefix)

This default implementation simply concatenates the two names. There's one twist when the "java.naming.provider.compose.elideEmpty" environment setting is set to "true": if each name contains a nonempty component, and if 'prefix' ends with an empty component or 'name' starts with one, then one empty component is dropped. For example:

                            elideEmpty=false     elideEmpty=true
 {"a"} + {"b"}          =>  {"a", "b"}           {"a", "b"}
 {"a"} + {""}           =>  {"a", ""}            {"a", ""}
 {"a"} + {"", "b"}      =>  {"a", "", "b"}       {"a", "b"}
 {"a", ""} + {"b", ""}  =>  {"a", "", "b", ""}   {"a", "b", ""}
 {"a", ""} + {"", "b"}  =>  {"a", "", "", "b"}   {"a", "", "b"}
 

Parameters
name a name relative to this context
prefix the name of this context relative to one of its ancestors
Returns
  • the composition of prefix and name

public Context createSubcontext (Name name)

Creates and binds a new context. Creates a new context with the given name and binds it in the target context (that named by all but terminal atomic component of the name). All intermediate contexts and the target context must already exist.

Parameters
name the name of the context to create; may not be empty
Returns
  • the newly created context

public Context createSubcontext (String name)

Creates and binds a new context. See createSubcontext(Name) for details.

Parameters
name the name of the context to create; may not be empty
Returns
  • the newly created context

public void destroySubcontext (Name name)

Destroys the named context and removes it from the namespace. Any attributes associated with the name are also removed. Intermediate contexts are not destroyed.

This method is idempotent. It succeeds even if the terminal atomic name is not bound in the target context, but throws NameNotFoundException if any of the intermediate contexts do not exist.

In a federated naming system, a context from one naming system may be bound to a name in another. One can subsequently look up and perform operations on the foreign context using a composite name. However, an attempt destroy the context using this composite name will fail with NotContextException, because the foreign context is not a "subcontext" of the context in which it is bound. Instead, use unbind() to remove the binding of the foreign context. Destroying the foreign context requires that the destroySubcontext() be performed on a context from the foreign context's "native" naming system.

Parameters
name the name of the context to be destroyed; may not be empty

public void destroySubcontext (String name)

Destroys the named context and removes it from the namespace. See destroySubcontext(Name) for details.

Parameters
name the name of the context to be destroyed; may not be empty

public NameParser getNameParser (Name name)

Retrieves the parser associated with the named context. In a federation of namespaces, different naming systems will parse names differently. This method allows an application to get a parser for parsing names into their atomic components using the naming convention of a particular naming system. Within any single naming system, NameParser objects returned by this method must be equal (using the equals() test).

Parameters
name the name of the context from which to get the parser
Returns
  • a name parser that can parse compound names into their atomic components

public NameParser getNameParser (String name)

Retrieves the parser associated with the named context. See getNameParser(Name) for details.

Parameters
name the name of the context from which to get the parser
Returns
  • a name parser that can parse compound names into their atomic components

public NamingEnumeration<NameClassPair> list (String name)

Enumerates the names bound in the named context, along with the class names of objects bound to them. See list(Name) for details.

Parameters
name the name of the context to list
Returns
  • an enumeration of the names and class names of the bindings in this context. Each element of the enumeration is of type NameClassPair.

public NamingEnumeration<NameClassPair> list (Name name)

Enumerates the names bound in the named context, along with the class names of objects bound to them. The contents of any subcontexts are not included.

If a binding is added to or removed from this context, its effect on an enumeration previously returned is undefined.

Parameters
name the name of the context to list
Returns
  • an enumeration of the names and class names of the bindings in this context. Each element of the enumeration is of type NameClassPair.

public NamingEnumeration<Binding> listBindings (Name name)

Enumerates the names bound in the named context, along with the objects bound to them. The contents of any subcontexts are not included.

If a binding is added to or removed from this context, its effect on an enumeration previously returned is undefined.

Parameters
name the name of the context to list
Returns
  • an enumeration of the bindings in this context. Each element of the enumeration is of type Binding.

public NamingEnumeration<Binding> listBindings (String name)

Enumerates the names bound in the named context, along with the objects bound to them. See listBindings(Name) for details.

Parameters
name the name of the context to list
Returns
  • an enumeration of the bindings in this context. Each element of the enumeration is of type Binding.

public Object lookup (String name)

Retrieves the named object. See lookup(Name) for details.

Parameters
name the name of the object to look up
Returns
  • the object bound to name

public Object lookup (Name name)

Retrieves the named object. If name is empty, returns a new instance of this context (which represents the same naming context as this context, but its environment may be modified independently and it may be accessed concurrently).

Parameters
name the name of the object to look up
Returns
  • the object bound to name

public Object lookupLink (String name)

Retrieves the named object, following links except for the terminal atomic component of the name. See lookupLink(Name) for details.

Parameters
name the name of the object to look up
Returns
  • the object bound to name, not following the terminal link (if any)

public Object lookupLink (Name name)

Retrieves the named object, following links except for the terminal atomic component of the name. If the object bound to name is not a link, returns the object itself.

Parameters
name the name of the object to look up
Returns
  • the object bound to name, not following the terminal link (if any).

public void rebind (String name, Object newObj)

Binds a name to an object, overwriting any existing binding. See rebind(Name, Object) for details.

Parameters
name the name to bind; may not be empty
newObj the object to bind; possibly null

public void rebind (Name name, Object newObj)

Binds a name to an object, overwriting any existing binding. All intermediate contexts and the target context (that named by all but terminal atomic component of the name) must already exist.

If the object is a DirContext, any existing attributes associated with the name are replaced with those of the object. Otherwise, any existing attributes associated with the name remain unchanged.

Parameters
name the name to bind; may not be empty
newObj the object to bind; possibly null

public void rename (String oldName, String newName)

Binds a new name to the object bound to an old name, and unbinds the old name. See rename(Name, Name) for details.

Parameters
oldName the name of the existing binding; may not be empty
newName the name of the new binding; may not be empty

public void rename (Name oldName, Name newName)

Binds a new name to the object bound to an old name, and unbinds the old name. Both names are relative to this context. Any attributes associated with the old name become associated with the new name. Intermediate contexts of the old name are not changed.

Parameters
oldName the name of the existing binding; may not be empty
newName the name of the new binding; may not be empty

public ResolveResult resolveToClass (Name name, Class<? extends Context> contextType)

Partially resolves a name. Stops at the first context that is an instance of a given subtype of Context.

Parameters
name the name to resolve
contextType the type of object to resolve. This should be a subtype of Context.
Returns
  • the object that was found, along with the unresolved suffix of name. Cannot be null.

public ResolveResult resolveToClass (String name, Class<? extends Context> contextType)

Partially resolves a name. See resolveToClass(Name, Class) for details.

Parameters
name the name to resolve
contextType the type of object to resolve. This should be a subtype of Context.
Returns
  • the object that was found, along with the unresolved suffix of name. Cannot be null.

public void unbind (Name name)

Unbinds the named object. Removes the terminal atomic name in name from the target context--that named by all but the terminal atomic part of name.

This method is idempotent. It succeeds even if the terminal atomic name is not bound in the target context, but throws NameNotFoundException if any of the intermediate contexts do not exist.

Any attributes associated with the name are removed. Intermediate contexts are not changed.

Parameters
name the name to unbind; may not be empty

public void unbind (String name)

Unbinds the named object. See unbind(Name) for details.

Parameters
name the name to unbind; may not be empty

Protected Methods

protected static boolean allEmpty (Name name)

Tests whether a name contains a nonempty component.

protected static PartialCompositeContext getPCContext (Continuation cont)

Retrieves a PartialCompositeContext for the resolved object in cont. Throws CannotProceedException if not successful.

protected abstract void p_bind (Name name, Object obj, Continuation cont)

protected abstract Context p_createSubcontext (Name name, Continuation cont)

protected abstract void p_destroySubcontext (Name name, Continuation cont)

protected Hashtable p_getEnvironment ()

A cheap way of getting the environment. Default implemenation is NOT cheap because it simply calls getEnvironment(), which most implementations clone before returning. Subclass should ALWAYS override this with the cheapest possible way. The toolkit knows to clone when necessary.

Returns
  • The possibly null environment of the context.

protected abstract NameParser p_getNameParser (Name name, Continuation cont)

protected abstract NamingEnumeration p_list (Name name, Continuation cont)

protected abstract NamingEnumeration p_listBindings (Name name, Continuation cont)

protected abstract Object p_lookup (Name name, Continuation cont)

protected abstract Object p_lookupLink (Name name, Continuation cont)

protected abstract void p_rebind (Name name, Object obj, Continuation cont)

protected abstract void p_rename (Name oldname, Name newname, Continuation cont)

protected abstract ResolveResult p_resolveToClass (Name name, Class contextType, Continuation cont)

protected abstract void p_unbind (Name name, Continuation cont)