Update ClassLoaderModelResolver to use the thread context classloader as the parent if its available and its not Equinox, so it works when Tuscany jars are outside of the application

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@778343 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
antelder 2009-05-25 08:09:48 +00:00
parent 0c9e426056
commit 0251f1173c

View file

@ -48,7 +48,18 @@ public class ClassLoaderModelResolver extends URLClassLoader implements ModelRes
private Map<String, ModelResolver> importResolvers = new HashMap<String, ModelResolver>();
private static ClassLoader parentClassLoader() {
ClassLoader parentClassLoader = ServiceDiscovery.getInstance().getServiceDiscoverer().getClass().getClassLoader();
ClassLoader parentClassLoader = null;
// FIXME: Need a better way to not use the ThreadContextClassLoader when running in Equinox
if (Thread.currentThread().getContextClassLoader() != null) {
if (!"org.apache.tuscany.sca.extensibility.equinox.EquinoxServiceDiscoverer".equals(ServiceDiscovery.getInstance().getServiceDiscoverer().getClass().getName())) {
parentClassLoader = Thread.currentThread().getContextClassLoader();
}
}
if (parentClassLoader == null) {
parentClassLoader = ServiceDiscovery.getInstance().getServiceDiscoverer().getClass().getClassLoader();
}
return parentClassLoader;
}