Methods Summary |
---|
public java.lang.Object | addToEnvironment(java.lang.String propName, java.lang.Object propVal)
myProps.put(propName, propVal);
return getDefaultInitCtx().addToEnvironment(propName, propVal);
|
public void | bind(java.lang.String name, java.lang.Object obj)
getURLOrDefaultInitCtx(name).bind(name, obj);
|
public void | bind(javax.naming.Name name, java.lang.Object obj)
getURLOrDefaultInitCtx(name).bind(name, obj);
|
public void | close()
myProps = null;
if (defaultInitCtx != null) {
defaultInitCtx.close();
defaultInitCtx = null;
}
gotDefault = false;
|
public 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.
Since an initial context may never be named relative
to any context other than itself, the value of the
prefix parameter must be an empty name ("").
return name;
|
public javax.naming.Name | composeName(javax.naming.Name name, javax.naming.Name prefix)Composes the name of this context with a name relative to
this context.
Since an initial context may never be named relative
to any context other than itself, the value of the
prefix parameter must be an empty name.
return (Name)name.clone();
|
public javax.naming.Context | createSubcontext(java.lang.String name)
return getURLOrDefaultInitCtx(name).createSubcontext(name);
|
public javax.naming.Context | createSubcontext(javax.naming.Name name)
return getURLOrDefaultInitCtx(name).createSubcontext(name);
|
public void | destroySubcontext(java.lang.String name)
getURLOrDefaultInitCtx(name).destroySubcontext(name);
|
public void | destroySubcontext(javax.naming.Name name)
getURLOrDefaultInitCtx(name).destroySubcontext(name);
|
protected javax.naming.Context | getDefaultInitCtx()Retrieves the initial context by calling
NamingManager.getInitialContext()
and cache it in defaultInitCtx.
Set gotDefault so that we know we've tried this before.
if (!gotDefault) {
defaultInitCtx = NamingManager.getInitialContext(myProps);
gotDefault = true;
}
if (defaultInitCtx == null)
throw new NoInitialContextException();
return defaultInitCtx;
|
public java.util.Hashtable | getEnvironment()
return getDefaultInitCtx().getEnvironment();
|
public java.lang.String | getNameInNamespace()
return getDefaultInitCtx().getNameInNamespace();
|
public javax.naming.NameParser | getNameParser(java.lang.String name)
return getURLOrDefaultInitCtx(name).getNameParser(name);
|
public javax.naming.NameParser | getNameParser(javax.naming.Name name)
return getURLOrDefaultInitCtx(name).getNameParser(name);
|
protected javax.naming.Context | getURLOrDefaultInitCtx(java.lang.String name)Retrieves a context for resolving the string name name .
If name name is a URL string, then attempt
to find a URL context for it. If none is found, or if
name is not a URL string, then return
getDefaultInitCtx() .
See getURLOrDefaultInitCtx(Name) for description
of how a subclass should use this method.
if (NamingManager.hasInitialContextFactoryBuilder()) {
return getDefaultInitCtx();
}
String scheme = getURLScheme(name);
if (scheme != null) {
Context ctx = NamingManager.getURLContext(scheme, myProps);
if (ctx != null) {
return ctx;
}
}
return getDefaultInitCtx();
|
protected javax.naming.Context | getURLOrDefaultInitCtx(javax.naming.Name name)Retrieves a context for resolving name .
If the first component of name name is a URL string,
then attempt to find a URL context for it. If none is found, or if
the first component of name is not a URL string,
then return getDefaultInitCtx() .
When creating a subclass of InitialContext, use this method as
follows.
Define a new method that uses this method to get an initial
context of the desired subclass.
protected XXXContext getURLOrDefaultInitXXXCtx(Name name)
throws NamingException {
Context answer = getURLOrDefaultInitCtx(name);
if (!(answer instanceof XXXContext)) {
if (answer == null) {
throw new NoInitialContextException();
} else {
throw new NotContextException("Not an XXXContext");
}
}
return (XXXContext)answer;
}
When providing implementations for the new methods in the subclass,
use this newly defined method to get the initial context.
public Object XXXMethod1(Name name, ...) {
throws NamingException {
return getURLOrDefaultInitXXXCtx(name).XXXMethod1(name, ...);
}
if (NamingManager.hasInitialContextFactoryBuilder()) {
return getDefaultInitCtx();
}
if (name.size() > 0) {
String first = name.get(0);
String scheme = getURLScheme(first);
if (scheme != null) {
Context ctx = NamingManager.getURLContext(scheme, myProps);
if (ctx != null) {
return ctx;
}
}
}
return getDefaultInitCtx();
|
private static java.lang.String | getURLScheme(java.lang.String str)
int colon_posn = str.indexOf(':");
int slash_posn = str.indexOf('/");
if (colon_posn > 0 && (slash_posn == -1 || colon_posn < slash_posn))
return str.substring(0, colon_posn);
return null;
|
protected void | init(java.util.Hashtable environment)Initializes the initial context using the supplied environment.
Environment properties are discussed in the class description.
This method will modify environment and save
a reference to it. The caller may no longer modify it.
myProps = ResourceManager.getInitialEnvironment(environment);
if (myProps.get(Context.INITIAL_CONTEXT_FACTORY) != null) {
// user has specified initial context factory; try to get it
getDefaultInitCtx();
}
|
public javax.naming.NamingEnumeration | list(java.lang.String name)
return (getURLOrDefaultInitCtx(name).list(name));
|
public javax.naming.NamingEnumeration | list(javax.naming.Name name)
return (getURLOrDefaultInitCtx(name).list(name));
|
public javax.naming.NamingEnumeration | listBindings(java.lang.String name)
return getURLOrDefaultInitCtx(name).listBindings(name);
|
public javax.naming.NamingEnumeration | listBindings(javax.naming.Name name)
return getURLOrDefaultInitCtx(name).listBindings(name);
|
public java.lang.Object | lookup(javax.naming.Name name)
return getURLOrDefaultInitCtx(name).lookup(name);
|
public java.lang.Object | lookup(java.lang.String name)
return getURLOrDefaultInitCtx(name).lookup(name);
|
public java.lang.Object | lookupLink(java.lang.String name)
return getURLOrDefaultInitCtx(name).lookupLink(name);
|
public java.lang.Object | lookupLink(javax.naming.Name name)
return getURLOrDefaultInitCtx(name).lookupLink(name);
|
public void | rebind(java.lang.String name, java.lang.Object obj)
getURLOrDefaultInitCtx(name).rebind(name, obj);
|
public void | rebind(javax.naming.Name name, java.lang.Object obj)
getURLOrDefaultInitCtx(name).rebind(name, obj);
|
public java.lang.Object | removeFromEnvironment(java.lang.String propName)
myProps.remove(propName);
return getDefaultInitCtx().removeFromEnvironment(propName);
|
public void | rename(java.lang.String oldName, java.lang.String newName)
getURLOrDefaultInitCtx(oldName).rename(oldName, newName);
|
public void | rename(javax.naming.Name oldName, javax.naming.Name newName)
getURLOrDefaultInitCtx(oldName).rename(oldName, newName);
|
public void | unbind(java.lang.String name)
getURLOrDefaultInitCtx(name).unbind(name);
|
public void | unbind(javax.naming.Name name)
getURLOrDefaultInitCtx(name).unbind(name);
|