geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r219798 - in /geronimo/trunk/modules: axis-builder/src/java/org/apache/geronimo/axis/builder/ j2ee-schema/src/java/org/apache/geronimo/schema/
Date Tue, 19 Jul 2005 23:00:13 GMT
Author: djencks
Date: Tue Jul 19 16:00:12 2005
New Revision: 219798

URL: http://svn.apache.org/viewcvs?rev=219798&view=rev
Log:
GERONIMO-779.  Fix schema reading in ws deployment

Modified:
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightTypeInfoBuilder.java
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/SchemaInfoBuilder.java
    geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java

Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java?rev=219798&r1=219797&r2=219798&view=diff
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java
(original)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java
Tue Jul 19 16:00:12 2005
@@ -62,18 +62,21 @@
 import org.apache.geronimo.xbeans.wsdl.TService;
 import org.apache.geronimo.xbeans.wsdl.TTypes;
 import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
 import org.apache.xmlbeans.impl.xb.xsdschema.ImportDocument;
 import org.apache.xmlbeans.impl.xb.xsdschema.IncludeDocument;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * @version $Rev$ $Date$
  */
 public class AxisServiceBuilder {
+    private static final Log log = LogFactory.getLog(AxisServiceBuilder.class);
+
     public static final String XSD_NS = "http://www.w3.org/2001/XMLSchema";
     public static final QName SCHEMA_QNAME = new QName(XSD_NS, "schema");
-    private static final String SOAP_NS = "http://schemas.xmlsoap.org/wsdl/soap/";
-//    private static final String LOCATION_REPLACEMENT_TOKEN = AxisWebServiceContainer.LOCATION_REPLACEMENT_TOKEN;
 
 
     private static void validateLightweightMapping(Definition definition) throws DeploymentException
{
@@ -238,57 +241,6 @@
                 rewriteSchema(schema, contextURI, key);
                 String schemaString = schemaDocument.toString();
                 wsdlMap.put(key.toString(), schemaString);
-//            } else if (value instanceof Definition) {
-//                Definition definition = (Definition) value;
-//                Map imports = definition.getImports();
-//                for (Iterator iterator2 = imports.values().iterator(); iterator2.hasNext();)
{
-//                    List importList = (List) iterator2.next();
-//                    for (Iterator iterator3 = importList.iterator(); iterator3.hasNext();)
{
-//                        Import anImport = (Import) iterator3.next();
-//                        String importLocation = anImport.getLocationURI();
-//                        if (!importLocation.startsWith("http://")) {
-//                            URI updated = buildQueryURI(contextURI, key, importLocation);
-//                            anImport.setLocationURI(updated.toString());
-//                        }
-//                    }
-//                }
-//                Types types = definition.getTypes();
-//                Map namespaceMap = definition.getNamespaces();
-//                if (null != types) {
-//                    List schemaList = types.getExtensibilityElements();
-//                    for (Iterator iterator1 = schemaList.iterator(); iterator1.hasNext();)
{
-//                        Object o = iterator1.next();
-//                        if (o instanceof Schema) {
-//                            Schema schemaType = (Schema) o;
-//                            Element e = schemaType.getElement();
-//                            try {
-//                                SchemaDocument.Schema schema = (SchemaDocument.Schema)
XmlObject.Factory.parse(e);
-//                                rewriteSchema(schema, contextURI, key);
-//                                Element e2 = (Element) schema.newDomNode();
-//                                schemaType.setElement(e2);
-//                            } catch (XmlException e1) {
-//                                throw new DeploymentException("Could not parse included
schema", e1);
-//                            }
-//                        } else if (o instanceof UnknownExtensibilityElement) {
-//                            UnknownExtensibilityElement u = (UnknownExtensibilityElement)
o;
-//                            QName elementType = u.getElementType();
-//                            if (SCHEMA_QNAME.equals(elementType)) {
-//                                Element e = u.getElement();
-//                                try {
-//                                    SchemaDocument schemaDocument = (SchemaDocument) SchemaInfoBuilder.parseWithNamespaces(e,
namespaceMap);
-//                                    SchemaDocument.Schema schema = schemaDocument.getSchema();
-//                                    rewriteSchema(schema, contextURI, key);
-//                                    Node node = schema.newDomNode();
-//                                    Element e2 = (Element) node.getFirstChild();
-//                                    u.setElement(e2);
-//                                } catch (XmlException e1) {
-//                                    throw new DeploymentException("Could not parse included
schema", e1);
-//                                }
-//                            }
-//                        }
-//                    }
-//                }
-//                wsdlMap.put(key.toString(), definition);
             } else if (value instanceof DefinitionsDocument) {
                 DefinitionsDocument doc = (DefinitionsDocument) ((DefinitionsDocument) value).copy();
                 TDefinitions definitions = doc.getDefinitions();
@@ -316,25 +268,6 @@
                         typeCursor.dispose();
                     }
                 }
-                //now done in SchemaInfoBuilder
-                //prepare for location substitution
-//                TService[] services = definitions.getServiceArray();
-//                for (int i = 0; i < services.length; i++) {
-//                    TService service = services[i];
-//                    TPort[] ports = service.getPortArray();
-//                    for (int j = 0; j < ports.length; j++) {
-//                        TPort port = ports[j];
-//                        XmlCursor portCursor = port.newCursor();
-//                        try {
-//                            if (portCursor.toChild(ADDRESS_QNAME)) {
-//                                //TODO rewrite the path from the actual deployed location,
and just replace the schema/host/port
-//                                portCursor.setAttributeText(LOCATION_QNAME, LOCATION_REPLACEMENT_TOKEN);
-//                            }
-//                        } finally {
-//                            portCursor.dispose();
-//                        }
-//                    }
-//                }
                 wsdlMap.put(key.toString(), doc.toString());
             } else {
                 throw new DeploymentException("Unexpected element in wsdlMap at location:
" + key + ", value: " + value);

Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightTypeInfoBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightTypeInfoBuilder.java?rev=219798&r1=219797&r2=219798&view=diff
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightTypeInfoBuilder.java
(original)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightTypeInfoBuilder.java
Tue Jul 19 16:00:12 2005
@@ -129,7 +129,9 @@
 
             SchemaType schemaType = (SchemaType) schemaTypeKeyToSchemaTypeMap.get(key);
             if (schemaType == null) {
-                throw new DeploymentException("Schema type key " + key + " not found in analyzed
schema: " + schemaTypeKeyToSchemaTypeMap);
+//                throw new DeploymentException("Schema type key " + key + " not found in
analyzed schema: " + schemaTypeKeyToSchemaTypeMap);
+                log.warn("Schema type key " + key + " not found in analyzed schema: " + schemaTypeKeyToSchemaTypeMap);
+                continue;
             }
             mappedTypeQNames.add(key.getqName());
 

Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/SchemaInfoBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/SchemaInfoBuilder.java?rev=219798&r1=219797&r2=219798&view=diff
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/SchemaInfoBuilder.java
(original)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/SchemaInfoBuilder.java
Tue Jul 19 16:00:12 2005
@@ -89,15 +89,15 @@
         if (is == null) {
             throw new RuntimeException("Could not locate soap encoding schema");
         }
-        Collection errors = new ArrayList();
-        XmlOptions xmlOptions = new XmlOptions();
-        xmlOptions.setErrorListener(errors);
+        ArrayList errors = new ArrayList();
+        XmlOptions xmlOptions = SchemaConversionUtils.createXmlOptions(errors);
         try {
-            XmlObject xmlObject = SchemaConversionUtils.parse(is);
-            if (!(xmlObject instanceof SchemaDocument)) {
-                xmlObject = xmlObject.changeType(SchemaDocument.type);
+            SchemaDocument parsed = SchemaDocument.Factory.parse(is, xmlOptions);
+            if (errors.size() != 0) {
+                throw new XmlException(errors.toArray().toString());
             }
-            basicTypeSystem = XmlBeans.compileXsd(new XmlObject[]{xmlObject}, XmlBeans.getBuiltinTypeSystem(),
xmlOptions);
+
+            basicTypeSystem = XmlBeans.compileXsd(new XmlObject[]{parsed}, XmlBeans.getBuiltinTypeSystem(),
xmlOptions);
             if (errors.size() > 0) {
                 throw new RuntimeException("Could not compile schema type system: errors:
" + errors);
             }
@@ -282,7 +282,7 @@
             }
             return schemaTypeSystem;
         } catch (XmlException e) {
-            throw new DeploymentException("Could not compile schema type system", e);
+            throw new DeploymentException("Could not compile schema type system: " + schemaList,
e);
         }
     }
 
@@ -354,8 +354,13 @@
     }
 
     static XmlObject parseWithNamespaces(Element element, Map namespaceMap) throws XmlException
{
-        XmlObject xmlObject = SchemaConversionUtils.parse(element);
-        XmlCursor cursor = xmlObject.newCursor();
+        ArrayList errors = new ArrayList();
+        XmlOptions xmlOptions = SchemaConversionUtils.createXmlOptions(errors);
+        SchemaDocument parsed = SchemaDocument.Factory.parse(element, xmlOptions);
+        if (errors.size() != 0) {
+            throw new XmlException(errors.toArray().toString());
+        }
+        XmlCursor cursor = parsed.newCursor();
         try {
             cursor.toFirstContentToken();
             for (Iterator namespaces = namespaceMap.entrySet().iterator(); namespaces.hasNext();)
{
@@ -365,7 +370,7 @@
         } finally {
             cursor.dispose();
         }
-        return xmlObject;
+        return parsed;
     }
 
     /**
@@ -532,13 +537,23 @@
         extensionRegistry.registerSerializer(Types.class, SchemaConstants.Q_ELEM_XSD_2001,
                 extensionRegistry.getDefaultSerializer());
         wsdlReaderNoImport.setExtensionRegistry(extensionRegistry);
-        JarWSDLLocator wsdlLocator = new JarWSDLLocator(wsdlURI, wsdlReaderNoImport);
+
+        JarWSDLLocator wsdlLocator = new JarWSDLLocator(wsdlURI);
         WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
+
+        Thread thread = Thread.currentThread();
+        ClassLoader oldCl = thread.getContextClassLoader();
+        thread.setContextClassLoader(this.getClass().getClassLoader());
         try {
-            definition = wsdlReader.readWSDL(wsdlLocator);
-        } catch (WSDLException e) {
-            throw new DeploymentException("Failed to read wsdl document", e);
+            try {
+                definition = wsdlReader.readWSDL(wsdlLocator);
+            } catch (WSDLException e) {
+                throw new DeploymentException("Failed to read wsdl document", e);
+            }
+        } finally {
+            thread.setContextClassLoader(oldCl);
         }
+
         return definition;
     }
 
@@ -626,12 +641,10 @@
     class JarWSDLLocator implements WSDLLocator {
 
         private final URI wsdlURI;
-//        private final WSDLReader wsdlReader;
         private URI latestImportURI;
 
-        public JarWSDLLocator(URI wsdlURI, WSDLReader wsdlReader) {
+        public JarWSDLLocator(URI wsdlURI) {
             this.wsdlURI = wsdlURI;
-//            this.wsdlReader = wsdlReader;
         }
 
         public InputSource getBaseInputSource() {
@@ -639,7 +652,6 @@
             try {
                 ZipEntry entry = moduleFile.getEntry(wsdlURI.toString());
                 wsdlInputStream = moduleFile.getInputStream(entry);
-//                Definition definition = wsdlReader.readWSDL(wsdlURI.toString(), new InputSource(wsdlInputStream));
                 DefinitionsDocument definition = DefinitionsDocument.Factory.parse(wsdlInputStream);
                 wsdlMap.put(wsdlURI, definition);
                 wsdlInputStream.close();

Modified: geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java?rev=219798&r1=219797&r2=219798&view=diff
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
(original)
+++ geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
Tue Jul 19 16:00:12 2005
@@ -90,7 +90,7 @@
         return parsed;
     }
 
-    private static XmlOptions createXmlOptions(ArrayList errors) {
+    public static XmlOptions createXmlOptions(ArrayList errors) {
         XmlOptions options = new XmlOptions();
         options.setLoadLineNumbers();
         options.setErrorListener(errors);



Mime
View raw message