summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/contribution/src/main/java/org
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2012-08-03 08:01:47 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2012-08-03 08:01:47 +0000
commite720311a52f90cc227eecb486cde62bdf040bf98 (patch)
tree95e78e34593c9c719f9ce4ac8f11fb27c0a00d37 /sca-java-2.x/trunk/modules/contribution/src/main/java/org
parentd3900dcc529e8f432bf920d720200d41960be3a7 (diff)
TUSCANY-4068: Start investigating a fix for finding resources from imported contributions.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1368826 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/contribution/src/main/java/org')
-rw-r--r--sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java36
1 files changed, 32 insertions, 4 deletions
diff --git a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java
index bb7ae3f29d..f782f72ed0 100644
--- a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java
+++ b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java
@@ -21,7 +21,7 @@ package org.apache.tuscany.sca.contribution.java.impl;
import java.io.IOException;
import java.lang.ref.WeakReference;
-import java.lang.reflect.Field;
+import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
@@ -30,8 +30,8 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Vector;
+import org.apache.tuscany.sca.contribution.Artifact;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.Import;
import org.apache.tuscany.sca.contribution.java.JavaImport;
@@ -132,13 +132,41 @@ public class ClassLoaderModelResolver extends URLClassLoader implements ModelRes
@Override
public URL findResource(String name) {
-
- //TODO delegate to the Java import resolvers
+ // TODO delegate to the Java import resolvers
+ // thats hard to do for arbitrary resources but for .wsdl or .xsd resources this
+ // can try to honour any namespace imports...
+ // however the namespace of the .wsdl or.xsd file isn't know until its read
+ if (name.endsWith(".wsdl") || name.endsWith(".xsd")) {
+ for (Contribution c : contribution.get().getDependencies()) {
+ for (Artifact a : c.getArtifacts()) {
+ if (a.getURI().equals(name)) {
+ if (contributionImports(getNamespace(a), c)) {
+ try {
+ return new URL(a.getLocation());
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ }
+ }
+ }
URL url = super.findResource(name);
return url;
}
+ private boolean contributionImports(String namespace, Contribution c) {
+ // TODO: does this contribution import the namespace from contribution c
+ return true;
+ }
+
+ private String getNamespace(Artifact a) {
+ // TODO: if the artifact model is a WSDLDefinition or XSDefinition then call getNamespace on that
+ // this module doesn't have dependencies on wsdl or xsd though so thats hard to do
+ return null;
+ }
+
@Override
public Enumeration<URL> findResources(String name) throws IOException {