Methods Summary |
---|
public java.lang.Object | addToEnvironment(java.lang.String propName, java.lang.Object propVal)Add the property name and value to the environment.
if (myEnv == null) {
myEnv = new Hashtable(5, 0.75f);
}
return myEnv.put(propName, propVal);
|
public void | bind(java.lang.String name, java.lang.Object obj)Bind the object to the specified name.
Name n = new CompositeName(name);
if (n.size() < 1) {
throw new InvalidNameException("Cannot bind empty name");
}
if(n.size() == 1) { // bottom
doBindOrRebind(n.toString(), obj, false);
} else {
String suffix = n.getSuffix(1).toString();
Context ctx;
try {
ctx = resolveContext(n.get(0));
} catch (NameNotFoundException e){
ctx = createSubcontext (n.get (0));
}
ctx.bind(suffix, obj);
}
|
public void | bind(javax.naming.Name name, java.lang.Object obj)Bind the object to the specified name.
bind(name.toString(), obj);
|
public void | close()Invalidate the current environment.
myEnv = null;
|
public java.lang.String | composeName(java.lang.String name, java.lang.String prefix)Compose a new name specified by name and prefix.
return null;
|
public javax.naming.Name | composeName(javax.naming.Name name, javax.naming.Name prefix)Compose a new name specified by name and prefix.
Name result = (Name)(prefix.clone());
result.addAll(name);
return result;
|
public javax.naming.Context | createSubcontext(java.lang.String name)Create a subcontext with the specified name.
return drillDownAndCreateSubcontext (name);
|
public javax.naming.Context | createSubcontext(javax.naming.Name name)Create a subcontext with the specified name.
return createSubcontext(name.toString());
|
public void | destroySubcontext(java.lang.String name)Destroy the subcontext with the specified name.
drillDownAndDestroySubcontext (name);
|
public void | destroySubcontext(javax.naming.Name name)Destroy the subcontext with the specified name.
destroySubcontext(name.toString());
|
private void | doBindOrRebind(java.lang.String name, java.lang.Object obj, boolean rebind)Binds or rebinds the object specified by name
if (name.equals("")) {
throw new InvalidNameException("Cannot bind empty name");
}
if(!rebind) {
if (bindings.get(name) != null) {
throw new NameAlreadyBoundException(
"Use rebind to override");
}
}
bindings.put(name, obj);
|
private java.lang.Object | doLookup(java.lang.String name)Lookup the specified name in the current objects hashtable.
Object answer = bindings.get(name);
if (answer == null) {
throw new NameNotFoundException(name + " not found");
}
return answer;
|
private void | doUnbind(java.lang.String name)Unbinds the object specified by name. Traverses down the context tree
and unbinds the object if required.
if (name.equals("")) {
throw new InvalidNameException("Cannot unbind empty name");
}
if (bindings.get(name) == null) {
throw new NameNotFoundException(
"Cannot find name to unbind");
}
bindings.remove(name);
|
public javax.naming.Context | drillDownAndCreateSubcontext(java.lang.String name)Handles making nested subcontexts
i.e. if you want abcd/efg/hij. It will go subcontext efg in abcd
(if not present already - it will create it) and then
make subcontext hij
Name n = new CompositeName (name);
if (n.size () < 1){
throw new InvalidNameException ("Cannot create empty subcontext");
}
if (n.size() == 1){ // bottom
if (bindings.containsKey (name)){
throw new NameAlreadyBoundException ("Subcontext " +
name + "already present");
}
TransientContext ctx = null;
ctx = new TransientContext ();
bindings.put (name, ctx);
return ctx;
} else {
String suffix = n.getSuffix(1).toString();
Context retCtx, ctx; // the created context
try {
ctx = resolveContext(n.get(0));
} catch (NameNotFoundException e){
ctx = new TransientContext ();
}
retCtx = ctx.createSubcontext (suffix);
bindings.put (n.get(0), ctx);
return retCtx;
}
|
public void | drillDownAndDestroySubcontext(java.lang.String name)Handles deleting nested subcontexts
i.e. if you want delete abcd/efg/hij. It will go subcontext efg in abcd
it will delete it) and then delete subcontext hij
Name n = new CompositeName (name);
if (n.size () < 1){
throw new InvalidNameException ("Cannot destoy empty subcontext");
}
if (n.size() == 1){ // bottom
if (bindings.containsKey (name)){
bindings.remove (name);
}
else{
throw new NameNotFoundException ("Subcontext: " + name +
" not found");
}
} else {
String suffix = n.getSuffix(1).toString();
Context ctx; // the context to drill down from
ctx = resolveContext(n.get(0));
ctx.destroySubcontext (suffix);
}
|
public java.util.Hashtable | getEnvironment()List the current environment.
if (myEnv == null) {
// Must return non-null
myEnv = new Hashtable(3, 0.75f);
}
return myEnv;
|
public java.lang.String | getNameInNamespace()Operation not supported.
throw new OperationNotSupportedException("getNameInNamespace() " +
"not implemented");
|
public javax.naming.NameParser | getNameParser(java.lang.String name)List the NameParser specified by name.
return myParser;
|
public javax.naming.NameParser | getNameParser(javax.naming.Name name)List the NameParser specified by name.
// Flat namespace; no federation; just call string version
return getNameParser(name.toString());
|
public java.util.Hashtable | list()list the objects stored by the current context
return bindings;
|
public javax.naming.NamingEnumeration | list(javax.naming.Name name)List the objects specified by name.
return list(name.toString());
|
public javax.naming.NamingEnumeration | list(java.lang.String name)List the objects specified by name.
if(debug) {
print(bindings);
}
if(name.equals(""))
return new RepNames(bindings);
Object target = lookup(name);
if(target instanceof Context) {
return ((Context)target).list("");
}
throw new NotContextException(name + " cannot be listed");
|
public javax.naming.NamingEnumeration | listBindings(java.lang.String name)List the bindings of objects present in name.
if(name.equals(""))
return new RepBindings(bindings);
Object target = lookup(name);
if(target instanceof Context) {
return ((Context)target).listBindings("");
}
throw new NotContextException(name + " cannot be listed");
|
public javax.naming.NamingEnumeration | listBindings(javax.naming.Name name)List the binding of objects specified by name.
return listBindings(name.toString());
|
public java.util.Hashtable | listContext(java.lang.String name)List the objects specified by name.
if(debug) {
print(bindings);
}
if(name.equals(""))
return bindings;
Object target = lookup(name);
if(target instanceof TransientContext) {
return ((TransientContext)target).listContext("");
}
throw new NotContextException(name + " cannot be listed");
|
public java.lang.Object | lookup(java.lang.String name)Lookup the specified name.
Name n = new CompositeName(name);
if (n.size() < 1) {
throw new InvalidNameException("Cannot bind empty name");
}
if(n.size() == 1) { // bottom
return doLookup(n.toString());
} else {
String suffix = n.getSuffix(1).toString();
TransientContext ctx = resolveContext(n.get(0));
return ctx.lookup(suffix);
}
|
public java.lang.Object | lookup(javax.naming.Name name)Lookup the specified name.
return lookup(name.toString());
|
public java.lang.Object | lookupLink(java.lang.String name)Lookup the name.
// This flat context does not treat links specially
return lookup(name);
|
public java.lang.Object | lookupLink(javax.naming.Name name)Lookup name.
// Flat namespace; no federation; just call string version
return lookupLink(name.toString());
|
private static void | print(java.util.Hashtable ht)Print the current hashtable.
for (Enumeration en = ht.keys(); en.hasMoreElements(); ) {
Object key = en.nextElement();
Object value = ht.get(key);
/** IASRI 4660742
System.out.println("[" + key + ":" + key.getClass().getName() +
", " + value + ":" + value.getClass().getName()
+ "]");
**/
// START OF IASRI 4660742
if(_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE,"[" + key + ":" +
key.getClass().getName() +
", " + value + ":" + value.getClass().getName() + "]");
}
// END OF IASRI 4660742
}
|
public void | rebind(java.lang.String name, java.lang.Object obj)Rebinds the object specified by name
Name n = new CompositeName(name);
if (n.size() < 1) {
throw new InvalidNameException("Cannot bind empty name");
}
if(n.size() == 1) { // bottom
doBindOrRebind(n.toString(), obj, true);
} else {
String suffix = n.getSuffix(1).toString();
Context ctx=null;
try {
ctx = resolveContext(n.get(0));
ctx.rebind(suffix, obj);
} catch (NameNotFoundException e){
ctx = createSubcontext (n.get(0));
ctx.rebind(suffix, obj);
}
}
|
public void | rebind(javax.naming.Name name, java.lang.Object obj)Binds or rebinds the object specified by name
rebind(name.toString(), obj);
|
public java.lang.Object | removeFromEnvironment(java.lang.String propName)Remove property from the environment.
if (myEnv == null) {
return null;
}
return myEnv.remove(propName);
|
public void | rename(javax.naming.Name oldname, javax.naming.Name newname)Rename the object specified by oldname to newname
rename(oldname.toString(), newname.toString());
|
public void | rename(java.lang.String oldname, java.lang.String newname)Rename the object specified by oldname to newname
if (oldname.equals("") || newname.equals("")) {
throw new InvalidNameException("Cannot rename empty name");
}
// Check if new name exists
if (bindings.get(newname) != null) {
throw new NameAlreadyBoundException(newname +
" is already bound");
}
// Check if old name is bound
Object oldBinding = bindings.remove(oldname);
if (oldBinding == null) {
throw new NameNotFoundException(oldname + " not bound");
}
bindings.put(newname, oldBinding);
|
private com.sun.enterprise.naming.TransientContext | resolveContext(java.lang.String s)Finds out if the subcontext specified is present in the current context
//TransientContext ctx = (TransientContext) bindings.get(s);
TransientContext ctx;
Object obj = bindings.get (s);
if(obj == null) {
throw new NameNotFoundException();
}
if (obj instanceof TransientContext){
ctx = (TransientContext) obj;
}
else {
throw new NameAlreadyBoundException (s);
}
return ctx;
|
public void | unbind(java.lang.String name)Unbinds the object specified by name. Calls itself recursively to
traverse down the context tree and unbind the object.
Name n = new CompositeName(name);
if (n.size() < 1) {
throw new InvalidNameException("Cannot unbind empty name");
}
if(n.size() == 1) { // bottom
doUnbind(n.toString());
} else {
String suffix = n.getSuffix(1).toString();
TransientContext ctx = resolveContext(n.get(0));
ctx.unbind(suffix);
}
|
public void | unbind(javax.naming.Name name)Unbinds the object specified by name
unbind(name.toString());
|