summaryrefslogtreecommitdiffstats
path: root/java/sca
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-05-25 08:09:48 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-05-25 08:09:48 +0000
commit0251f1173c18e278bb2c76360c08644884fd25e7 (patch)
tree3977eac59bcfdf08744c79c733be2d162e64dc12 /java/sca
parent0c9e42605632996661916f9c3796f909b388cb68 (diff)
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
Diffstat (limited to 'java/sca')
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java13
1 files changed, 12 insertions, 1 deletions
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<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;
}