|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.mockejb.jndi.MockContext
Provides implementation of javax.naming.Context interface for
hierarchical in memory single-namespace naming system.
A name in the MockContext namespace is a sequence of one or more
atomic names, relative to a root initial context.
When a name consist of more than one atomic names it is a CompoundName
where atomic names are separated with separator character - '/' or '.'.
It is possible to use both separator characters in the same name. In such cases
any occurrences of '.' are replaced with '/' before parsing.
Leading and terminal components of a CompoundName can not be empty -
for example "name1/name2/name3" is a valid name, while the following names are
not valid - "/name1/name2/name3", "name1/name2/name3/", "/name1/name2/name3/".
If such name is passed, all empty leading/terminal components will be removed
before the name is actually used (this will not affect the original value) -
from the above three examples the actual name will be "name1/name2/name3".
If a name contains intermediate empty components (for example "a//b") then
InvalidNameException will be thrown.
Composite names (instances of CompositeName) must contain zero or one
component from the MockContext namespace.
The namespace of MockContext can be represented as a tree of atomic names.
Each name is bound to an instance of MockContext (subcontext) or to an arbitrary object.
Each subcontext has collection of names bound to other subcontexts or arbitrary objects.
When instance of Name is used as parameter to any of the
MockContext methods, if the object is not CompositeName then
it is assumed that it is CompoundName
Example:
myContext = initialContext.lookup("foo"); myObject = myContext.lookup("bar");is equivalent tomyObject = initialContext.lookup("foo/bar");
Instances of MockContext are created only through
MockContextFactory, when InitialContext is instantiated.
If a remote context is provided, this class will search in that remote context if the object is not found locally.
For overloaded methods that accept name as String or
Name only the version for Name is documented.
The String version creates CompoundName, from
the string name passed as parameter, and calls the Name version of
the same method.
| Field Summary |
| 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 | |
protected |
MockContext(javax.naming.Context remoteContext)
Creates a new instance of the context. |
| Method Summary | |
java.lang.Object |
addToEnvironment(java.lang.String arg0,
java.lang.Object arg1)
Not implemented |
void |
bind(javax.naming.Name name,
java.lang.Object obj)
Binds object obj to name name in this context. |
void |
bind(java.lang.String name,
java.lang.Object obj)
Binds object obj to name name in this context. |
void |
close()
Does nothing. |
javax.naming.Name |
composeName(javax.naming.Name name,
javax.naming.Name prefix)
Returns composition of prefix and name. |
java.lang.String |
composeName(java.lang.String name,
java.lang.String prefix)
Composes the name of this context with a name relative to this context. |
javax.naming.Context |
createSubcontext(javax.naming.Name name)
Creates subcontext with name name, relative to this Context. |
javax.naming.Context |
createSubcontext(java.lang.String name)
Creates subcontext with name name, relative to this Context. |
void |
destroySubcontext(javax.naming.Name name)
Destroys subcontext with name name
The subcontext must be empty otherwise ContextNotEmptyException
is thrown. |
void |
destroySubcontext(java.lang.String name)
Destroys subcontext with name name |
java.util.Hashtable |
getEnvironment()
Not implemented |
java.lang.String |
getNameInNamespace()
Not implemented |
javax.naming.NameParser |
getNameParser(javax.naming.Name name)
Retrieves name parser used to parse context with name name. |
javax.naming.NameParser |
getNameParser(java.lang.String name)
Retrieves name parser used to parse context with name name. |
javax.naming.NamingEnumeration |
list(javax.naming.Name name)
The same as listBindings(String) |
javax.naming.NamingEnumeration |
list(java.lang.String name)
The same as listBindings(String) |
javax.naming.NamingEnumeration |
listBindings(javax.naming.Name name)
Lists all bindings for Context with name name. |
javax.naming.NamingEnumeration |
listBindings(java.lang.String name)
Lists all bindings for Context with name name. |
java.lang.Object |
lookup(javax.naming.Name name)
Looks up object with name name in this context. |
java.lang.Object |
lookup(java.lang.String name)
Looks up the object in this context. |
java.lang.Object |
lookupLink(javax.naming.Name arg0)
Not implemented |
java.lang.Object |
lookupLink(java.lang.String arg0)
Not implemented |
void |
rebind(javax.naming.Name name,
java.lang.Object obj)
Rebinds object obj to name name. |
void |
rebind(java.lang.String name,
java.lang.Object obj)
Same as bind except that if name is already bound in
the context, it will be re-bound to object obj |
java.lang.Object |
removeFromEnvironment(java.lang.String arg0)
Not implemented |
void |
rename(javax.naming.Name arg0,
javax.naming.Name arg1)
Not implemented |
void |
rename(java.lang.String arg0,
java.lang.String arg1)
Not implemented |
void |
unbind(javax.naming.Name name)
Removes name and its associated object from the context. |
void |
unbind(java.lang.String name)
Removes object from the object map |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
protected MockContext(javax.naming.Context remoteContext)
remoteContext - remote context that MockContext will
delegate to if it fails to lookup an object locally| Method Detail |
public java.lang.Object addToEnvironment(java.lang.String arg0,
java.lang.Object arg1)
throws javax.naming.NamingException
addToEnvironment in interface javax.naming.Contextjavax.naming.NamingExceptionContext.addToEnvironment(java.lang.String, java.lang.Object)
public void bind(javax.naming.Name name,
java.lang.Object obj)
throws javax.naming.NamingException
obj to name name in this context.
Intermediate contexts that do not exist will be created.
bind in interface javax.naming.Contextname - name of the object to bindobj - object to bind. Can be null.
javax.naming.NoPermissionException - if this context has been destroyed
javax.naming.InvalidNameException - if name is empty or is
CompositeName that spans more than one naming system
javax.naming.NotContextException - if name has more than one
atomic name and intermediate atomic name is bound to object that is
not context.
javax.naming.NamingExceptionContext.bind(javax.naming.Name, java.lang.Object)
public void bind(java.lang.String name,
java.lang.Object obj)
throws javax.naming.NamingException
obj to name name in this context.
bind in interface javax.naming.Contextname - name of the object to addobj - object to bind
javax.naming.NamingException - if naming error occursbind(Name, Object)
public void close()
throws javax.naming.NamingException
close in interface javax.naming.Contextjavax.naming.NamingException
public javax.naming.Name composeName(javax.naming.Name name,
javax.naming.Name prefix)
throws javax.naming.NamingException
prefix and name.
composeName in interface javax.naming.Contextname - name relative to this contextprefix - name of this context
javax.naming.NamingExceptionContext.composeName(javax.naming.Name, javax.naming.Name)
public java.lang.String composeName(java.lang.String name,
java.lang.String prefix)
throws javax.naming.NamingException
composeName in interface javax.naming.Contextname - name relative to this contextprefix - name of this context
javax.naming.NamingExceptionContext.composeName(java.lang.String, java.lang.String)
public javax.naming.Context createSubcontext(javax.naming.Name name)
throws javax.naming.NamingException
name, relative to this Context.
createSubcontext in interface javax.naming.Contextname - subcontext name.
name relative to this context
javax.naming.NoPermissionException - if this context has been destroyed
javax.naming.InvalidNameException - if name is empty or is
CompositeName that spans more than one naming system
javax.naming.NameAlreadyBoundException - if name is already bound in this Context
javax.naming.NotContextException - if any intermediate name from name
is not bound to instance of javax.naming.Context
javax.naming.NamingExceptionContext.createSubcontext(javax.naming.Name)
public javax.naming.Context createSubcontext(java.lang.String name)
throws javax.naming.NamingException
name, relative to this Context.
createSubcontext in interface javax.naming.Contextname - subcontext name
name relative to this context
javax.naming.NamingException - if naming error occurscreateSubcontext(javax.naming.Name)
public void destroySubcontext(javax.naming.Name name)
throws javax.naming.NamingException
name
The subcontext must be empty otherwise ContextNotEmptyException
is thrown.
Once a context is destroyed, the instance should not be used.
destroySubcontext in interface javax.naming.Contextname - subcontext to destroy
javax.naming.NoPermissionException - if this context has been destroyed
javax.naming.InvalidNameException - if name is empty or is
CompositeName that spans more than one naming system
javax.naming.ContextNotEmptyException - if Context name is not empty
javax.naming.NameNotFoundException - if subcontext with name name can not be found
javax.naming.NotContextException - if name is not bound to instance of
MockContext
javax.naming.NamingExceptionContext.destroySubcontext(javax.naming.Name)
public void destroySubcontext(java.lang.String name)
throws javax.naming.NamingException
name
destroySubcontext in interface javax.naming.Contextname - name of subcontext to destroy
javax.naming.NamingException - if naming error occursdestroySubcontext(javax.naming.Name)
public java.util.Hashtable getEnvironment()
throws javax.naming.NamingException
getEnvironment in interface javax.naming.Contextjavax.naming.NamingExceptionContext.getEnvironment()
public java.lang.String getNameInNamespace()
throws javax.naming.NamingException
getNameInNamespace in interface javax.naming.Contextjavax.naming.NamingExceptionContext.getNameInNamespace()
public javax.naming.NameParser getNameParser(javax.naming.Name name)
throws javax.naming.NamingException
name.
getNameParser in interface javax.naming.Contextname - context name
NameParser
javax.naming.NoPermissionException - if this context has been destroyed
javax.naming.NamingException - if any other naming error occursContext.getNameParser(javax.naming.Name)
public javax.naming.NameParser getNameParser(java.lang.String name)
throws javax.naming.NamingException
name.
getNameParser in interface javax.naming.Contextname - context name
NameParser
javax.naming.NamingException - if naming error occursgetNameParser(javax.naming.Name)
public javax.naming.NamingEnumeration list(javax.naming.Name name)
throws javax.naming.NamingException
listBindings(String)
list in interface javax.naming.Contextname - name of Context, relative to this Context
NamingEnumeration of all name-class pairs. Each
element from the enumeration is instance of NameClassPair
javax.naming.NamingException - if naming error occurslistBindings(javax.naming.Name)
public javax.naming.NamingEnumeration list(java.lang.String name)
throws javax.naming.NamingException
listBindings(String)
list in interface javax.naming.Contextname - name of Context, relative to this Context
NamingEnumeration of all name-class pairs. Each
element from the enumeration is instance of NameClassPair
javax.naming.NamingException - if naming error occurslistBindings(java.lang.String)
public javax.naming.NamingEnumeration listBindings(javax.naming.Name name)
throws javax.naming.NamingException
name.
If name is empty then this Context is assumed.
listBindings in interface javax.naming.Contextname - name of Context, relative to this Context
NamingEnumeration of all name-object pairs. Each
element from the enumeration is instance of Binding
javax.naming.NoPermissionException - if this context has been destroyed
javax.naming.InvalidNameException - if name is CompositeName
that spans more than one naming system
javax.naming.NameNotFoundException - if name can not be found
javax.naming.NotContextException - component of name is not bound to instance of
MockContext, when name is not an atomic name
javax.naming.NamingException - if any other naming error occursContext.listBindings(javax.naming.Name)
public javax.naming.NamingEnumeration listBindings(java.lang.String name)
throws javax.naming.NamingException
name.
If name is empty then this Context is assumed.
listBindings in interface javax.naming.Contextname - name of Context, relative to this Context
NamingEnumeration of all name-object pairs. Each
element from the enumeration is instance of Binding
javax.naming.NamingException - if naming error occurslistBindings(javax.naming.Name)
public java.lang.Object lookup(javax.naming.Name name)
throws javax.naming.NamingException
name in this context. If the object is not
found and the remote context was provided, calls the remote
context to lookup the object.
lookup in interface javax.naming.Contextname - name to look up
name
javax.naming.NoPermissionException - if this context has been destroyed
javax.naming.InvalidNameException - if name is CompositeName
that spans more than one naming system
javax.naming.NameNotFoundException - if name can not be found
javax.naming.NotContextException - component of name is not bound to instance of
MockContext, when name is not atomic name.
javax.naming.NamingException - if any other naming error occursContext.lookup(javax.naming.Name)
public java.lang.Object lookup(java.lang.String name)
throws javax.naming.NamingException
lookup in interface javax.naming.Contextname - object to search
name
javax.naming.NamingException - if naming error occurslookup(javax.naming.Name)
public java.lang.Object lookupLink(javax.naming.Name arg0)
throws javax.naming.NamingException
lookupLink in interface javax.naming.Contextjavax.naming.NamingExceptionContext.lookupLink(javax.naming.Name)
public java.lang.Object lookupLink(java.lang.String arg0)
throws javax.naming.NamingException
lookupLink in interface javax.naming.Contextjavax.naming.NamingExceptionContext.lookupLink(java.lang.String)
public void rebind(javax.naming.Name name,
java.lang.Object obj)
throws javax.naming.NamingException
obj to name name.
If there is existing binding it will be overwritten.
rebind in interface javax.naming.Contextname - name of the object to rebindobj - object to add. Can be null
javax.naming.NoPermissionException - if this context has been destroyed
javax.naming.InvalidNameException - if name is empty or is
CompositeName that spans more than one naming system
javax.naming.NotContextException - if name has more than one
atomic name and intermediate context is not found
javax.naming.NamingException - if any other naming error occursContext.rebind(javax.naming.Name, java.lang.Object)
public void rebind(java.lang.String name,
java.lang.Object obj)
throws javax.naming.NamingException
name is already bound in
the context, it will be re-bound to object obj
rebind in interface javax.naming.Contextname - name of the object to rebindobj - object to add. Can be null
javax.naming.NamingException - if naming error occursrebind(javax.naming.Name, Object)
public java.lang.Object removeFromEnvironment(java.lang.String arg0)
throws javax.naming.NamingException
removeFromEnvironment in interface javax.naming.Contextjavax.naming.NamingExceptionContext.removeFromEnvironment(java.lang.String)
public void rename(javax.naming.Name arg0,
javax.naming.Name arg1)
throws javax.naming.NamingException
rename in interface javax.naming.Contextjavax.naming.NamingExceptionContext.rename(javax.naming.Name, javax.naming.Name)
public void rename(java.lang.String arg0,
java.lang.String arg1)
throws javax.naming.NamingException
rename in interface javax.naming.Contextjavax.naming.NamingExceptionContext.rename(java.lang.String, java.lang.String)
public void unbind(javax.naming.Name name)
throws javax.naming.NamingException
name and its associated object from the context.
unbind in interface javax.naming.Contextname - name to remove
javax.naming.NoPermissionException - if this context has been destroyed
javax.naming.InvalidNameException - if name is empty or is
CompositeName that spans more than one naming system
javax.naming.NameNotFoundException - if intermediate context can not be found
javax.naming.NotContextException - if name has more than one
atomic name and intermediate context is not found
javax.naming.NamingException - if any other naming exception occursContext.unbind(javax.naming.Name)
public void unbind(java.lang.String name)
throws javax.naming.NamingException
unbind in interface javax.naming.Contextname - object to remove
javax.naming.NamingException - if naming error occursunbind(javax.naming.Name)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||