There is a bit history here. ContextClassLoaderServiceDiscoverer used to be ClassLoaderServiceDiscoverer and it expects the Node to configure it with the runtime classloader. Then we moved into the world that NodeFactory can be shared by multiple nodes which can have different TCCLs.

We use ServiceDiscovery.getInstance().getContextClassLoader() to set the parent classloader for the contributions. TCCL is not always reliable here so we leave it to the ServiceDiscover impl.

I suggest that we make the following changes:

1) Removed the cached classloader
2) For classloader based discovery, we can use ContextClassLoaderServiceDiscoverer.class.getClassLoader() assuming that all core and extension modules will be loaded by the same classloader (OSGi has its discoverer). Using TCCL is fine too if it has access to the Tuscany runtime classes. 3) Return current TCCL from org.apache.tuscany.sca.extensibility.ContextClassLoaderServiceDiscoverer.getContextClassLoader().

Thanks,
Raymond

--------------------------------------------------
From: "ant elder" <[email protected]>
Sent: Friday, January 15, 2010 3:42 AM
To: <[email protected]>
Subject: Re: ContextClassLoaderServiceDiscoverer use of TCCL

On Fri, Jan 15, 2010 at 11:34 AM, Simon Laws <[email protected]> wrote:
Firstly, it does seem a little odd that it has to cache it. There is
extra effort in doing it so it would be interesting to know why.

This is probably a stupid question but in the new world of the
NodeFactory I thought we only loaded the extensions once. Presumably
using the classloader that loads the factory. What's the effect you
see in your scenario when you have multiple nodes on different
classloaders?

Simon


The scenario is in Tomcat where the Tuscany jars are shared and each
webapp starts a Node. So the extensions are only started once and the
first time ContextClassLoaderServiceDiscoverer gets used it caches the
current value for the TCCL which as its cached is also used for every
other Node in all the other webapps. So then things like the
ModelResolvers try find things using an incorrect classloader.

...ant

Reply via email to