cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1330962 - in /cxf/branches/2.4.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/resourc...
Date Thu, 26 Apr 2012 16:54:40 GMT
Author: dkulp
Date: Thu Apr 26 16:54:39 2012
New Revision: 1330962

URL: http://svn.apache.org/viewvc?rev=1330962&view=rev
Log:
Merged revisions 1330953 via  svn merge from
https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes

........
  r1330953 | dkulp | 2012-04-26 12:50:26 -0400 (Thu, 26 Apr 2012) | 10 lines
  
  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.4.x-fixes/tools/wadlto/jaxrs/src/test/resources/META-INF/
      - copied from r1330953, cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/META-INF/
Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
    cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java?rev=1330962&r1=1330961&r2=1330962&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
(original)
+++ cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
Thu Apr 26 16:54:39 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;
@@ -943,7 +944,8 @@ public final class JAXBUtils {
     }
     
     public interface SchemaCompiler {
-
+        void setEntityResolver(EntityResolver entityResolver);
+        
         void setErrorListener(Object elForRun);
 
         void setClassNameAllocator(Object allocator);

Modified: cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java?rev=1330962&r1=1330961&r2=1330962&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
Thu Apr 26 16:54:39 2012
@@ -33,9 +33,12 @@ 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.resource.URIResolver;
 import org.apache.xml.resolver.Catalog;
 import org.apache.xml.resolver.CatalogManager;
 import org.apache.xml.resolver.tools.CatalogResolver;
@@ -50,21 +53,31 @@ public class OASISCatalogManager {
     private static final String DEBUG_LEVEL = System.getProperty(CATALOG_DEBUG_KEY);
     
 
-    private Object resolver;
+    private EntityResolver resolver;
+    private Object catalog;
     private Set<URL> loadedCatalogs = Collections.synchronizedSet(new HashSet<URL>());
     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) {
@@ -72,8 +85,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
         }        
@@ -105,7 +134,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;
         }
 
@@ -113,14 +142,14 @@ public class OASISCatalogManager {
         while (catalogs.hasMoreElements()) {
             URL catalogURL = catalogs.nextElement();
             if (!loadedCatalogs.contains(catalogURL)) {
-                ((Catalog)resolver).parseCatalog(catalogURL);
+                ((Catalog)catalog).parseCatalog(catalogURL);
                 loadedCatalogs.add(catalogURL);
             }
         }
     }
 
     public final void loadCatalog(URL catalogURL) throws IOException {
-        if (!loadedCatalogs.contains(catalogURL) && resolver != null) {
+        if (!loadedCatalogs.contains(catalogURL) && catalog != null) {
             if ("file".equals(catalogURL.getProtocol())) {
                 try {
                     File file = new File(catalogURL.toURI());
@@ -132,7 +161,7 @@ public class OASISCatalogManager {
                 }
             }
 
-            ((Catalog)resolver).parseCatalog(catalogURL);
+            ((Catalog)catalog).parseCatalog(catalogURL);
 
             loadedCatalogs.add(catalogURL);
         }
@@ -164,23 +193,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.4.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.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java?rev=1330962&r1=1330961&r2=1330962&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
Thu Apr 26 16:54:39 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;
@@ -87,6 +89,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
@@ -1176,8 +1179,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[] {}));



Mime
View raw message