You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2012/05/28 14:04:12 UTC

svn commit: r1343216 - in /cxf/branches/2.5.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/ tools/wadlto/jaxrs/src/test/resources/wadl/

Author: sergeyb
Date: Mon May 28 12:04:12 2012
New Revision: 1343216

URL: http://svn.apache.org/viewvc?rev=1343216&view=rev
Log:
Merged revisions 1343210 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1343210 | sergeyb | 2012-05-28 12:51:57 +0100 (Mon, 28 May 2012) | 1 line
  
  Trying to read XMLSchema for WADL generator not to fail with the low memory available, JIRA to be updated when it's available
........

Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
    cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreInlinedSchemaWithImport.xml
    cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreMultipleSchemas.xml
    cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/resourceWithEPR.xml

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:1343210

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

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=1343216&r1=1343215&r2=1343216&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 Mon May 28 12:04:12 2012
@@ -76,6 +76,7 @@ import org.apache.cxf.common.logging.Log
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.util.ReflectionInvokationHandler;
 import org.apache.cxf.common.util.SystemPropertyAction;
+import org.apache.cxf.common.xmlschema.SchemaCollection;
 import org.apache.cxf.common.xmlschema.XmlSchemaConstants;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.DOMUtils;
@@ -88,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.ws.commons.schema.XmlSchema;
 
 /**
  * TODO: This will need to be moved into a separate module
@@ -168,6 +170,8 @@ public class SourceGenerator {
     private Map<String, String> schemaTypesMap = Collections.emptyMap();
     private Bus bus;
     private boolean supportMultipleXmlReps;
+
+    private SchemaCollection schemaCollection = new SchemaCollection();
     
     public SourceGenerator() {
         this(Collections.<String, String>emptyMap());
@@ -1224,8 +1228,21 @@ public class SourceGenerator {
     
     private SchemaInfo createSchemaInfo(Element schemaEl, String systemId) { 
         SchemaInfo info = new SchemaInfo(schemaEl.getAttribute("targetNamespace"));
+
         info.setElement(schemaEl);
         info.setSystemId(systemId);
+
+        // Lets try to read the schema to deal with the possible
+        // eviction of the DOM element from the memory 
+        try {
+            XmlSchema xmlSchema = schemaCollection.read(schemaEl, systemId);
+            info.setSchema(xmlSchema);
+        } catch (Exception ex) {
+            // may be due to unsupported resolvers for protocols like
+            // classpath: or not the valid schema definition, may not be critical
+            // for the purpose of the schema compilation.
+        } 
+
         return info;
     }
     
@@ -1303,7 +1320,9 @@ public class SourceGenerator {
                 // when addressing the issue of retrieving WADLs with included schemas  
                 if (key.startsWith("classpath:")) {
                     String resource = key.substring(10);
-                    URL url = getClass().getResource(resource);
+                    URL url = ResourceUtils.getClasspathResourceURL(resource,
+                                                                    SourceGenerator.class,
+                                                                    bus);
                     if (url != null) {
                         try {
                             key = url.toURI().toString();

Modified: cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreInlinedSchemaWithImport.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreInlinedSchemaWithImport.xml?rev=1343216&r1=1343215&r2=1343216&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreInlinedSchemaWithImport.xml (original)
+++ cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreInlinedSchemaWithImport.xml Mon May 28 12:04:12 2012
@@ -32,7 +32,7 @@
         <xs:sequence>
             <xs:element name="name" type="xs:string"/>
             <xs:element name="id" type="xs:int"/>
-            <xs:element name="chapter" ref="ch:thechapter"/>
+            <xs:element ref="ch:thechapter"/>
         </xs:sequence>
       </xs:complexType>
     </xs:schema>

Modified: cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreMultipleSchemas.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreMultipleSchemas.xml?rev=1343216&r1=1343215&r2=1343216&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreMultipleSchemas.xml (original)
+++ cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreMultipleSchemas.xml Mon May 28 12:04:12 2012
@@ -41,7 +41,7 @@
         <xs:sequence>
             <xs:element name="name" type="xs:string"/>
             <xs:element name="id" type="xs:int"/>
-            <xs:element name="chapter" ref="ch:thechapter"/>
+            <xs:element ref="ch:thechapter"/>
         </xs:sequence>
       </xs:complexType>
     </xs:schema>

Modified: cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/resourceWithEPR.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/resourceWithEPR.xml?rev=1343216&r1=1343215&r2=1343216&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/resourceWithEPR.xml (original)
+++ cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/resourceWithEPR.xml Mon May 28 12:04:12 2012
@@ -31,7 +31,7 @@
 	     <xs:complexType>
 	       <xs:sequence>
 	         <xs:element name="name" type="xs:string"/>
-	         <xs:element name="ref" ref="wsa:EndpointReference"/>
+	         <xs:element ref="wsa:EndpointReference"/>
 	       </xs:sequence>  
 	     </xs:complexType>    
 	 </xs:element>