cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1343210 - in /cxf/trunk/tools/wadlto/jaxrs/src: main/java/org/apache/cxf/tools/wadlto/jaxrs/ test/resources/wadl/
Date Mon, 28 May 2012 11:51:57 GMT
Author: sergeyb
Date: Mon May 28 11:51:57 2012
New Revision: 1343210

URL: http://svn.apache.org/viewvc?rev=1343210&view=rev
Log:
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/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
    cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreInlinedSchemaWithImport.xml
    cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreMultipleSchemas.xml
    cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/resourceWithEPR.xml

Modified: cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java?rev=1343210&r1=1343209&r2=1343210&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
(original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
Mon May 28 11:51:57 2012
@@ -80,6 +80,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
@@ -169,6 +171,8 @@ public class SourceGenerator {
     private Bus bus;
     private boolean supportMultipleXmlReps;
     
+    private SchemaCollection schemaCollection = new SchemaCollection();
+    
     public SourceGenerator() {
         this(Collections.<String, String>emptyMap());
     }
@@ -1223,10 +1227,22 @@ public class SourceGenerator {
         return lastSep != -1 ? docPath.substring(0, lastSep + 1) : docPath;
     }
     
-    private SchemaInfo createSchemaInfo(Element schemaEl, String systemId) { 
+    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;
     }
     
@@ -1304,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/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreInlinedSchemaWithImport.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreInlinedSchemaWithImport.xml?rev=1343210&r1=1343209&r2=1343210&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreInlinedSchemaWithImport.xml
(original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreInlinedSchemaWithImport.xml
Mon May 28 11:51:57 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/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreMultipleSchemas.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreMultipleSchemas.xml?rev=1343210&r1=1343209&r2=1343210&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreMultipleSchemas.xml (original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreMultipleSchemas.xml Mon
May 28 11:51:57 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/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/resourceWithEPR.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/resourceWithEPR.xml?rev=1343210&r1=1343209&r2=1343210&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/resourceWithEPR.xml (original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/resourceWithEPR.xml Mon May 28 11:51:57
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>		



Mime
View raw message