From 0251f1173c18e278bb2c76360c08644884fd25e7 Mon Sep 17 00:00:00 2001 From: antelder Date: Mon, 25 May 2009 08:09:48 +0000 Subject: 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 --- .../contribution/java/impl/ClassLoaderModelResolver.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java index 64ff500741..516b0d6342 100644 --- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java +++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java @@ -48,7 +48,18 @@ public class ClassLoaderModelResolver extends URLClassLoader implements ModelRes private Map importResolvers = new HashMap(); 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; } -- cgit v1.2.3