You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2012/10/15 19:54:36 UTC
svn commit: r1398422 - in /axis/axis1/java/branches/AXIS-1984: axis-rt-core/
axis-rt-core/src/main/java/org/apache/axis/wsdl/gen/
axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/
maven/maven-wsdl2java-plugin/
Author: veithen
Date: Mon Oct 15 17:54:35 2012
New Revision: 1398422
URL: http://svn.apache.org/viewvc?rev=1398422&view=rev
Log:
Some unfinished work for AXIS-1984.
Added:
axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/NullEntityResolver.java (with props)
axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/WSDLLocatorAdapter.java (with props)
Modified:
axis/axis1/java/branches/AXIS-1984/axis-rt-core/pom.xml
axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/gen/Parser.java
axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/SymbolTable.java
axis/axis1/java/branches/AXIS-1984/maven/maven-wsdl2java-plugin/pom.xml
Modified: axis/axis1/java/branches/AXIS-1984/axis-rt-core/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis1/java/branches/AXIS-1984/axis-rt-core/pom.xml?rev=1398422&r1=1398421&r2=1398422&view=diff
==============================================================================
--- axis/axis1/java/branches/AXIS-1984/axis-rt-core/pom.xml (original)
+++ axis/axis1/java/branches/AXIS-1984/axis-rt-core/pom.xml Mon Oct 15 17:54:35 2012
@@ -53,7 +53,7 @@
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
- <version>1.5.1</version>
+ <version>1.6.2</version>
</dependency>
<dependency>
<groupId>commons-discovery</groupId>
Modified: axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/gen/Parser.java
URL: http://svn.apache.org/viewvc/axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/gen/Parser.java?rev=1398422&r1=1398421&r2=1398422&view=diff
==============================================================================
--- axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/gen/Parser.java (original)
+++ axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/gen/Parser.java Mon Oct 15 17:54:35 2012
@@ -27,6 +27,7 @@ import org.apache.axis.wsdl.symbolTable.
import org.apache.axis.wsdl.symbolTable.TypeEntry;
import org.apache.axis.wsdl.symbolTable.Utils;
import org.w3c.dom.Document;
+import org.xml.sax.EntityResolver;
import org.xml.sax.SAXException;
import javax.wsdl.Binding;
@@ -70,6 +71,8 @@ public class Parser {
/** If this is false, we'll prefer "String[]" to "ArrayOfString" for literal wrapped arrays */
protected boolean wrapArrays = false;
+ protected EntityResolver entityResolver;
+
// Timeout, in milliseconds, to let the Emitter do its work
/** Field timeoutms */
@@ -172,6 +175,26 @@ public class Parser {
}
/**
+ * Get the entity resolver configured for this parser.
+ *
+ * @return the entity resolver, or <code>null</code> if no entity resolver is configured
+ */
+ public EntityResolver getEntityResolver() {
+ return entityResolver;
+ }
+
+ /**
+ * Set the entity resolver for this parser. This is used to load the WSDL file (unless it is
+ * supplied as a {@link Document}) and all imported WSDL and schema documents.
+ *
+ * @param entityResolver
+ * the entity resolver, or <code>null</code> to use a default entity resolver
+ */
+ public void setEntityResolver(EntityResolver entityResolver) {
+ this.entityResolver = entityResolver;
+ }
+
+ /**
* Return the current timeout setting
*
* @return
@@ -298,6 +321,7 @@ public class Parser {
verbose, nowrap);
symbolTable.setQuiet(quiet);
symbolTable.setWrapArrays(wrapArrays);
+ symbolTable.setEntityResolver(entityResolver);
// We run the actual Emitter in a thread that we can kill
WSDLRunnable runnable = new WSDLRunnable(symbolTable, wsdlURI);
@@ -395,6 +419,7 @@ public class Parser {
symbolTable = new SymbolTable(genFactory.getBaseTypeMapping(), imports,
verbose, nowrap);
+ symbolTable.setEntityResolver(entityResolver);
symbolTable.populate(context, doc);
generate(symbolTable);
Added: axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/NullEntityResolver.java
URL: http://svn.apache.org/viewvc/axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/NullEntityResolver.java?rev=1398422&view=auto
==============================================================================
--- axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/NullEntityResolver.java (added)
+++ axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/NullEntityResolver.java Mon Oct 15 17:54:35 2012
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis.wsdl.symbolTable;
+
+import java.io.IOException;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+class NullEntityResolver implements EntityResolver {
+ static final NullEntityResolver INSTANCE = new NullEntityResolver();
+
+ private NullEntityResolver() {}
+
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
+ return null;
+ }
+}
Propchange: axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/NullEntityResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/SymbolTable.java
URL: http://svn.apache.org/viewvc/axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/SymbolTable.java?rev=1398422&r1=1398421&r2=1398422&view=diff
==============================================================================
--- axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/SymbolTable.java (original)
+++ axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/SymbolTable.java Mon Oct 15 17:54:35 2012
@@ -27,6 +27,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.xml.sax.EntityResolver;
import org.xml.sax.SAXException;
import javax.wsdl.Binding;
@@ -170,6 +171,8 @@ public class SymbolTable {
/** Field wsdlURI */
private String wsdlURI = null;
+ private EntityResolver entityResolver;
+
/** If this is false, we will "unwrap" literal arrays, generating a plan "String[]" instead
* of "ArrayOfString" when encountering an element containing a single maxOccurs="unbounded"
* inner element.
@@ -424,6 +427,26 @@ public class SymbolTable {
}
/**
+ * Get the entity resolver.
+ *
+ * @return the entity resolver, or <code>null</code> if no entity resolver is configured
+ */
+ public EntityResolver getEntityResolver() {
+ return entityResolver;
+ }
+
+ /**
+ * Set the entity resolver. This is used to load the WSDL file (unless it is supplied as a
+ * {@link Document}) and all imported WSDL and schema documents.
+ *
+ * @param entityResolver
+ * the entity resolver, or <code>null</code> to use a default entity resolver
+ */
+ public void setEntityResolver(EntityResolver entityResolver) {
+ this.entityResolver = entityResolver;
+ }
+
+ /**
* Dump the contents of the symbol table. For debugging purposes only.
*
* @param out
@@ -516,7 +539,9 @@ public class SymbolTable {
reader.setFeature("javax.wsdl.verbose", verbose);
- this.def = reader.readWSDL(context, doc);
+ this.def = reader.readWSDL(new WSDLLocatorAdapter(context,
+ entityResolver != null ? entityResolver : NullEntityResolver.INSTANCE),
+ doc.getDocumentElement());
add(context, def, doc);
} // populate
Added: axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/WSDLLocatorAdapter.java
URL: http://svn.apache.org/viewvc/axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/WSDLLocatorAdapter.java?rev=1398422&view=auto
==============================================================================
--- axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/WSDLLocatorAdapter.java (added)
+++ axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/WSDLLocatorAdapter.java Mon Oct 15 17:54:35 2012
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis.wsdl.symbolTable;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.wsdl.xml.WSDLLocator;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+class WSDLLocatorAdapter implements WSDLLocator {
+ private final String baseURI;
+ private final EntityResolver entityResolver;
+ private String latestImportURI;
+
+ WSDLLocatorAdapter(String baseURI, EntityResolver entityResolver) {
+ this.baseURI = baseURI;
+ this.entityResolver = entityResolver;
+ }
+
+ private InputSource getInputSource(String uri) {
+ try {
+ InputSource is = entityResolver.resolveEntity(null, uri);
+ return is != null ? is : new InputSource(uri);
+ } catch (SAXException ex) {
+ return null;
+ } catch (IOException ex) {
+ return null;
+ }
+ }
+
+ public InputSource getBaseInputSource() {
+ return getInputSource(baseURI);
+ }
+
+ public String getBaseURI() {
+ return baseURI;
+ }
+
+ public InputSource getImportInputSource(String parentLocation, String importLocation) {
+ if (parentLocation == null) {
+ latestImportURI = importLocation;
+ } else {
+ try {
+ latestImportURI = new URI(parentLocation).resolve(importLocation).toString();
+ } catch (URISyntaxException ex) {
+ return null;
+ }
+ }
+ return getInputSource(latestImportURI);
+ }
+
+ public String getLatestImportURI() {
+ return latestImportURI;
+ }
+
+ public void close() {
+ }
+}
Propchange: axis/axis1/java/branches/AXIS-1984/axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/WSDLLocatorAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: axis/axis1/java/branches/AXIS-1984/maven/maven-wsdl2java-plugin/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis1/java/branches/AXIS-1984/maven/maven-wsdl2java-plugin/pom.xml?rev=1398422&r1=1398421&r2=1398422&view=diff
==============================================================================
--- axis/axis1/java/branches/AXIS-1984/maven/maven-wsdl2java-plugin/pom.xml (original)
+++ axis/axis1/java/branches/AXIS-1984/maven/maven-wsdl2java-plugin/pom.xml Mon Oct 15 17:54:35 2012
@@ -65,6 +65,11 @@
<groupId>com.github.veithen.ulog</groupId>
<artifactId>ulog</artifactId>
</dependency>
+ <dependency>
+ <groupId>xml-resolver</groupId>
+ <artifactId>xml-resolver</artifactId>
+ <version>1.2</version>
+ </dependency>
</dependencies>
<profiles>
<profile>