You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by aj...@apache.org on 2005/12/01 17:50:44 UTC

svn commit: r350272 - in /webservices/axis2/trunk/java/modules: codegen/src/org/apache/axis2/databinding/schema/ codegen/src/org/apache/axis2/databinding/schema/writer/ codegen/test-resources/xsd/ codegen/test/org/apache/axis2/databinding/schema/compil...

Author: ajith
Date: Thu Dec  1 08:49:36 2005
New Revision: 350272

URL: http://svn.apache.org/viewcvs?rev=350272&view=rev
Log:
1. Updated the schema compiler to handle simple restrictions (it still needs a bit of improvement though)
2. Added a new test case to test the simple restrictions
3. Fixed a small issue that was introduced by Deepal's change into the Axis Engine.

Added:
    webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/Simple_restriction.xsd
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleRestrictionTest.java
Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/JavaBeanWriter.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java?rev=350272&r1=350271&r2=350272&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java Thu Dec  1 08:49:36 2005
@@ -36,6 +36,8 @@
     //The writing to the processedElementList happens when an outer element is processed.
     private HashMap processedElementMap;
     private HashMap processedAnonymousComplexTypesMap;
+    private HashMap simpleTypesMap;
+    private HashMap changedTypeMap;
     private ArrayList processedElementList;
 
 
@@ -66,8 +68,10 @@
 
             this.processedTypemap = new HashMap();
             this.processedElementMap = new HashMap();
+            this.simpleTypesMap = new HashMap();
             this.processedElementList = new ArrayList();
             this.processedAnonymousComplexTypesMap = new HashMap();
+            this.changedTypeMap = new HashMap();
 
             //load the writer
             this.writer = SchemaPropertyLoader.getBeanWriterInstance();
@@ -135,7 +139,7 @@
             processElement((XmlSchemaElement)xmlSchemaElement1Iterator.next(),true);
         }
 
-        //Now re iterate through the elements and write them
+        //Now re-iterate through the elements and write them
         Iterator xmlSchemaElement2Iterator = elements.getValues();
         while (xmlSchemaElement2Iterator.hasNext()) {
             //this is the set of outer elements so we need to generate classes
@@ -163,9 +167,17 @@
                 QName qName = schemaType.getQName();
                 //find the class name
                 String className = findClassName(qName,isArray(xsElt));
-                metainf.registerMapping(xsElt.getQName(),
+                //this means the schema type actually returns a different QName
+                if (changedTypeMap.containsKey(qName)){
+                    metainf.registerMapping(xsElt.getQName(),
+                        (QName)changedTypeMap.get(qName),
+                        className);
+                }else{
+                     metainf.registerMapping(xsElt.getQName(),
                         qName,
                         className);
+                }
+
 
             }else{
                 //we are going to special case the anonymous complex type. Our algorithm for dealing
@@ -237,6 +249,8 @@
         String className;
         if (processedTypemap.containsKey(qName)) {
             className = (String)processedTypemap.get(qName);
+        }else if(simpleTypesMap.containsKey(qName)){
+            className =(String)simpleTypesMap.get(qName);
         }else if(baseSchemaTypeMap.containsKey(qName)){
             className =(String)baseSchemaTypeMap.get(qName);
         }else{
@@ -507,8 +521,27 @@
      * @param simpleType
      */
     private void processSimpleSchemaType(XmlSchemaSimpleType simpleType){
-        //nothing to here yet.
-        //todo perhaps we need to populate the processed type map here
+        // handle the restriction
+        XmlSchemaSimpleTypeContent content = simpleType.getContent();
+        if (content!=null){
+            if (content instanceof XmlSchemaSimpleTypeRestriction){
+                XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content;
+                QName baseTypeName = restriction.getBaseTypeName();
+                //check whether the base type is one of the base schema types
+                if (baseSchemaTypeMap.containsKey(baseTypeName)){
+                    //this is a basic xsd datatype. Populate the map and populate
+                    //the mappings map
+                    String className =(String)baseSchemaTypeMap.get(baseTypeName);
+                    this.simpleTypesMap.put(simpleType.getQName(),className);
+                    //set the old schema type QName and the new schema type QName
+                    this.changedTypeMap.put(simpleType.getQName(),baseTypeName);
+                }else{
+                    //recurse
+                    //processSimpleSchemaType(xsElt, new XmlSchemaSimpleType());
+                }
+            }
+        }
+
 
     }
 

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/JavaBeanWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/JavaBeanWriter.java?rev=350272&r1=350271&r2=350272&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/JavaBeanWriter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/JavaBeanWriter.java Thu Dec  1 08:49:36 2005
@@ -168,6 +168,7 @@
             XSLTUtils.addAttribute(model,"name",xmlName,property);
             XSLTUtils.addAttribute(model,"javaname",javaName,property);
             String javaClassNameForElement = metainf.getClassNameForQName(name);
+            
             String shortTypeName = "";
             if (metainf.getSchemaQNameForQName(name)!=null){
                 shortTypeName = metainf.getSchemaQNameForQName(name).getLocalPart();

Added: webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/Simple_restriction.xsd
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/Simple_restriction.xsd?rev=350272&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/Simple_restriction.xsd (added)
+++ webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/Simple_restriction.xsd Thu Dec  1 08:49:36 2005
@@ -0,0 +1,15 @@
+<xs:schema targetNamespace="http://soapinterop.org/xsd"
+           xmlns:xs="http://www.w3.org/2001/XMLSchema"
+           xmlns:tns="http://soapinterop.org/xsd"
+           elementFormDefault="qualified">
+    <xs:element name="char" nillable="true" type="tns:char"/>
+    <xs:simpleType name="char">
+        <xs:restriction base="xs:int"/>
+    </xs:simpleType>
+    <xs:element name="guid" nillable="true" type="tns:guid"/>
+    <xs:simpleType name="guid">
+        <xs:restriction base="xs:string">
+            <xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}"/>
+        </xs:restriction>
+    </xs:simpleType>
+</xs:schema>
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleRestrictionTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleRestrictionTest.java?rev=350272&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleRestrictionTest.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleRestrictionTest.java Thu Dec  1 08:49:36 2005
@@ -0,0 +1,24 @@
+package org.apache.axis2.databinding.schema.compile;
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class SimpleRestrictionTest extends AbstractSchemaCompilerTester{
+     protected void setUp() throws Exception {
+        this.fileName = "test-resources/xsd/simple_restriction.xsd";
+        super.setUp();
+    }
+
+}

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java?rev=350272&r1=350271&r2=350272&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java Thu Dec  1 08:49:36 2005
@@ -65,7 +65,7 @@
     public void send(MessageContext msgContext) throws AxisFault {
         verifyContextBuilt(msgContext);
 
-        //find and invoke the Phases        
+        //find and invoke the Phases
         OperationContext operationContext = msgContext.getOperationContext();
         ArrayList phases =
                 operationContext.getAxisOperation().getPhasesOutFlow();
@@ -74,6 +74,10 @@
             //who paused the Message will be the first one to run
             //resume fixed, global precalulated phases
             resumeInvocationPhases(phases, msgContext);
+            ArrayList globaleOutphase = msgContext.getConfigurationContext().
+                    getAxisConfiguration().getGlobalOutPhases();
+            //invoking global phase.
+            invokePhases(globaleOutphase, msgContext);
         } else {
             invokePhases(phases, msgContext);
             ArrayList globaleOutphase = msgContext.getConfigurationContext().
@@ -173,8 +177,8 @@
                 invokePhases(phases, msgContext);
             }
         }
-        //it is possible that Operation Context is Null as the error occered before the 
-        //Dispatcher. We do not run Handlers in that case 
+        //it is possible that Operation Context is Null as the error occered before the
+        //Dispatcher. We do not run Handlers in that case
 
         if (!msgContext.isPaused()) {
             //Actually send the SOAP Fault
@@ -194,8 +198,8 @@
 
         OperationContext opContext = msgContext.getOperationContext();
         if (opContext == null) {
-            //If we do not have a OperationContext that means this may be a incoming 
-            //Dual Channel response. So try to dispatch the Service 
+            //If we do not have a OperationContext that means this may be a incoming
+            //Dual Channel response. So try to dispatch the Service
             ConfigurationContext sysCtx = msgContext.getConfigurationContext();
             ArrayList phases =
                     sysCtx