cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r632324 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/databinding/ common/common/src/main/java/org/apache/cxf/common/xmlschema/ rt/core/src/main/java/org/apache/cxf/wsdl11/ tools/corba/src/main/java/org/apache/cxf/tools/corba/...
Date Fri, 29 Feb 2008 14:14:13 GMT
Author: dkulp
Date: Fri Feb 29 06:14:11 2008
New Revision: 632324

URL: http://svn.apache.org/viewvc?rev=632324&view=rev
Log:
Updates to prepare for XmlSchema 1.4 which is being voted on now.   This now works with 1.3.2
and 1.4.

Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/SchemaUtil.java
    incubator/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ObjectReferenceVisitor.java
    incubator/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java
    incubator/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToProcessor.java
    incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
    incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
    incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenOptionTest.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java?rev=632324&r1=632323&r2=632324&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java
(original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java
Fri Feb 29 06:14:11 2008
@@ -82,7 +82,7 @@
         }
         SchemaInfo schema = new SchemaInfo(serviceInfo, ns);
         schema.setSystemId(systemId);
-        XmlSchema xmlSchema = col.read(d, null);
+        XmlSchema xmlSchema = col.read(d, systemId, null);
         schema.setSchema(xmlSchema);
         serviceInfo.addSchema(schema);
         return xmlSchema;

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java?rev=632324&r1=632323&r2=632324&view=diff
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
(original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
Fri Feb 29 06:14:11 2008
@@ -21,13 +21,13 @@
 
 import java.io.Reader;
 import java.io.StringReader;
+import java.lang.reflect.Method;
 
 import javax.xml.namespace.QName;
 import javax.xml.transform.Source;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-
 import org.xml.sax.InputSource;
 
 import org.apache.ws.commons.schema.ValidationEventHandler;
@@ -46,6 +46,17 @@
  * One bug is WSCOMMONS-272.
  */
 public class SchemaCollection {
+    private static final Method GET_ELEMENT_BY_NAME_METHOD;
+    static {
+        Method m = null;
+        try {
+            m = XmlSchema.class.getMethod("getElementByName",
+                                          new Class[] {String.class});
+        } catch (Exception ex) {
+            //ignore
+        }
+        GET_ELEMENT_BY_NAME_METHOD = m;
+    }
     
     private XmlSchemaCollection schemaCollection;
     
@@ -156,6 +167,33 @@
         for (XmlSchema schema : schemaCollection.getXmlSchemas()) {
             if (schema.getTargetNamespace().equals(namespaceURI)) {
                 return schema;
+            }
+        }
+        return null;
+    }
+
+    public XmlSchema getSchemaForElement(QName name) {
+        for (XmlSchema schema : schemaCollection.getXmlSchemas()) {
+            if (name.getNamespaceURI().equals(schema.getTargetNamespace())) {
+
+                //for XmlSchema 1.4, we should use:
+                //schema.getElementByName(name.getLocalPart()) != null
+                //but that doesn't exist in 1.3 so for now, use reflection
+                try {
+                    if (GET_ELEMENT_BY_NAME_METHOD != null) {
+                        if (GET_ELEMENT_BY_NAME_METHOD.invoke(schema,
+                                                              new Object[] {name.getLocalPart()})
!= null) {
+                            return schema;
+                        }
+                    } else if (schema.getElementByName(name) != null) {
+                        return schema;
+                    }
+
+                } catch (java.lang.reflect.InvocationTargetException ex) {
+                    //ignore
+                } catch (IllegalAccessException ex) {
+                    //ignore
+                }
             }
         }
         return null;

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/SchemaUtil.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/SchemaUtil.java?rev=632324&r1=632323&r2=632324&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/SchemaUtil.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/SchemaUtil.java Fri Feb
29 06:14:11 2008
@@ -21,6 +21,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.IdentityHashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -63,10 +64,16 @@
         extractSchema(def, schemaCol, serviceInfo);
         // added
         getSchemaList(def);
+        
+        Map<Definition, Definition> done = new IdentityHashMap<Definition, Definition>();
+        done.put(def, def);
         for (Definition def2 : defList) {
-            extractSchema(def2, schemaCol, serviceInfo);
-            // added
-            getSchemaList(def2);
+            if (!done.containsKey(def2)) {
+                extractSchema(def2, schemaCol, serviceInfo);
+                // added
+                getSchemaList(def2);
+                done.put(def2, def2);
+            }
         }
     }
 

Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ObjectReferenceVisitor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ObjectReferenceVisitor.java?rev=632324&r1=632323&r2=632324&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ObjectReferenceVisitor.java
(original)
+++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ObjectReferenceVisitor.java
Fri Feb 29 06:14:11 2008
@@ -98,7 +98,19 @@
         // type, we still need to create a schema type so that the visitor knows what
         // kind of parameter this is.  For a default endpoint, we'll just provide a
         // reference to a WS addressing EndpointReferenceType.
-        XmlSchema wsaSchema = new XmlSchema(ReferenceConstants.WSADDRESSING_NAMESPACE, schemas);
+        XmlSchema scs[] = schemas.getXmlSchema(ReferenceConstants.WSADDRESSING_NAMESPACE);
+        XmlSchema wsaSchema = null;
+        if (scs != null) {
+            for (XmlSchema sc : scs) {
+                if (ReferenceConstants.WSADDRESSING_NAMESPACE.equals(sc.getTargetNamespace()))
{
+                    wsaSchema = sc;
+                    break;
+                }
+            }
+        }
+        if (wsaSchema == null) {
+            wsaSchema = new XmlSchema(ReferenceConstants.WSADDRESSING_NAMESPACE, schemas);
+        }
         XmlSchemaType objectType = new XmlSchemaType(wsaSchema);
         objectType.setName(ReferenceConstants.WSADDRESSING_LOCAL_NAME);
         setSchemaType(objectType);
@@ -180,7 +192,19 @@
 
         // Create a schema namespace for WS addressing and use it to create an endpoint 
         // reference type.  This will be used as the type for our endpoint reference.
-        XmlSchema wsaSchema = new XmlSchema(ReferenceConstants.WSADDRESSING_NAMESPACE, schemas);
+        XmlSchema scs[] = schemas.getXmlSchema(ReferenceConstants.WSADDRESSING_NAMESPACE);
+        XmlSchema wsaSchema = null;
+        if (scs != null) {
+            for (XmlSchema sc : scs) {
+                if (ReferenceConstants.WSADDRESSING_NAMESPACE.equals(sc.getTargetNamespace()))
{
+                    wsaSchema = sc;
+                    break;
+                }
+            }
+        }
+        if (wsaSchema == null) {
+            wsaSchema = new XmlSchema(ReferenceConstants.WSADDRESSING_NAMESPACE, schemas);
+        }
         XmlSchemaType wsaType = new XmlSchemaType(wsaSchema);
         wsaType.setName(ReferenceConstants.WSADDRESSING_LOCAL_NAME);
         

Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java?rev=632324&r1=632323&r2=632324&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java
(original)
+++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java
Fri Feb 29 06:14:11 2008
@@ -23,6 +23,7 @@
 import java.io.File;
 import java.io.FileReader;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -118,7 +119,7 @@
         return helper;
     }
     
-    private void createXmlSchemaList(List<XmlSchema> list) {                
+    private void createXmlSchemaList(Collection<XmlSchema> list) {                
         List<XmlSchema> schemaList = new ArrayList<XmlSchema>();        
         Iterator s = list.iterator();
             

Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToProcessor.java?rev=632324&r1=632323&r2=632324&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToProcessor.java
(original)
+++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToProcessor.java
Fri Feb 29 06:14:11 2008
@@ -21,6 +21,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -63,7 +64,7 @@
     private ExtensionRegistry extReg;        
     private List<Definition> importedDefinitions = new ArrayList<Definition>();
   
     private XmlSchemaCollection schemaCol = new XmlSchemaCollection();
-    private List<XmlSchema> schematypeList = new ArrayList<XmlSchema>();
+    private Map<String, XmlSchema> schematypeList = new HashMap<String, XmlSchema>();
     private List<Schema> schemaList;  
     private List<String> schemaTargetNamespaces = new ArrayList<String>();
     
@@ -157,8 +158,12 @@
                 }
                 
                 if (schemaElem != null) {
-                    schematype = schemaCol.read(schemaElem);                    
-                    schematypeList.add(schematype);                    
+                    String uri = def.getDocumentBaseURI() + "#types";
+                    String ns = schemaElem.getAttribute("targetNamespace");
+                    if (!schematypeList.containsKey("{" + ns + "}" + uri)) {
+                        schematype = schemaCol.read(schemaElem, uri);                   

+                        schematypeList.put("{" + ns + "}" + uri, schematype);           
        
+                    }
                 }
             }
         }
@@ -226,8 +231,8 @@
         return this.schematype;
     }
 
-    public List<XmlSchema> getXmlSchemaTypes() {
-        return this.schematypeList;
+    public Collection<XmlSchema> getXmlSchemaTypes() {
+        return this.schematypeList.values();
     }
         
     public void setEnvironment(ProcessorEnvironment environement) {

Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java?rev=632324&r1=632323&r2=632324&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
Fri Feb 29 06:14:11 2008
@@ -59,7 +59,7 @@
 
 public final class ProcessorUtil {
     private static final String KEYWORDS_PREFIX = "_";
-    
+
     private ProcessorUtil() {
     }
 
@@ -396,12 +396,9 @@
     public static boolean isSchemaFormQualified(ToolContext context, QName partElement) {
         ServiceInfo serviceInfo = (ServiceInfo)context.get(ServiceInfo.class);
         SchemaCollection schemaCol = serviceInfo.getXmlSchemaCollection();
-
-        for (int i = 0; i < schemaCol.getXmlSchemas().length; i++) {
-            XmlSchema schema = schemaCol.getXmlSchemas().clone()[i];
-            if (schema.getElementByName(partElement) != null) {
-                return schema.getElementFormDefault().getValue().equals(XmlSchemaForm.QUALIFIED);
-            }
+        XmlSchema schema = schemaCol.getSchemaForElement(partElement);
+        if (schema != null) {
+            return schema.getElementFormDefault().getValue().equals(XmlSchemaForm.QUALIFIED);
         }
         return false;
     

Modified: incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?rev=632324&r1=632323&r2=632324&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
Fri Feb 29 06:14:11 2008
@@ -529,6 +529,7 @@
         String results = FileUtils.getStringFromFile(new File(output.getCanonicalPath(),

                                                     "org/apache/sayhi/SayHi.java"));
         assertTrue(results.trim().length() > 0);
+        
         assertTrue(results.indexOf("@WebResult(name  =  \"return\",  " 
                                    + "targetNamespace  =  \"http://apache.org/sayHi\")")
!= -1);
         assertTrue(results.indexOf("@WebResult(name  =  \"return\",  targetNamespace  = 
\"\")") != -1);

Modified: incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenOptionTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenOptionTest.java?rev=632324&r1=632323&r2=632324&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenOptionTest.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenOptionTest.java
Fri Feb 29 06:14:11 2008
@@ -137,12 +137,7 @@
         env.put(ToolConstants.CFG_CLASSDIR, null);
 
         processor.setContext(env);
-        try {
-            processor.execute();
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail("Catalog not working");
-        }
+        processor.execute();
     }
 
     @Test
@@ -153,11 +148,6 @@
         env.put(ToolConstants.CFG_CLASSDIR, null);
 
         processor.setContext(env);
-        try {
-            processor.execute();
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail("Catalog not working");
-        }
+        processor.execute();
     }
 }



Mime
View raw message