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 2012/04/26 18:50:27 UTC
svn commit: r1330953 - in /cxf/branches/2.5.x-fixes:
common/common/src/main/java/org/apache/cxf/jaxb/
rt/core/src/main/java/org/apache/cxf/catalog/
rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/
tools/wadlto/jaxrs/src/test/resources/...
Author: dkulp
Date: Thu Apr 26 16:50:26 2012
New Revision: 1330953
URL: http://svn.apache.org/viewvc?rev=1330953&view=rev
Log:
Merged revisions 1330948 via git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1330948 | dkulp | 2012-04-26 12:47:40 -0400 (Thu, 26 Apr 2012) | 3 lines
[CXF-4118, CXF-4268] Set a catalog based resolver into the schema
compiler to allow using the catalogs.
........
Added:
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/META-INF/
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/META-INF/jax-ws-catalog.xml (with props)
Modified:
cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
Modified: cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java?rev=1330953&r1=1330952&r2=1330953&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java (original)
+++ cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java Thu Apr 26 16:50:26 2012
@@ -65,6 +65,7 @@ import javax.xml.transform.stream.Stream
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.apache.cxf.common.logging.LogUtils;
@@ -939,7 +940,8 @@ public final class JAXBUtils {
}
public interface SchemaCompiler {
-
+ void setEntityResolver(EntityResolver entityResolver);
+
void setErrorListener(Object elForRun);
void setClassNameAllocator(Object allocator);
Modified: cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java?rev=1330953&r1=1330952&r2=1330953&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java (original)
+++ cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java Thu Apr 26 16:50:26 2012
@@ -34,10 +34,13 @@ import java.util.logging.Logger;
import javax.annotation.Resource;
+import org.xml.sax.EntityResolver;
+
import org.apache.cxf.Bus;
import org.apache.cxf.common.injection.NoJSR250Annotations;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.SystemPropertyAction;
+import org.apache.cxf.resource.URIResolver;
import org.apache.xml.resolver.Catalog;
import org.apache.xml.resolver.CatalogManager;
import org.apache.xml.resolver.tools.CatalogResolver;
@@ -53,21 +56,31 @@ public class OASISCatalogManager {
= SystemPropertyAction.getPropertyOrNull(CATALOG_DEBUG_KEY);
- private Object resolver;
+ private EntityResolver resolver;
+ private Object catalog;
private Set<URI> loadedCatalogs = Collections.synchronizedSet(new HashSet<URI>());
private Bus bus;
public OASISCatalogManager() {
resolver = getResolver();
+ catalog = getCatalog(resolver);
}
public OASISCatalogManager(Bus b) {
bus = b;
resolver = getResolver();
+ catalog = getCatalog(resolver);
loadContextCatalogs(DEFAULT_CATALOG_NAME);
}
-
- private static Object getResolver() {
+ private static Object getCatalog(EntityResolver resolver) {
+ try {
+ return ((CatalogResolver)resolver).getCatalog();
+ } catch (Throwable t) {
+ //ignore
+ }
+ return null;
+ }
+ private static EntityResolver getResolver() {
try {
CatalogManager catalogManager = new CatalogManager();
if (DEBUG_LEVEL != null) {
@@ -75,8 +88,24 @@ public class OASISCatalogManager {
}
catalogManager.setUseStaticCatalog(false);
catalogManager.setIgnoreMissingProperties(true);
- CatalogResolver catalogResolver = new CatalogResolver(catalogManager);
- return catalogResolver.getCatalog();
+ CatalogResolver catalogResolver = new CatalogResolver(catalogManager) {
+ public String getResolvedEntity(String publicId, String systemId) {
+ String s = super.getResolvedEntity(publicId, systemId);
+ if (s != null && s.startsWith("classpath:")) {
+ try {
+ URIResolver r = new URIResolver(s);
+ if (r.isResolved()) {
+ r.getInputStream().close();
+ return r.getURL().toExternalForm();
+ }
+ } catch (IOException e) {
+ //ignore
+ }
+ }
+ return s;
+ }
+ };
+ return catalogResolver;
} catch (Throwable t) {
//ignore
}
@@ -108,7 +137,7 @@ public class OASISCatalogManager {
}
public final void loadCatalogs(ClassLoader classLoader, String name) throws IOException {
- if (classLoader == null || resolver == null) {
+ if (classLoader == null || catalog == null) {
return;
}
@@ -116,14 +145,14 @@ public class OASISCatalogManager {
while (catalogs.hasMoreElements()) {
URL catalogURL = catalogs.nextElement();
if (!loadedCatalogs.contains(URI.create(catalogURL.toString()))) {
- ((Catalog)resolver).parseCatalog(catalogURL);
+ ((Catalog)catalog).parseCatalog(catalogURL);
loadedCatalogs.add(URI.create(catalogURL.toString()));
}
}
}
public final void loadCatalog(URL catalogURL) throws IOException {
- if (!loadedCatalogs.contains(URI.create(catalogURL.toString())) && resolver != null) {
+ if (!loadedCatalogs.contains(URI.create(catalogURL.toString())) && catalog != null) {
if ("file".equals(catalogURL.getProtocol())) {
try {
File file = new File(catalogURL.toURI());
@@ -135,7 +164,7 @@ public class OASISCatalogManager {
}
}
- ((Catalog)resolver).parseCatalog(catalogURL);
+ ((Catalog)catalog).parseCatalog(catalogURL);
loadedCatalogs.add(URI.create(catalogURL.toString()));
}
@@ -167,23 +196,27 @@ public class OASISCatalogManager {
}
public String resolveSystem(String sys) throws MalformedURLException, IOException {
- if (resolver == null) {
+ if (catalog == null) {
return null;
}
- return ((Catalog)resolver).resolveSystem(sys);
+ return ((Catalog)catalog).resolveSystem(sys);
}
public String resolveURI(String uri) throws MalformedURLException, IOException {
- if (resolver == null) {
+ if (catalog == null) {
return null;
}
- return ((Catalog)resolver).resolveURI(uri);
+ return ((Catalog)catalog).resolveURI(uri);
}
public String resolvePublic(String uri, String parent) throws MalformedURLException, IOException {
if (resolver == null) {
return null;
}
- return ((Catalog)resolver).resolvePublic(uri, parent);
+ return ((Catalog)catalog).resolvePublic(uri, parent);
+ }
+
+ public EntityResolver getEntityResolver() {
+ return resolver;
}
}
Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java?rev=1330953&r1=1330952&r2=1330953&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java (original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java Thu Apr 26 16:50:26 2012
@@ -66,7 +66,9 @@ import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
+import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.apache.cxf.Bus;
@@ -88,6 +90,7 @@ import org.apache.cxf.jaxrs.utils.JAXRSU
import org.apache.cxf.jaxrs.utils.ResourceUtils;
import org.apache.cxf.service.model.SchemaInfo;
import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.xml.resolver.tools.CatalogResolver;
/**
* TODO: This will need to be moved into a separate module
@@ -1256,8 +1259,9 @@ public class SourceGenerator {
private JCodeModel createCodeModel(List<SchemaInfo> schemaElements, Set<String> type) {
-
SchemaCompiler compiler = createCompiler(type);
+ compiler.setEntityResolver(OASISCatalogManager.getCatalogManager(bus)
+ .getEntityResolver());
if (compilerArgs.size() > 0) {
compiler.getOptions().addGrammar(new InputSource("null"));
compiler.getOptions().parseArguments(compilerArgs.toArray(new String[] {}));
Added: cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/META-INF/jax-ws-catalog.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/META-INF/jax-ws-catalog.xml?rev=1330953&view=auto
==============================================================================
--- cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/META-INF/jax-ws-catalog.xml (added)
+++ cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/META-INF/jax-ws-catalog.xml Thu Apr 26 16:50:26 2012
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
+ <rewriteSystem systemIdStartString="http://www.w3.org/2005/08/addressing" rewritePrefix="classpath:/schemas/wsdl"/>
+</catalog>
Propchange: cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/META-INF/jax-ws-catalog.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/META-INF/jax-ws-catalog.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/META-INF/jax-ws-catalog.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml