summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml
diff options
context:
space:
mode:
authorramkumar <ramkumar@13f79535-47bb-0310-9956-ffa450edef68>2009-03-26 10:22:47 +0000
committerramkumar <ramkumar@13f79535-47bb-0310-9956-ffa450edef68>2009-03-26 10:22:47 +0000
commit94aadd0d3038eb9be60642ff6eb0d1a11a600be4 (patch)
tree8d3632d322bd051368053bc8fde17dce7411e6a4 /branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml
parent64672808a634a51b77756d20d2bf6349ac839364 (diff)
Fixes for TUSCANY-2906
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@758582 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml')
-rw-r--r--branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java82
1 files changed, 62 insertions, 20 deletions
diff --git a/branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java b/branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java
index 9c23458743..cb7072de62 100644
--- a/branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java
+++ b/branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java
@@ -205,7 +205,7 @@ public class WSDLModelResolver implements ModelResolver {
}
latestImportURI = url.toString();
return XMLDocumentHelper.getInputSource(url);
- } catch (Exception e) {
+ } catch (IOException e) {
throw new ContributionRuntimeException(e);
}
}
@@ -247,18 +247,18 @@ public class WSDLModelResolver implements ModelResolver {
* @param definitions A list of the WSDL definitions under the same target namespace
* @return The aggregated WSDL definition
*/
- private WSDLDefinition aggregate(List<WSDLDefinition> definitions) {
+ private WSDLDefinition aggregate(List<WSDLDefinition> definitions) throws ContributionReadException {
if (definitions == null || definitions.size() == 0) {
return null;
}
if (definitions.size() == 1) {
WSDLDefinition d = definitions.get(0);
- loadOnDemand(d);
+ loadDefinition(d);
return d;
}
WSDLDefinition aggregated = wsdlFactory.createWSDLDefinition();
for (WSDLDefinition d : definitions) {
- loadOnDemand(d);
+ loadDefinition(d);
}
Definition facade = wsdl4jFactory.newDefinition();
String ns = definitions.get(0).getNamespace();
@@ -290,7 +290,12 @@ public class WSDLModelResolver implements ModelResolver {
return modelClass.cast(unresolved);
}
List<WSDLDefinition> list = map.get(namespace);
- WSDLDefinition resolved = aggregate(list);
+ WSDLDefinition resolved = null;
+ try {
+ resolved = aggregate(list);
+ } catch (ContributionReadException e) {
+ throw new RuntimeException(e);
+ }
if (resolved != null && !resolved.isUnresolved()) {
return modelClass.cast(resolved);
}
@@ -322,23 +327,37 @@ public class WSDLModelResolver implements ModelResolver {
}
return modelClass.cast(unresolved);
}
-
- /**
- * Load the WSDL definition on demand
- * @param def
- */
- private void loadOnDemand(WSDLDefinition def) {
- if (def.getDefinition() == null && def.getLocation() != null) {
- // Load the definition on-demand
+
+ // Use non-sca mechanism to resolve the import location, if not
+ // found then use the sca mechanism
+ private <T> T resolveImports (Class<T> modelClass, WSDLDefinition unresolved) {
+
+ WSDLDefinition resolved = null;
+ if (unresolved.getDefinition() == null && unresolved.getLocation() != null) {
try {
- loadDefinition(def);
+ // Load the definition using non-sca mechanism.
+ List<WSDLDefinition> list = new ArrayList<WSDLDefinition>();
+ list.add(unresolved);
+ map.put(unresolved.getNamespace(), list);
+ resolved = aggregate(list);
+ // if no exception then its resolved.
+ if (unresolved.getNamespace().equals(resolved.getDefinition().getTargetNamespace())) {
+ resolved.setNamespace(resolved.getDefinition().getTargetNamespace());
+ resolved.setUnresolved(false);
+ resolved.setURI(resolved.getLocation());
+ return modelClass.cast(resolved);
+ }
} catch (ContributionReadException e) {
- throw new RuntimeException(e);
+ // Load the definition using sca mechanism.
+ resolved = resolveModel(WSDLDefinition.class, unresolved);
+ if (resolved != null && !resolved.isUnresolved()) {
+ return modelClass.cast(resolved);
+ }
}
}
- }
-
- // private Map<String, WSDLDefinition> loadedDefinitions = new Hashtable<String, WSDLDefinition>();
+
+ return modelClass.cast(unresolved);
+ }
/**
* Load the WSDL definition and inline schemas
@@ -373,7 +392,30 @@ public class WSDLModelResolver implements ModelResolver {
WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition();
wsdlDefinition.setUnresolved(true);
wsdlDefinition.setNamespace(entry.getKey());
- WSDLDefinition resolved = resolveModel(WSDLDefinition.class, wsdlDefinition);
+ WSDLDefinition resolved = null;
+ for (javax.wsdl.Import imp : entry.getValue()) {
+ try {
+ wsdlDefinition.setLocation(new URI(imp.getDefinition().getDocumentBaseURI()));
+ resolved = resolveImports(WSDLDefinition.class, wsdlDefinition);
+ if (!resolved.isUnresolved()) {
+ if (resolved.getDefinition().getDocumentBaseURI().equals(imp.getDefinition().getDocumentBaseURI())) {
+ // this WSDLDefinition contains the imported document
+ wsdlDef.getImportedDefinitions().add(resolved);
+ } else {
+ // this is a facade, so look in its imported definitions
+ for (WSDLDefinition def : resolved.getImportedDefinitions()) {
+ if (def.getDefinition().getDocumentBaseURI().equals(imp.getDefinition().getDocumentBaseURI())) {
+ wsdlDef.getImportedDefinitions().add(def);
+ break;
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new ContributionReadException(e);
+ }
+ }
+ /*resolved = resolveImports(WSDLDefinition.class, wsdlDefinition);
if (!resolved.isUnresolved()) {
for (javax.wsdl.Import imp : entry.getValue()) {
if (resolved.getDefinition().getDocumentBaseURI().equals(imp.getDefinition().getDocumentBaseURI())) {
@@ -389,7 +431,7 @@ public class WSDLModelResolver implements ModelResolver {
}
}
}
- }
+ }*/
}
}