Author: jkaputin
Date: Wed Sep 28 10:12:18 2005
New Revision: 292229
URL: http://svn.apache.org/viewcvs?rev=292229&view=rev
Log:
Added logic to check if a schema has already been imported.
Modified:
incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
Modified: incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
URL:
http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java?rev=292229&r1=292228&r2=292229&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
(original)
+++ incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java Wed
Sep 28 10:12:18 2005
@@ -7,6 +7,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
+import java.util.Hashtable;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
@@ -45,15 +46,14 @@
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-
-
-
-
/**
* @author [EMAIL PROTECTED]
*/
public class DOMWSDLReader extends BaseWSDLReader {
+ //a map of imported schema docs keyed by location URI
+ private Map fImportedSchemas = new Hashtable();
+
public DOMWSDLReader() throws WSDLException {
super();
}
@@ -379,20 +379,28 @@
}
String schemaURL = url.toString();
+ boolean justImported = false;
- try {
- importedSchemaDoc = getDocument(new InputSource(schemaURL),
schemaURL);
-
- } catch (IOException e4) {
-
- //the failed retrieval is reported as a warning, not an error.
- getErrorReporter().reportError(
- "WSDL015", new Object[] {schemaURL},
ErrorReporter.SEVERITY_WARNING, e4);
- return schemaImport;
- }
+ //If the schema has already been imported, reuse it.
+ Schema schema = (Schema)fImportedSchemas.get(schemaURL);
- schemaEl = importedSchemaDoc.getDocumentElement();
- Schema schema = parseSchema(schemaEl, desc);
+ if(schema == null)
+ {
+ //not previously imported, so retrieve it now.
+ try {
+ importedSchemaDoc = getDocument(new InputSource(schemaURL),
schemaURL);
+
+ } catch (IOException e4) {
+
+ //the failed retrieval is reported as a warning, not an error.
+ getErrorReporter().reportError(
+ "WSDL015", new Object[] {schemaURL},
ErrorReporter.SEVERITY_WARNING, e4);
+ return schemaImport;
+ }
+ schemaEl = importedSchemaDoc.getDocumentElement();
+ schema = parseSchema(schemaEl, desc);
+ justImported = true;
+ }
if(schema.getTargetNamespace() == null)
{
@@ -421,8 +429,11 @@
schemaImport.setSchema(schema);
- return schemaImport;
+ if(justImported) {
+ fImportedSchemas.put(schemaURL, schema);
+ }
+ return schemaImport;
}
/*
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]