|-----Original Message-----
|From: [EMAIL PROTECTED]
|[mailto:[EMAIL PROTECTED]]On Behalf Of Rickard �berg
|Sent: Thursday, October 26, 2000 5:42 AM
|To: jBoss Developer
|Subject: Re: [jBoss-Dev] RE: [jBoss-User] JNDI Problem (and
|EmbeddedTomcat)
|
|
|Rickard �berg wrote:
|> This means that all you have to do to use java:comp/ is to, well, start
|> using it. The first thing you'd want to do during initialization of it,
|> for example, is to create the "env" subcontext, like this:
|> Context ctx = (Context)new InitialContext().lookup("java:comp");
|> ctx.createSubcontext("env");
|
|One further example. Let's say you have two components with two
|different classloaders wanting two different namespaces:
|Thread.setContextClassLoader(loader1);
|Context ctx = (Context)new InitialContext().lookup("java:comp");
|ctx.createSubcontext("env");
|ctx.bind("foo","bar"); // Bind java:comp/env/foo to bar in component 1's
|namespace
|
|Thread.setContextClassLoader(loader2);
|Context ctx = (Context)new InitialContext().lookup("java:comp");
|ctx.createSubcontext("env"); // No env currently in loader2's namespace,
|so create it
|ctx.bind("foo","xyzzy"); // Bind java:comp/env/foo to xyzzy in component
|2's namespace
|
|Thread.setContextClassLoader(loader1);
|new InitialContext().lookup("java:comp/env/foo"); // Result is "bar"
|Thread.setContextClassLoader(loader2);
|new InitialContext().lookup("java:comp/env/foo"); // Result is "xyzzy"
|
|Do you see? Pretty easy to use IMO...

yeah that helps... <teen-voice>like, *alot*</teen-voice>

ok so java:/comp is thread local, better than java: being thread local like
we used to
this is why java: is vm local,  it's going in the right direction, but java:
is global


marc


|
|/Rickard
|
|--
|Rickard �berg
|
|Email: [EMAIL PROTECTED]
|http://www.telkel.com
|http://www.jboss.org
|http://www.dreambean.com
|
|
|


Reply via email to