Listing 1

protected Class loadClass(String name,
boolean resolve)
throws ClassNotFoundException
{
if (shouldIsolate(name)) {
Class c = findLoadedClass(name);

if (c == null) {
c = findClass(name);
}

if (resolve) {
resolveClass(c);
}

return c;
}

return super.loadClass(name, resolve);
}



Listing 2

java -cp jmsinterop.jar;d:\wls5.1\lib\weblogicaux.jar
com.wldj.paston.interop.DualWLSJMSClient
d:\bea\wlserver6.1\lib\weblogic.jar
t3://localhost:9001
d:\wls5.1\sp10\lib\weblogic510sp10.jar;d:\wls5.1\classes
t3://localhost:7001

Doing work with Server A:
looking up queue connection factory
initializing queue connection
sending 'Testing'
sent 'Testing'
received 'Testing'
closing objects
Done
Doing work with Server B:
looking up queue connection factory

initializing queue connection
sending 'Testing'
sent 'Testing'
received 'Testing'
closing objects
Done

Listing 3

final Thread thread = Thread.currentThread();

final ClassLoader oldContextClassLoader =
thread.getContextClassLoader();

try {
thread.setContextClassLoader(
isolatingClassLoader);

final Properties jndiProperties =
new Properties();

jndiProperties.put(
Context.INITIAL_CONTEXT_FACTORY,
initialContextFactory);

jndiProperties.put(
Context.PROVIDER_URL,
providerURL);

final Context jndiContext =
new InitialContext(jndiProperties);

final QueueConnectionFactory
queueConnectionFactory =
(QueueConnectionFactory)jndiContext.lookup(
"javax.jms.QueueConnectionFactory");

// ... more JMS work ...
}
finally {
thread.setContextClassLoader(
oldContextClassLoader);
}