User: starksm
Date: 01/09/06 18:31:35
Modified: src/main/org/jboss/naming Tag: Branch_2_4 ENCFactory.java
NamingService.java
Log:
Update the java:comp lookup to first look for a binding for a parent
ClassLoader if the current thread context ClassLoader does not have
a java:comp entry.
Revision Changes Path
No revision
No revision
1.3.6.2 +26 -21 jboss/src/main/org/jboss/naming/ENCFactory.java
Index: ENCFactory.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/naming/ENCFactory.java,v
retrieving revision 1.3.6.1
retrieving revision 1.3.6.2
diff -u -r1.3.6.1 -r1.3.6.2
--- ENCFactory.java 2001/09/03 23:00:22 1.3.6.1
+++ ENCFactory.java 2001/09/07 01:31:34 1.3.6.2
@@ -14,16 +14,13 @@
import org.jnp.interfaces.NamingContext;
/**
- * Implementation of "java:" namespace factory. The context is associated
- * with the thread, so the root context must be set before this is used in a
thread
- *
- * SA FIXME: the java: namespace should be global. the java:comp/env subcontext
should
- * be threadlocal
+ * Implementation of "java:comp" namespace factory. The context is associated
+ * with the thread class loader.
*
* @see <related>
* @author Rickard Oberg ([EMAIL PROTECTED])
* @author [EMAIL PROTECTED]
- * @version $Revision: 1.3.6.1 $
+ * @version $Revision: 1.3.6.2 $
*/
public class ENCFactory
implements ObjectFactory
@@ -31,12 +28,20 @@
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
- static Hashtable encs = new Hashtable();
-
+ private static Hashtable encs = new Hashtable();
+ private static ClassLoader topLoader;
+
// Static --------------------------------------------------------
-
+ public static void setTopClassLoader(ClassLoader topLoader)
+ {
+ ENCFactory.topLoader = topLoader;
+ }
+ public static ClassLoader getTopClassLoader()
+ {
+ return ENCFactory.topLoader;
+ }
// Constructors --------------------------------------------------
-
+
// Public --------------------------------------------------------
// ObjectFactory implementation ----------------------------------
@@ -50,28 +55,28 @@
{
// Get naming for this component
ClassLoader ctxClassLoader =
Thread.currentThread().getContextClassLoader();
- NamingServer srv = (NamingServer) encs.get(ctxClassLoader);
+ Context compCtx = (Context) encs.get(ctxClassLoader);
/* If this is the first time we see ctxClassLoader first check to see
if a parent ClassLoader has created an ENC namespace.
*/
- if (srv == null)
+ if (compCtx == null)
{
- ClassLoader parent = ctxClassLoader.getParent();
- while( parent != null && srv == null )
+ ClassLoader loader = ctxClassLoader;
+ while( loader != null && loader != topLoader && compCtx == null )
{
- parent = parent.getParent();
- if( parent != null )
- srv = (NamingServer) encs.get(parent);
+ compCtx = (Context) encs.get(loader);
+ loader = loader.getParent();
}
// If we did not find an ENC create it
- if( srv == null )
+ if( compCtx == null )
{
- srv = new NamingServer();
- encs.put(ctxClassLoader, srv);
+ NamingServer srv = new NamingServer();
+ compCtx = new NamingContext(environment, null, srv);
+ encs.put(ctxClassLoader, compCtx);
}
}
- return new NamingContext(environment, null, srv);
+ return compCtx;
}
}
1.11.4.3 +7 -3 jboss/src/main/org/jboss/naming/NamingService.java
Index: NamingService.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/naming/NamingService.java,v
retrieving revision 1.11.4.2
retrieving revision 1.11.4.3
diff -u -r1.11.4.2 -r1.11.4.3
--- NamingService.java 2001/07/19 20:13:07 1.11.4.2
+++ NamingService.java 2001/09/07 01:31:34 1.11.4.3
@@ -29,7 +29,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rickard �berg</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>.
- * @version $Revision: 1.11.4.2 $
+ * @version $Revision: 1.11.4.3 $
*
* Revisions:
* 20010622 scott.stark: Report IntialContext env for problem tracing
@@ -168,10 +168,14 @@
if( providerURL != null )
category.warn("Saw Context.PROVIDER_URL in server jndi.properties,
url="+providerURL);
- // Create "java:comp/env"
+ /* Bind a ObjectFactory to "java:comp" so that "java:comp/env" lookups
produce a
+ unique context for each thread contexxt ClassLoader that performs the lookup.
+ */
+ ClassLoader topLoader = Thread.currentThread().getContextClassLoader();
+ ENCFactory.setTopClassLoader(topLoader);
RefAddr refAddr = new StringRefAddr("nns", "ENC");
Reference envRef = new Reference("javax.naming.Context", refAddr,
ENCFactory.class.getName(), null);
- Context ctx = (Context)iniCtx.lookup("java:");
+ Context ctx = (Context) iniCtx.lookup("java:");
ctx.rebind("comp", envRef);
category.info("Naming started on port "+naming.getPort());
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development