axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r395163 - in /webservices/axis2/trunk/java/modules: codegen/src/org/apache/axis2/schema/ codegen/src/org/apache/axis2/schema/writer/ codegen/src/org/apache/axis2/wsdl/codegen/ codegen/src/org/apache/axis2/wsdl/codegen/emitter/ codegen/src/o...
Date Wed, 19 Apr 2006 08:07:44 GMT
Author: ajith
Date: Wed Apr 19 01:07:42 2006
New Revision: 395163

URL: http://svn.apache.org/viewcvs?rev=395163&view=rev
Log:
1. Fixed the duplicate exception issue mentioned by Simon Fell (Issue 587)(Yet to add a test
case )
2. Halfway through implementing configurable package names 
   1. Added a namespace to package map to the configuration (and the necessary code to populate
it)
   2. Fixed the package handler in XMLBeans to pump in the correct package in place of the
namespace
   * Yet to fix ADB for this


Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/CompilerOptions.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/CommandLineOptionConstants.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java
    webservices/axis2/trunk/java/modules/xmlbeans/src/org/apache/axis2/xmlbeans/CodeGenerationUtility.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/CompilerOptions.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/CompilerOptions.java?rev=395163&r1=395162&r2=395163&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/CompilerOptions.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/CompilerOptions.java
Wed Apr 19 01:07:42 2006
@@ -5,6 +5,8 @@
 import java.io.File;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.Map;
+import java.util.HashMap;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -26,6 +28,10 @@
  * Right now the compiler options consist of the following
  * 1. output file location - A folder with necessary rights for the
  * schema compiler to write the files
+ * 2.package name
+ * 3.namespace to package map
+ * 4.boolean flag marking whether to wrap or unwrap
+ * 4.boolean flag marking whether to write classes or not
  */
 public class CompilerOptions {
 
@@ -34,6 +40,19 @@
      */
     private File outputLocation;
     private String packageName = null;
+
+    /**
+     * Keep track of the namespace and packages mapping
+     */
+    private Map ns2PackageMap = new HashMap();
+
+    public Map getNs2PackageMap() {
+        return ns2PackageMap;
+    }
+
+    public void setNs2PackageMap(Map ns2PackageMap) {
+        this.ns2PackageMap = ns2PackageMap;
+    }
 
     /**
      * This flag tells the databinder to either write the output or

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java?rev=395163&r1=395162&r2=395163&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
Wed Apr 19 01:07:42 2006
@@ -236,11 +236,11 @@
      */
     public String makeFullyQualifiedClassName(QName qName) {
 
-        String nameSpaceFromURL = URLProcessor.makePackageName(qName.getNamespaceURI());
+        String packageNameFromURL = URLProcessor.makePackageName(qName.getNamespaceURI());
 
         String packageName = this.packageName == null ?
-                nameSpaceFromURL :
-                this.packageName + nameSpaceFromURL;
+                packageNameFromURL :
+                this.packageName + packageNameFromURL;
 
         String originalName = qName.getLocalPart();
         String className = makeUniqueJavaClassName(this.namesList, originalName);
@@ -473,7 +473,7 @@
                 XSLTUtils.addAttribute(model, "nillable", "yes", property);
             }
 
-            String shortTypeName = "";
+            String shortTypeName;
             if (metainf.getSchemaQNameForQName(name) != null) {
                 //see whether the QName is a basetype
                 if (baseTypeMap.containsKey(metainf.getSchemaQNameForQName(name))){
@@ -668,9 +668,8 @@
         if (typeClassName.endsWith("[]")){
             typeClassName = typeClassName.substring(0,typeClassName.lastIndexOf("["));
         }
-        String s = typeClassName.substring(typeClassName.lastIndexOf(".")+1, typeClassName.length());
 
-        return s;
+        return typeClassName.substring(typeClassName.lastIndexOf(".")+1, typeClassName.length());
 
     }
 }

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java?rev=395163&r1=395162&r2=395163&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java
Wed Apr 19 01:07:42 2006
@@ -35,6 +35,20 @@
     private String repositoryPath;
 
     /**
+     * A map to keep the custom namespace and package name mappings
+     */
+    private Map uri2PackageNameMap;
+
+
+    public Map getUri2PackageNameMap() {
+        return uri2PackageNameMap;
+    }
+
+    public void setUri2PackageNameMap(Map uri2PackageNameMap) {
+        this.uri2PackageNameMap = uri2PackageNameMap;
+    }
+
+    /**
      * Determines whether the parameters are wrappedor unwrapped
      * false by default
      */

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java?rev=395163&r1=395162&r2=395163&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java
Wed Apr 19 01:07:42 2006
@@ -7,6 +7,7 @@
 import java.io.File;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.HashMap;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -89,16 +90,36 @@
 
         CommandLineOption serviceNameOption = loadOption(WSDL2JavaConstants.SERVICE_NAME_OPTION,
WSDL2JavaConstants.SERVICE_NAME_OPTION_LONG,optionMap);
         config.setServiceName(serviceNameOption!=null?serviceNameOption.getOptionValue():null);
-        
+
         CommandLineOption repositoryPathOption = loadOption(WSDL2JavaConstants.REPOSITORY_PATH_OPTION,
WSDL2JavaConstants.REPOSITORY_PATH_OPTION_LONG, optionMap);
         config.setRepositoryPath(repositoryPathOption != null ? repositoryPathOption.getOptionValue():
null);
-        
+
         CommandLineOption generateAllOption = loadOption(WSDL2JavaConstants.GENERATE_ALL_OPTION,
WSDL2JavaConstants.GENERATE_ALL_OPTION_LONG,optionMap);
         if (generateAllOption != null) {
             config.setGenerateAll(true);
         }
 
-        
+        CommandLineOption ns2packageOption = loadOption(
+                WSDL2JavaConstants.NAME_SPACE_TO_PACKAGE_OPTION,
+                WSDL2JavaConstants.NAME_SPACE_TO_PACKAGE_OPTION_LONG,
+                optionMap);
+        if (ns2packageOption!=null){
+            //the syntax for the value of the namespaces and packages is
+            //to be a comma seperated list with uri,packagename,uri,packagename...
+            String value = ns2packageOption.getOptionValue();
+            String valuepairs[]  = value.split(",");
+            if (valuepairs.length >0 && valuepairs.length%2==0){
+                //put them in the hash map
+                HashMap map = new HashMap(valuepairs.length);
+                for (int i = 0; i < valuepairs.length; i=i+2) {
+                    map.put(valuepairs[i],valuepairs[i+1]);
+                }
+                config.setUri2PackageNameMap(map);
+            }else{
+               //todo throw an exception here
+            }
+        }
+
         //loop through the map and find parameters having the extra prefix.
         //put them in the property map
         Iterator keyIterator = optionMap.keySet().iterator();
@@ -119,10 +140,10 @@
         //short option gets precedence
         CommandLineOption option = null;
         if (longOption!=null){
-           option =(CommandLineOption)options.get(longOption);
-           if (option!=null) {
-               return option;
-           }
+            option =(CommandLineOption)options.get(longOption);
+            if (option!=null) {
+                return option;
+            }
         }
         if (shortOption!= null){
             option = (CommandLineOption)options.get(shortOption);

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java?rev=395163&r1=395162&r2=395163&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
Wed Apr 19 01:07:42 2006
@@ -436,6 +436,9 @@
             rootElement.appendChild(doc.importNode((Element) stubMethods, true));
         }
 
+        //add another element to have the unique list of faults
+        rootElement.appendChild(getUniqueListofFaults(doc));
+
         /////////////////////////////////////////////////////
         //System.out.println(DOM2Writer.nodeToString(rootElement));
         /////////////////////////////////////////////////////
@@ -445,6 +448,55 @@
         return doc;
     }
 
+    private Element getUniqueListofFaults(Document doc) {
+        Element  rootElement = doc.createElement("fault-list");
+        Element faultElement;
+        QName key;
+        Iterator iterator = fullyQualifiedFaultClassNameMap.keySet().iterator();
+        while (iterator.hasNext()) {
+            faultElement = doc.createElement("fault");
+            key = (QName) iterator.next();
+
+            //as for the name of a fault, we generate an exception
+            addAttribute(doc, "name",
+                    (String)fullyQualifiedFaultClassNameMap.get(key),
+                    faultElement);
+            addAttribute(doc, "intantiatiableName",
+                    (String)InstantiatableFaultClassNameMap.get(key),
+                    faultElement);
+            addAttribute(doc, "shortName",
+                    (String)faultClassNameMap.get(key),
+                    faultElement);
+
+
+            //the type represents the type that will be wrapped by this
+            //name
+            String typeMapping =
+                    this.mapper.getTypeMappingName(key);
+            addAttribute(doc, "type", (typeMapping == null)
+                    ? ""
+                    : typeMapping, faultElement);
+            String attribValue = (String) instantiatableMessageClassNames.
+                    get(key);
+
+            addAttribute(doc, "instantiatableType",
+                    attribValue==null?"":attribValue,
+                    faultElement);
+
+            // add an extra attribute to say whether the type mapping is
+            // the default
+            if (TypeMapper.DEFAULT_CLASS_NAME.equals(typeMapping)) {
+                addAttribute(doc, "default", "yes", faultElement);
+            }
+            addAttribute(doc, "value", getParamInitializer(typeMapping),
+                    faultElement);
+
+
+            rootElement.appendChild(faultElement);
+        }
+        return rootElement;
+    }
+
     /**
      * Adds the endpoint to the document.
      *
@@ -749,6 +801,10 @@
         //put the result in the property map
         infoHolder.put(mep, isOpsFound ? Boolean.TRUE : Boolean.FALSE);
         rootElement.appendChild(createDOMElementforDatabinders(doc));
+
+        //attach a list of faults
+        rootElement.appendChild(getUniqueListofFaults(doc));
+        
         doc.appendChild(rootElement);
 
         //////////////////////////////////
@@ -995,10 +1051,14 @@
 
         fillSyncAttributes(doc, rootElement);
         loadOperations(doc, rootElement, null);
+
+        //attach a list of faults
+        rootElement.appendChild(getUniqueListofFaults(doc));
+
         doc.appendChild(rootElement);
 
         /////////////////////////////////////////////////////
-        System.out.println(DOM2Writer.nodeToString(rootElement));
+        //System.out.println(DOM2Writer.nodeToString(rootElement));
         /////////////////////////////////////////////////////
 
         return doc;
@@ -1043,7 +1103,9 @@
                 addAttribute(doc, "mep", axisOperation.getMessageExchangePattern(), methodElement);
 
                 addSOAPAction(doc, methodElement, axisOperation);
+                //add header ops for input
                 addHeaderOperations(soapHeaderInputParameterList, axisOperation, true);
+                //add header ops for output
                 addHeaderOperations(soapHeaderOutputParameterList, axisOperation, false);
 
                 PolicyInclude policyInclude = axisOperation.getPolicyInclude();

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java?rev=395163&r1=395162&r2=395163&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
Wed Apr 19 01:07:42 2006
@@ -59,10 +59,7 @@
             return;
         }
 
-        //check the comptibilty
-        //checkCompatibility();
         try {
-
             // try dummy load of framework class first to check missing jars
             try {
                 getClass().getClassLoader().loadClass(XMLBEANS_CONFIG_CLASS);

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl?rev=395163&r1=395162&r2=395163&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
Wed Apr 19 01:07:42 2006
@@ -653,8 +653,7 @@
 
 
      <!-- write the classes for the exceptions if there are any present -->
-   <xsl:for-each select="method">
-       <xsl:for-each select="fault/param">
+   <xsl:for-each select="fault-list/fault">
          public static class <xsl:value-of select="@shortName"/> extends java.rmi.RemoteException{
 
             private <xsl:value-of select="@type"/> faultMessage;
@@ -667,7 +666,6 @@
                return faultMessage;
             }
          }
-       </xsl:for-each>
    </xsl:for-each>
 
     //<xsl:apply-templates/>

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl?rev=395163&r1=395162&r2=395163&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
Wed Apr 19 01:07:42 2006
@@ -111,25 +111,17 @@
         </xsl:for-each>
 
         newMsgContext.setEnvelope(envelope);
-       }
-        <xsl:for-each select="method">
-        <xsl:choose>
-           <xsl:when test="fault/param">
-               <xsl:for-each select="fault/param">
-                    <xsl:if test="position()=1">}</xsl:if>catch (<xsl:value-of
select="@name"/> e) {
-                        org.apache.axis2.AxisFault f =
-                            new org.apache.axis2.AxisFault("<xsl:value-of select="@shortName"/>");
-                        f.setDetail(toOM(e.getFaultMessage(),false));
-                        throw f;
-                    }
-               </xsl:for-each>
-            </xsl:when>
-            <xsl:otherwise>
-                    <!-- put a single bracket for the catch-->
-                    }
-            </xsl:otherwise>
-        </xsl:choose>
+        }
+        <xsl:for-each select="fault-list/fault">
+        <xsl:if test="position()=1">}</xsl:if>catch (<xsl:value-of select="@name"/>
e) {
+                org.apache.axis2.AxisFault f =
+                    new org.apache.axis2.AxisFault("<xsl:value-of select="@shortName"/>");
+                f.setDetail(toOM(e.getFaultMessage(),false));
+                throw f;
+            }
         </xsl:for-each>
+        <!-- put the extra bracket-->
+        <xsl:if test="count(fault-list/fault)=0">}</xsl:if>
             catch (Exception e) {
               throw org.apache.axis2.AxisFault.makeFault(e);
             }

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl?rev=395163&r1=395162&r2=395163&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl
Wed Apr 19 01:07:42 2006
@@ -40,8 +40,7 @@
 
 
     <!-- write the classes for the exceptions if there are any present -->
-   <xsl:for-each select="method">
-       <xsl:for-each select="fault/param">
+   <xsl:for-each select="fault-list/fault">
          public static class <xsl:value-of select="@shortName"/> extends java.rmi.RemoteException{
 
             private <xsl:value-of select="@type"/> faultMessage;
@@ -54,7 +53,6 @@
                return faultMessage;
             }
          }
-       </xsl:for-each>
    </xsl:for-each>
     }
     </xsl:template>

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/CommandLineOptionConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/CommandLineOptionConstants.java?rev=395163&r1=395162&r2=395163&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/CommandLineOptionConstants.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/CommandLineOptionConstants.java
Wed Apr 19 01:07:42 2006
@@ -36,7 +36,8 @@
         String PORT_NAME_OPTION = "pn";
         String SERVICE_NAME_OPTION = "sn";
         String REPOSITORY_PATH_OPTION = "r";
-        
+        String NAME_SPACE_TO_PACKAGE_OPTION = "ns2p";
+
         //long option constants
         String OUTPUT_LOCATION_OPTION_LONG = "output";
         String SERVER_SIDE_CODE_OPTION_LONG = "server-side";
@@ -54,6 +55,8 @@
         String INVALID_OPTION = "INVALID_OPTION";
         String EXTRA_OPTIONTYPE_PREFIX = "E";
         String REPOSITORY_PATH_OPTION_LONG = "repository-path";
+        String NAME_SPACE_TO_PACKAGE_OPTION_LONG = "namespace2package";
+
     }
 
     interface Java2WSDLConstants{

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java?rev=395163&r1=395162&r2=395163&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java
Wed Apr 19 01:07:42 2006
@@ -67,6 +67,29 @@
     }
 
     static {
+        loadAllProperties();
+    }
+
+    public static void reload(){
+        reset();
+        loadAllProperties();
+    }
+
+    private static void reset(){
+        dbSupporterTemplateName = null;
+        testObjectTemplateName = null;
+        extensionClassNames = null;
+        thirdPartySchemaNames = null;
+        languageTypes = null;
+        databindingFrameworkNames = null;
+        languageEmitterMap = null;
+        languageSpecificPropertiesMap = null;
+        databindingFrameworkNameToExtensionMap = null;
+        defaultLanguage = null;
+        defaultDBFrameworkName = null;
+
+    }
+    private static void loadAllProperties() {
         try {
             //look for the system property "org.apache.axis2.codegen.config" to for a property
             //entry refering to the config properties
@@ -193,7 +216,6 @@
         } catch (Exception e) {
             throw new RuntimeException(CodegenMessages.getMessage("propfileload.generalException"),
e);
         }
-
     }
 
     /**

Modified: webservices/axis2/trunk/java/modules/xmlbeans/src/org/apache/axis2/xmlbeans/CodeGenerationUtility.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xmlbeans/src/org/apache/axis2/xmlbeans/CodeGenerationUtility.java?rev=395163&r1=395162&r2=395163&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xmlbeans/src/org/apache/axis2/xmlbeans/CodeGenerationUtility.java
(original)
+++ webservices/axis2/trunk/java/modules/xmlbeans/src/org/apache/axis2/xmlbeans/CodeGenerationUtility.java
Wed Apr 19 01:07:42 2006
@@ -29,6 +29,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Vector;
+import java.util.HashMap;
 
 import org.apache.axis2.namespace.Constants;
 import org.apache.axis2.util.URLProcessor;
@@ -120,12 +121,15 @@
 
             //compile the type system
             XmlObject[] objeArray = convertToXMLObjectArray(xmlObjectsVector);
-            BindingConfig config = new Axis2BindingConfig();
 
-            //set the STS name to null. it makes the generated class include a unique (but
random) STS name
-            sts = XmlBeans.compileXmlBeans(null, null,
+            sts = XmlBeans.compileXmlBeans(
+                    //set the STS name to null. it makes the generated class
+                    // include a unique (but random) STS name
+                    null,
+                    null,
                     objeArray,
-                    config, XmlBeans.getContextTypeLoader(),
+                    new Axis2BindingConfig(cgconfig.getUri2PackageNameMap()),
+                    XmlBeans.getContextTypeLoader(),
                     new Axis2Filer(cgconfig.getOutputLocation()),
                     null);
 
@@ -165,7 +169,7 @@
         List allSeenTypes = new ArrayList();
         List base64ElementQNamesList = new ArrayList();
         SchemaType outerType;
-//add the document types and global types
+        //add the document types and global types
         allSeenTypes.addAll(Arrays.asList(sts.documentTypes()));
         allSeenTypes.addAll(Arrays.asList(sts.globalTypes()));
         for (int i = 0; i < allSeenTypes.size(); i++) {
@@ -174,8 +178,8 @@
             if (sType.getContentType() == SchemaType.SIMPLE_CONTENT && sType.getPrimitiveType()
!= null) {
                 if (Constants.BASE_64_CONTENT_QNAME.equals(sType.getPrimitiveType().getName()))
{
                     outerType = sType.getOuterType();
-//check the outer type further to see whether it has the contenttype attribute from
-//XMime namespace
+                    //check the outer type further to see whether it has the contenttype
attribute from
+                    //XMime namespace
                     SchemaProperty[] properties = sType.getProperties();
                     for (int j = 0; j < properties.length; j++) {
                         if (Constants.XMIME_CONTENT_TYPE_QNAME.equals(properties[j].getName()))
{
@@ -214,14 +218,12 @@
 
         for (int i = 0; i < elementProperties.length; i++) {
             SchemaType schemaType = elementProperties[i].getType();
-
             if (schemaType.isPrimitiveType()) {
                 SchemaType primitiveType = schemaType.getPrimitiveType();
-
                 if (Constants.BASE_64_CONTENT_QNAME.equals(primitiveType.getName())) {
+                    //todo fix the recursive problem here
                     base64Types.add(elementProperties[i].getName());
                 }
-
             } else {
                 findPlainBase64Types(schemaType, base64Types);
             }
@@ -287,27 +289,25 @@
      * how the namespaces are suffixed/prefixed
      */
     private static class Axis2BindingConfig extends BindingConfig {
+
+        private Map uri2packageMappings = null;
+
+        public Axis2BindingConfig(Map uri2packageMappings) {
+            this.uri2packageMappings = uri2packageMappings;
+            if (this.uri2packageMappings==null){
+                //make an empty one to avoid nasty surprises
+                this.uri2packageMappings = new HashMap();
+            }
+        }
+
         public String lookupPackageForNamespace(String uri) {
-            return URLProcessor.makePackageName(uri);
+            if (uri2packageMappings.containsKey(uri)){
+                return (String)uri2packageMappings.get(uri);
+            }else{
+                 return URLProcessor.makePackageName(uri);
+            }
+
         }
     }
 
-//    /**
-//     *
-//     */
-//    public static class Axis2SchemaCompilerExtension implements SchemaCompilerExtension{
-//        private SchemaTypeSystem sts;
-//
-//        public SchemaTypeSystem getSts() {
-//            return sts;
-//        }
-//
-//        public void schemaCompilerExtension(SchemaTypeSystem schemaTypeSystem, Map parms)
{
-//            this.sts = schemaTypeSystem;
-//        }
-//
-//        public String getExtensionName() {
-//            return "Axis2.xmlbeans.extension";
-//        }
-//    }
 }



Mime
View raw message