Author: mriou
Date: Fri Mar 30 10:54:09 2007
New Revision: 524206
URL: http://svn.apache.org/viewvc?view=rev&rev=524206
Log:
Fixed direct inernal schema importin WSDL (when more than one schema is
declared in the WSDL itself). One more test passes.
Modified:
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java
Modified:
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java?view=diff&rev=524206&r1=524205&r2=524206
==============================================================================
---
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
(original)
+++
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
Fri Mar 30 10:54:09 2007
@@ -18,24 +18,6 @@
*/
package org.apache.ode.bpel.compiler;
-import java.io.StringReader;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.wsdl.Definition;
-import javax.wsdl.Import;
-import javax.wsdl.Message;
-import javax.wsdl.PortType;
-import javax.wsdl.Types;
-import javax.wsdl.extensions.ExtensibilityElement;
-import javax.xml.namespace.QName;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.compiler.api.CompilationException;
@@ -53,6 +35,23 @@
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.wsdl.Message;
+import javax.wsdl.PortType;
+import javax.wsdl.Types;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.xml.namespace.QName;
+import java.io.StringReader;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
/**
* A parsed collection of WSDL definitions, including BPEL-specific extensions.
@@ -66,6 +65,7 @@
private final HashMap<String, ArrayList<Definition4BPEL>> _definitions =
new HashMap<String, ArrayList<Definition4BPEL>>();
private final Map<URI, byte[]> _schemas = new HashMap<URI,byte[]>();
+ private final Map<URI, String> _internalSchemas = new HashMap<URI,
String>();
private SchemaModel _model;
@@ -201,19 +201,16 @@
String schema = ((XMLSchemaType)ee).getXMLSchema();
Map<URI, byte[]> capture = null;
- WsdlFinderXMLEntityResolver resolver = new
WsdlFinderXMLEntityResolver(rf, defuri);
+ WsdlFinderXMLEntityResolver resolver = new
WsdlFinderXMLEntityResolver(rf, defuri, _internalSchemas);
try {
-
capture = XSUtils.captureSchema(defuri, schema,
resolver);
-
- // Add new schemas to our list.
_schemas.putAll(capture);
try {
Document doc = DOMUtils.parse(new InputSource(new
StringReader(schema)));
String schemaTargetNS =
doc.getDocumentElement().getAttribute("targetNamespace");
if (schemaTargetNS != null &&
schemaTargetNS.length() > 0)
- resolver.addInternalResource(new
URI(schemaTargetNS), schema);
+ _internalSchemas.put(new URI(schemaTargetNS),
schema);
} catch (Exception e) {
throw new RuntimeException("Couldn't parse schema
in " + def.getTargetNamespace(), e);
}
Modified:
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java?view=diff&rev=524206&r1=524205&r2=524206
==============================================================================
---
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java
(original)
+++
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java
Fri Mar 30 10:54:09 2007
@@ -18,13 +18,6 @@
*/
package org.apache.ode.bpel.compiler;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.xerces.xni.XMLResourceIdentifier;
@@ -32,6 +25,14 @@
import org.apache.xerces.xni.parser.XMLEntityResolver;
import org.apache.xerces.xni.parser.XMLInputSource;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* Xerces [EMAIL PROTECTED] XMLEntityResolver} implementation that defers to
our own
* [EMAIL PROTECTED] ResourceFinder} interface for loading resources. This
class is
@@ -54,7 +55,7 @@
private boolean _failIfNotFound = true;
private ResourceFinder _wsdlFinder;
- private HashMap<URI,String> _internalResources = new HashMap<URI,
String>();
+ private Map<URI, String> _internalSchemas = new HashMap<URI, String>();
private URI _baseURI;
/**
@@ -64,9 +65,10 @@
* typically this is the system URI of the WSDL containing
an
* embedded schema
*/
- public WsdlFinderXMLEntityResolver(ResourceFinder finder, URI baseURI) {
+ public WsdlFinderXMLEntityResolver(ResourceFinder finder, URI baseURI,
Map<URI, String> internalSchemas) {
_wsdlFinder = finder;
_baseURI = baseURI;
+ _internalSchemas = internalSchemas;
}
public XMLInputSource resolveEntity(XMLResourceIdentifier
resourceIdentifier)
@@ -101,8 +103,8 @@
__log.debug("resolveEntity: Expecting to find " +
resourceIdentifier.getNamespace()
+ " at " + location);
- if (_internalResources.get(location) != null) {
- src.setByteStream(new
ByteArrayInputStream(_internalResources.get(location).getBytes()));
+ if (_internalSchemas.get(location) != null) {
+ src.setByteStream(new
ByteArrayInputStream(_internalSchemas.get(location).getBytes()));
return src;
}
@@ -130,16 +132,6 @@
}
return src;
- }
-
- /**
- * Register a previously loaded resource with the finder; this is used to
make
- * accessible the schema in-lined into a WSDL document.
- * @param location/namespace location/namespace of the resource
- * @param source text of the resource
- */
- public void addInternalResource(URI location, String source) {
- _internalResources.put(location, source);
}
}