diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-12 21:37:32 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-12 21:37:32 +0000 |
commit | d07c609f43b55ebf2922b3251e0f15c9d965b330 (patch) | |
tree | d589ab55d9ad42f476a144f06ee08d7788ca74d3 /sca-java-2.x/trunk/modules/interface-wsdl | |
parent | 39bee7916c491f04132bf7fc00ae95afc109b2b8 (diff) |
Update wsdl resolving to take account of wsdli:location namespace to location url mappings
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@963496 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/interface-wsdl')
4 files changed, 40 insertions, 4 deletions
diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java index 7497dd3c2f..9fd4313af0 100644 --- a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java +++ b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java @@ -21,6 +21,7 @@ package org.apache.tuscany.sca.interfacedef.wsdl; import java.net.URI; import java.util.List; +import java.util.Map; import javax.wsdl.Binding; import javax.wsdl.Definition; @@ -178,6 +179,12 @@ public interface WSDLDefinition extends Base { * * @param nameOfBindingToResolve */ - void setNameOfServiceToResolve(QName nameOfServiceToResolve); + void setNameOfServiceToResolve(QName nameOfServiceToResolve); + + /** + * Gets the wsdli:location attribute namespace mappings + * @return a Map with key being namespace and value the location + */ + Map<String, String> getWsdliLocations(); } diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java index 45763d01b0..5b3ad74229 100644 --- a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java +++ b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java @@ -21,6 +21,7 @@ package org.apache.tuscany.sca.interfacedef.wsdl.impl; import java.net.URI; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -62,6 +63,7 @@ public class WSDLDefinitionImpl implements WSDLDefinition { private QName nameOfPortTypeToResolve; private QName nameOfBindingToResolve; private QName nameOfServiceToResolve; + private Map<String, String> wsdliLocations = new HashMap<String, String>(); protected WSDLDefinitionImpl() { } @@ -311,4 +313,9 @@ public class WSDLDefinitionImpl implements WSDLDefinition { public void setNameOfServiceToResolve(QName nameOfServiceToResolve) { this.nameOfServiceToResolve = nameOfServiceToResolve; } + + @Override + public Map<String, String> getWsdliLocations() { + return wsdliLocations ; + } } diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java index 139a0ebd39..6afa43b905 100644 --- a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java +++ b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java @@ -339,6 +339,17 @@ public class WSDLModelResolver implements ModelResolver { return modelClass.cast(unresolved); } + // Lookup based on wsdli:location + if (((WSDLDefinition)unresolved).getWsdliLocations().containsKey(namespace)) { + try { + loadDefinition(((WSDLDefinition)unresolved), context); + } catch (ContributionReadException e) { + context.getMonitor().error(context.getMonitor(), this, "interface-wsdlxml-validation-messages", "wsdliLocationException", e, ((WSDLDefinition)unresolved).getNamespace()); + } + return modelClass.cast((WSDLDefinition)unresolved); + } + + // Lookup a definition for the given namespace, from imports for (Import import_ : this.contribution.getImports()) { if (import_ instanceof NamespaceImport) { @@ -458,11 +469,20 @@ public class WSDLModelResolver implements ModelResolver { * @throws ContributionReadException */ private void loadDefinition(WSDLDefinition wsdlDef, ProcessorContext context) throws ContributionReadException { - if (wsdlDef.getDefinition() != null || wsdlDef.getLocation() == null) { + if (wsdlDef.getDefinition() != null) { return; } try { - URL artifactURL = wsdlDef.getLocation().toURL(); + URL artifactURL; + String loc = wsdlDef.getWsdliLocations().get(wsdlDef.getNamespace()); + if (loc != null) { + artifactURL = new URL(loc); + } else { + if (wsdlDef.getLocation() == null) { + return; + } + artifactURL = wsdlDef.getLocation().toURL(); + } // Read a WSDL document InputStream is = IOHelper.openStream(artifactURL); WSDLReader reader = wsdl4jFactory.newWSDLReader(); @@ -474,6 +494,7 @@ public class WSDLModelResolver implements ModelResolver { // Collection of namespace,location for wsdl:import definition Map<String, String> wsdlImports = indexRead(wsdlDef.getLocation().toURL()); + wsdlImports.putAll(wsdlDef.getWsdliLocations()); WSDLLocatorImpl locator = new WSDLLocatorImpl(context, artifactURL, is, wsdlImports); Definition definition = reader.readWSDL(locator); wsdlDef.setDefinition(definition); diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/resources/interface-wsdlxml-validation-messages.properties b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/resources/interface-wsdlxml-validation-messages.properties index 11756711be..101d9de60c 100644 --- a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/resources/interface-wsdlxml-validation-messages.properties +++ b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/resources/interface-wsdlxml-validation-messages.properties @@ -23,4 +23,5 @@ ContributionResolveException = ContributionResolveException occured due to : {0} InvalidWSDLInterfaceAttr = Invalid WSDL interface attribute: {0} WsdlInterfaceDoesNotMatch = The WSDL referenced by the interface.wsdl interface as ({0}) cannot be found in this contribution or in any imports that this contribution makes InvalidRemotableValue = The interface.wsdl interface {0} element can only have a remotable attribute with the value "true" as WSDL interface are assumed to be remotable by default. The value that was found is: {1}. -IncompatibleCallbacks = The interface.wsdl element has a forward interface with a callback declared in the WSDL {0} and a callback interface also declared using the callbackInterface attribute {1} but the callback interfaces are not equal.
\ No newline at end of file +IncompatibleCallbacks = The interface.wsdl element has a forward interface with a callback declared in the WSDL {0} and a callback interface also declared using the callbackInterface attribute {1} but the callback interfaces are not equal. +wsdliLocationException = Exception locating wsdli:location resource: {0}
\ No newline at end of file |