Methods Summary |
---|
public java.lang.Object | addToEnvironment(java.lang.String propName, java.lang.Object propVal)Add to the environment for the current context.
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 = getRelativeName(name);
if (isjavaURL(name)) {
javaUrlContext.bind(name, obj);
} else {
try {
getProvider().bind(name, obj);
} catch (RemoteException ex) {
throw new CommunicationException(ex.toString());
}
}
|
public void | bind(javax.naming.Name name, java.lang.Object obj)Bind the object to the specified name.
// Flat namespace; no federation; just call string version
bind(name.toString(), obj);
|
public void | close()Set the environment for the current context to null when close is
called.
myEnv = null;
|
public java.lang.String | composeName(java.lang.String name, java.lang.String prefix)
Name result = composeName(new CompositeName(name),
new CompositeName(prefix));
return result.toString();
|
public javax.naming.Name | composeName(javax.naming.Name name, javax.naming.Name prefix)
Name result = (Name)(prefix.clone());
result.addAll(name);
return result;
|
public javax.naming.Context | createSubcontext(java.lang.String name)Create the specified subcontext.
Context c = null;
name = getRelativeName (name);
if (isjavaURL(name)) {
return javaUrlContext.createSubcontext(name);
} else {
try {
c = getProvider().createSubcontext(name);
/* this simulates the transient context structure on the
* client side. Have to do this - as reference to
* Transient Context is not resolved properly due to rmi
*/
if (c instanceof Context){
c = new SerialContext (name, myEnv);
}
} catch(RemoteException e) {
CommunicationException ce =
new CommunicationException(e.toString());
ce.initCause(e);
throw ce;
}
return c;
}
|
public javax.naming.Context | createSubcontext(javax.naming.Name name)Create the specified subcontext.
// Flat namespace; no federation; just call string version
return createSubcontext(name.toString());
|
public void | destroySubcontext(java.lang.String name)Destroy the specified subcontext.
name = getRelativeName (name);
if (isjavaURL(name)) {
javaUrlContext.destroySubcontext(name);
} else {
try {
getProvider().destroySubcontext(name);
} catch(RemoteException e) {
CommunicationException ce =
new CommunicationException(e.toString());
ce.initCause(e);
throw ce;
}
}
|
public void | destroySubcontext(javax.naming.Name name)Destroy the specified subcontext.
// Flat namespace; no federation; just call string version
destroySubcontext(name.toString());
|
public void | generateEntryContext(java.lang.Object context)Generates an entry context and give it to ondemand initialization framework.
ServerEntryHelper.generateJndiEntryContext((String) context);
|
public java.util.Hashtable | getEnvironment()Return the environment for the current context.
if (myEnv == null) {
// Must return non-null
myEnv = new Hashtable(3, 0.75f);
}
return myEnv;
|
public java.lang.String | getNameInNamespace()The getNameInNamespace API is not supported in this context.
return myName;
|
public javax.naming.NameParser | getNameParser(java.lang.String name)Allow access to the name parser object.
return myParser;
|
public javax.naming.NameParser | getNameParser(javax.naming.Name name)Allow access to the name parser object.
// Flat namespace; no federation; just call string version
return getNameParser(name.toString());
|
private SerialContextProvider | getProvider()
try {
if (provider == null) {
if (Switch.getSwitch().getContainerType() ==
Switch.EJBWEB_CONTAINER) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("lookup call inside the server VM...");
}
provider = Switch.getSwitch().getProviderManager().getLocalProvider();
} else {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("lookup call outside the server VM...");
}
// get SerialContextProvider from naming service
// Get orb to use for connecting to NameService
ORB orb = (ORB) myEnv.get(ORBManager.JNDI_CORBA_ORB_PROPERTY);
if ( orb == null ) {
orb = ORBManager.getORB();
}
if (_logger.isLoggable(Level.FINE))
print(orb);
org.omg.CORBA.Object ref = null;
//if the following is not null, then we are in EE world
//else PE
//if (myEnv.get("com.sun.appserv.ee.iiop.endpointslist") != null) {
if (isEE == true) {
ref = orb.string_to_object((String)(myEnv.get(
"com.sun.appserv.ee.iiop.endpointslist")));
provider = narrowProvider(ref);
} else {
provider = (SerialContextProvider) providerCache.get(orb);
// thread-safety: race condition
if (provider == null) {
ref = orb.resolve_initial_references("NameService");
provider = narrowProvider(ref);
providerCache.put(orb, provider);
}
}
}
}
} catch (Exception ex) {
setSticky(null);
CommunicationException ce = new CommunicationException
("Can't find SerialContextProvider");
ce.initCause(ex);
throw ce;
}
return provider;
|
private java.lang.String | getRelativeName(java.lang.String name)
if(!myName.equals("")) {
name = myName + "/" + name;
}
return name;
|
public static com.sun.enterprise.naming.SerialContext$ThreadLocalIC | getSticky()
return (ThreadLocalIC) stickyContext.get();
|
public static javax.naming.Context | getStickyContext()This method is called from SerialInitContextFactory & S1ASCtxFactory
to check if sticky context is set.
return getSticky().getStickyContext();
|
private boolean | isjavaURL(java.lang.String name)method to check if the name to look up starts with "java:"
if (name.startsWith(JAVA_URL)) {
return true;
} else return false;
|
public javax.naming.NamingEnumeration | list(java.lang.String name)List the contents of the specified context.
if (name.equals("")) {
// listing this context
try {
Hashtable bindings = getProvider().list(myName);
return new RepNames(bindings);
} catch (RemoteException ex) {
throw new CommunicationException(ex.toString());
}
}
name = getRelativeName(name);
if (isjavaURL(name)) {
return javaUrlContext.list(name);
} else {
// Perhaps 'name' names a context
Object target = lookup(name);
if (target instanceof Context) {
return ((Context)target).list("");
}
throw new NotContextException(name + " cannot be listed");
}
|
public javax.naming.NamingEnumeration | list(javax.naming.Name name)List the contents of the specified context.
// Flat namespace; no federation; just call string version
return list(name.toString());
|
public javax.naming.NamingEnumeration | listBindings(java.lang.String name)List the bindings in the specified context.
if (name.equals("")) {
// listing this context
try {
Hashtable bindings = getProvider().list(myName);
return new RepBindings(bindings);
} catch (RemoteException ex) {
CommunicationException ce =
new CommunicationException(ex.toString());
ce.initCause(ex);
throw ce;
}
}
name = getRelativeName(name);
if (isjavaURL(name)) {
return javaUrlContext.listBindings(name);
} else {
// Perhaps 'name' names a context
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 bindings in the specified context.
// Flat namespace; no federation; just call string version
return listBindings(name.toString());
|
public java.lang.Object | lookup(java.lang.String name)Lookup the specified name in the context.
Returns the resolved object.
//Before enything call ondemand initialization framework.
generateEntryContext(name);
/**
* In case a user is creating an IC with env passed
* in constructor; env specifies endpoints in some form
* in that case, the sticky IC should be stores as a thread local
* variable.
*
*/
if (myEnv.get("com.sun.appserv.ee.iiop.endpointslist") != null) {
if (getSticky() == null) {
ThreadLocalIC threadLocal = new ThreadLocalIC(this,1);
setSticky(threadLocal);
} else getSticky().incrementCount();
}
if (_logger.isLoggable(Level.FINE))
_logger.fine("SerialContext ==> doing lookup with " + this);
if (name.equals("")) {
resetSticky();
// Asking to look up this context itself. Create and return
// a new instance with its own independent environment.
return (new SerialContext(myName, myEnv));
}
name = getRelativeName(name);
if (_logger.isLoggable(Level.FINE))
_logger.fine("SerialContext ==> looking up : " + name);
try {
if (isjavaURL(name)) {
resetSticky();
return javaUrlContext.lookup(name);
} else {
Object obj = getProvider().lookup(name);
if(obj instanceof Context) {
resetSticky();
return new SerialContext(name, myEnv);
}
Object retObj =
javax.naming.spi.NamingManager.getObjectInstance(obj,
new CompositeName(name),
null, myEnv);
resetSticky();
return retObj;
}
} catch (NamingException nnfe) {
setSticky(null);
throw nnfe;
} catch (Exception ex) {
setSticky(null);
_logger.log(Level.SEVERE,
"enterprise_naming.serialctx_communication_exception",
ex);
//temp fix for 6320008
//this should be removed once we change the transient NS implementation to persistent
if (ex instanceof java.rmi.MarshalException &&
ex.getCause() instanceof org.omg.CORBA.COMM_FAILURE) {
provider = null;
_logger.fine("Resetting provider to NULL. Will get new obj ref for provider since previous obj ref was stale...");
return lookup(name);
} else {
CommunicationException ce =
new CommunicationException("serial context communication ex");
ce.initCause(ex);
throw ce;
}
}
|
public java.lang.Object | lookup(javax.naming.Name name)Lookup the specifed name in the context.
Returns the resolved object.
// Flat namespace; no federation; just call string version
return lookup(name.toString());
|
public java.lang.Object | lookupLink(java.lang.String name)Links are not treated specially.
name = getRelativeName(name);
if (isjavaURL(name)) {
return javaUrlContext.lookupLink(name);
} else {
// This flat context does not treat links specially
return lookup(name);
}
|
public java.lang.Object | lookupLink(javax.naming.Name name)Links are not treated specially.
// Flat namespace; no federation; just call string version
return lookupLink(name.toString());
|
private SerialContextProvider | narrowProvider(org.omg.CORBA.Object ref)method to narrow down the provider.
common code that is called from getProvider()
NamingContext nctx = NamingContextHelper.narrow(ref);
NameComponent[] path =
{ new NameComponent("SerialContextProvider", "") };
synchronized (threadlock) {
provider = (SerialContextProvider)
PortableRemoteObject.narrow(nctx.resolve(path),
SerialContextProvider.class);
}
return provider;
|
public void | print(org.omg.CORBA.ORB orb)
_logger.fine("SerialContext ==> SerialContext instance created : " + this);
if (orb != null) {
_logger.fine("SerialContext ==> ORB instance : " + orb);
String host = ((com.sun.corba.ee.impl.orb.ORBImpl)orb).
getORBData().getORBInitialHost();
int port = ((com.sun.corba.ee.impl.orb.ORBImpl)orb).
getORBData().getORBInitialPort();
_logger.fine("SerialContext ==> ORB HOST : " + host +
", ORB PORT : " + port);
} else _logger.fine("orb is null");
|
public void | rebind(java.lang.String name, java.lang.Object obj)Rebind the object to the specified name.
name = getRelativeName(name);
if (isjavaURL(name)) {
javaUrlContext.rebind(name, obj);
} else {
try {
getProvider().rebind(name, obj);
} catch (RemoteException ex) {
throw new CommunicationException(ex.toString());
}
}
|
public void | rebind(javax.naming.Name name, java.lang.Object obj)Rebind the object to the specified name.
// Flat namespace; no federation; just call string version
rebind(name.toString(), obj);
|
public java.lang.Object | removeFromEnvironment(java.lang.String propName)Remove from the environment for the current context.
if (myEnv == null) {
return null;
}
return myEnv.remove(propName);
|
public void | rename(java.lang.String oldname, java.lang.String newname)Rename the bound object.
oldname = getRelativeName(oldname);
newname = getRelativeName(newname);
if (isjavaURL(oldname)) {
javaUrlContext.rename(oldname, newname);
} else {
try {
getProvider().rename(oldname, newname);
} catch (RemoteException ex) {
throw new CommunicationException(ex.toString());
}
}
|
public void | rename(javax.naming.Name oldname, javax.naming.Name newname)Rename the bound object.
// Flat namespace; no federation; just call string version
rename(oldname.toString(), newname.toString());
|
private void | resetSticky()method for checking the count and decrementing it
also resets the sticky context to null if count is 0
if (getSticky() != null) {
getSticky().decrementCount();
if (getSticky().getStickyCount() == 0) {
setSticky(null);
}
}
|
public static void | setSticky(com.sun.enterprise.naming.SerialContext$ThreadLocalIC var)set and get methods for preserving stickiness.
This is a temporary solution
to store the sticky IC as a thread local variable.
This sticky IC will be used by all classes that require a context
object to do lookup (if LB is enabled)
SerialContext.lookup() sets a value for the thread local variable
(stickyContext) before performing th lookup in case LB is enabled.
If not, the thread local variable is null.
At the end of the SerialContext.lookup() method, the thread local
variable gets set to null.
So actually speaking, more than being a global variable for the
entire thread, its global only during the execution of the
SerialContext.lookup() method. bug 5050591
This will be cleaned for the next release.
stickyContext.set(var);
|
public void | unbind(java.lang.String name)Unbind the object with the specified name.
name = getRelativeName(name);
if (isjavaURL(name)) {
javaUrlContext.unbind(name);
} else {
try {
getProvider().unbind(name);
} catch (RemoteException ex) {
throw new CommunicationException(ex.toString());
}
}
|
public void | unbind(javax.naming.Name name)Unbind the object with the specified name.
// Flat namespace; no federation; just call string version
unbind(name.toString());
|