You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2009/12/09 03:14:16 UTC
svn commit: r888677 - in /cxf/branches/2.1.x-fixes: ./
tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
Author: dkulp
Date: Wed Dec 9 02:14:15 2009
New Revision: 888677
URL: http://svn.apache.org/viewvc?rev=888677&view=rev
Log:
Merged revisions 888581 via svnmerge from
https://svn.apache.org/repos/asf/cxf/branches/2.2.x-fixes
................
r888581 | dkulp | 2009-12-08 16:48:49 -0500 (Tue, 08 Dec 2009) | 9 lines
Merged revisions 888567 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r888567 | dkulp | 2009-12-08 16:00:28 -0500 (Tue, 08 Dec 2009) | 1 line
[CXF-2571] ANother attempt at a fix for jar URL's with xjc
........
................
Modified:
cxf/branches/2.1.x-fixes/ (props changed)
cxf/branches/2.1.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.1.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?rev=888677&r1=888676&r2=888677&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java (original)
+++ cxf/branches/2.1.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java Wed Dec 9 02:14:15 2009
@@ -40,6 +40,7 @@
import javax.xml.validation.SchemaFactory;
+import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -65,7 +66,8 @@
import com.sun.tools.xjc.api.TypeAndAnnotation;
import com.sun.tools.xjc.api.XJC;
-
+import org.apache.cxf.Bus;
+import org.apache.cxf.catalog.OASISCatalogManager;
import org.apache.cxf.common.i18n.Message;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.StringUtils;
@@ -242,7 +244,9 @@
Map<String, Element> schemaLists) {
for (String key : schemaLists.keySet()) {
Element ele = schemaLists.get(key);
- ele = removeImportElement(ele);
+ Bus bus = context.get(Bus.class);
+ OASISCatalogManager catalog = bus.getExtension(OASISCatalogManager.class);
+ ele = removeImportElement(ele, key, catalog);
if (context.get(ToolConstants.CFG_VALIDATE_WSDL) != null) {
validateSchema(ele);
}
@@ -375,7 +379,7 @@
return null;
}
- private Element removeImportElement(Element element) {
+ private Element removeImportElement(Element element, String sysId, OASISCatalogManager catalog) {
List<Element> impElemList = DOMUtils.findAllElementsByTagNameNS(element,
ToolConstants.SCHEMA_URI,
"import");
@@ -395,18 +399,17 @@
Node importNode = elem;
ns.add(importNode);
}
+ for (Node item : ns) {
+ Node schemaNode = item.getParentNode();
+ schemaNode.removeChild(item);
+ }
+
incElemList = DOMUtils.findAllElementsByTagNameNS(element,
ToolConstants.SCHEMA_URI,
"include");
for (Element elem : incElemList) {
- Node importNode = elem;
- ns.add(importNode);
- }
-
-
- for (Node item : ns) {
- Node schemaNode = item.getParentNode();
- schemaNode.removeChild(item);
+ Attr val = elem.getAttributeNode("schemaLocation");
+ val.setNodeValue(mapSchemaLocation(val.getNodeValue(), sysId, catalog));
}
return element;
}
@@ -741,6 +744,35 @@
}
}
}
-
+ private static String mapSchemaLocation(String target, String base, OASISCatalogManager catalog) {
+ if (catalog != null) {
+ try {
+ String resolvedLocation = catalog.getCatalog().resolveSystem(target);
+
+ if (resolvedLocation == null) {
+ resolvedLocation = catalog.getCatalog().resolveURI(target);
+ }
+ if (resolvedLocation == null) {
+ resolvedLocation = catalog.getCatalog().resolvePublic(target, base);
+ }
+ if (resolvedLocation != null) {
+ return resolvedLocation;
+ }
+
+ } catch (Exception ex) {
+ //ignore
+ }
+ }
+ try {
+ //JAXB xjc cannot properly do this for "jar" URL's so we'll go ahead and do
+ //the resolving ourselves.
+ URL url = new URL(base);
+ url = new URL(url, target);
+ return url.toString();
+ } catch (Exception ex) {
+ //ignore
+ }
+ return target;
+ }
}