axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r369183 - in /webservices/axis2/trunk/java: etc/ modules/codegen/ modules/codegen/src/org/apache/axis2/wsdl/codegen/ modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/ modules/codegen/src/org/apache/axis2/wsdl/i18n/ modules/codege...
Date Sun, 15 Jan 2006 06:41:23 GMT
Author: dims
Date: Sat Jan 14 22:41:15 2006
New Revision: 369183

URL: http://svn.apache.org/viewcvs?rev=369183&view=rev
Log:
EXPERIMENTAL CODE: Checking in something i had in my sandbox for Jochen to review and help
us. Generated code compiles ok. Needs stax-utils to run. Tons of TODO items in source code.
generated build.xml needs to be fixed as well.


Added:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JaxMeExtension.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/jaxmeAntBuildTemplate.xsl
Modified:
    webservices/axis2/trunk/java/etc/project.properties
    webservices/axis2/trunk/java/modules/codegen/project.xml
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/wsdl/TestConstants.java

Modified: webservices/axis2/trunk/java/etc/project.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/etc/project.properties?rev=369183&r1=369182&r2=369183&view=diff
==============================================================================
--- webservices/axis2/trunk/java/etc/project.properties (original)
+++ webservices/axis2/trunk/java/etc/project.properties Sat Jan 14 22:41:15 2006
@@ -86,6 +86,7 @@
 servletapi.version=2.3
 groovy.all.version=1.0-jsr-01
 jaxen.version=1.1-beta-7
+jaxme.version=0.5.1
 junit.version=3.8.1
 log4j.version=1.2.12
 maven.itest.plugin.version=1.0

Modified: webservices/axis2/trunk/java/modules/codegen/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/project.xml?rev=369183&r1=369182&r2=369183&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/project.xml (original)
+++ webservices/axis2/trunk/java/modules/codegen/project.xml Sat Jan 14 22:41:15 2006
@@ -160,10 +160,34 @@
                 <module>true</module>
             </properties>
         </dependency>
-    <dependency>
+        <dependency>
             <groupId>ws-commons</groupId>
             <artifactId>ws-policy</artifactId>
             <version>${ws_policy.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>jaxme</groupId>
+            <artifactId>jaxme2</artifactId>
+            <version>${jaxme.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>jaxme</groupId>
+            <artifactId>jaxmejs</artifactId>
+            <version>${jaxme.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>jaxme</groupId>
+            <artifactId>jaxmexs</artifactId>
+            <version>${jaxme.version}</version>
             <properties>
                 <module>true</module>
             </properties>

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties?rev=369183&r1=369182&r2=369183&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
Sat Jan 14 22:41:15 2006
@@ -5,7 +5,7 @@
 # these are loaded in their lexical order
 # Note the last extension - It includes a check to figure out whether proper databinding
has taken place
 # This extension should appear AFTER all the databinding extensions inorder to function properly
-codegen.extension=org.apache.axis2.wsdl.codegen.extension.WSDLValidatorExtension,org.apache.axis2.wsdl.codegen.extension.PackageFinder,org.apache.axis2.wsdl.codegen.extension.XMLBeansExtension,org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension,org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension
+codegen.extension=org.apache.axis2.wsdl.codegen.extension.WSDLValidatorExtension,org.apache.axis2.wsdl.codegen.extension.PackageFinder,org.apache.axis2.wsdl.codegen.extension.JaxMeExtension,org.apache.axis2.wsdl.codegen.extension.XMLBeansExtension,org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension,org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension
 #codegen.extension=org.apache.axis2.wsdl.codegen.extension.AxisBindingBuilder,org.apache.axis2.wsdl.codegen.extension.WSDLValidatorExtension,org.apache.axis2.wsdl.codegen.extension.PackageFinder,org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension
 # The third party schemas to be loaded. e.g. The Xmime extension
 # Note - these will be loaded from the org.apache.axis2.wsdl.codegen.schema package.
@@ -17,11 +17,11 @@
 # Codegen data binding frameworks and their related information
 # The names of the codegeneration frameworks in lexical order
 # these are the names that should be passed onto the tool as arguments as well
-codegen.databinding.frameworks=adb,xmlbeans,none
+codegen.databinding.frameworks=adb,xmlbeans,jaxme,none
 # the related extensions for the specified data binding frameworks above
 # Note -  these are in the lexical order of the framework names. There is an implicit assumption
 # that a given databinding framework will be processed only by one extension
-codegen.databinding.extensions=org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension,org.apache.axis2.wsdl.codegen.extension.XMLBeansExtension,org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension
+codegen.databinding.extensions=org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension,org.apache.axis2.wsdl.codegen.extension.XMLBeansExtension,org.apache.axis2.wsdl.codegen.extension.JaxMeExtension,org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension
 # the default data binding framework name
 codegen.databinding.frameworks.default=adb
 # the databinding template - this should include all the necessary xslt templates for
@@ -62,6 +62,7 @@
 java.service.template=org.apache.axis2.wsdl.codegen.writer.ServiceXMLWriter,/org/apache/axis2/wsdl/template/general/ServiceXMLTemplate.xsl
 java.message.receiver.template=org.apache.axis2.wsdl.codegen.writer.MessageReceiverWriter,/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
 #
+java.antbuild.jaxme.template=org.apache.axis2.wsdl.codegen.writer.AntBuildWriter,/org/apache/axis2/wsdl/template/general/jaxmeAntBuildTemplate.xsl
 java.antbuild.xmlbeans.template=org.apache.axis2.wsdl.codegen.writer.AntBuildWriter,/org/apache/axis2/wsdl/template/general/xmlbeansAntBuildTemplate.xsl
 java.antbuild.adb.template=org.apache.axis2.wsdl.codegen.writer.AntBuildWriter,/org/apache/axis2/wsdl/template/general/adbAntBuildTemplate.xsl
 java.antbuild.none.template=org.apache.axis2.wsdl.codegen.writer.AntBuildWriter,/org/apache/axis2/wsdl/template/general/defaultAntBuildTemplate.xsl

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JaxMeExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JaxMeExtension.java?rev=369183&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JaxMeExtension.java
(added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JaxMeExtension.java
Sat Jan 14 22:41:15 2006
@@ -0,0 +1,367 @@
+/*
+ * 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.
+ */
+
+package org.apache.axis2.wsdl.codegen.extension;
+
+import com.ibm.wsdl.util.xml.DOM2Writer;
+import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
+import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
+import org.apache.axis2.wsdl.i18n.CodegenMessages;
+import org.apache.axis2.wsdl.util.ConfigPropertyFileLoader;
+import org.apache.ws.jaxme.generator.impl.GeneratorImpl;
+import org.apache.ws.jaxme.generator.sg.GroupSG;
+import org.apache.ws.jaxme.generator.sg.ObjectSG;
+import org.apache.ws.jaxme.generator.sg.SchemaSG;
+import org.apache.ws.jaxme.generator.sg.TypeSG;
+import org.apache.ws.jaxme.generator.sg.impl.JAXBSchemaReader;
+import org.apache.ws.jaxme.js.JavaQName;
+import org.apache.ws.jaxme.xs.xml.XsQName;
+import org.apache.wsdl.WSDLBinding;
+import org.apache.wsdl.WSDLBindingMessageReference;
+import org.apache.wsdl.WSDLBindingOperation;
+import org.apache.wsdl.WSDLConstants;
+import org.apache.wsdl.WSDLExtensibilityElement;
+import org.apache.wsdl.WSDLTypes;
+import org.apache.wsdl.extensions.ExtensionConstants;
+import org.apache.wsdl.extensions.SOAPBody;
+import org.apache.wsdl.extensions.Schema;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+import java.util.Vector;
+
+public class JaxMeExtension extends AbstractDBProcessingExtension {
+    public static final String SCHEMA_FOLDER = "schemas";
+
+    public static String MAPPINGS = "mappings";
+    public static String MAPPING = "mapping";
+    public static String MESSAGE = "message";
+    public static String JAVA_NAME = "javaclass";
+
+    public static final String MAPPING_FOLDER = "Mapping";
+    public static final String MAPPER_FILE_NAME = "mapper";
+    public static final String SCHEMA_PATH = "/org/apache/axis2/wsdl/codegen/schema/";
+
+    boolean debug = false;
+    
+    public void engage() {
+
+        //test the databinding type. If not just fall through
+        if (testFallThrough(configuration.getDatabindingType())) {
+            return;
+        }
+
+        //check the comptibilty
+        checkCompatibility();
+
+        try {
+            //get the types from the types section
+            WSDLTypes typesList = configuration.getWom().getTypes();
+
+            //check for the imported types. Any imported types are supposed to be here also
+            if (typesList == null) {
+                //there are no types to be code generated
+                //However if the type mapper is left empty it will be a problem for the other
+                //processes. Hence the default type mapper is set to the configuration
+                this.configuration.setTypeMapper(new DefaultTypeMapper());
+                return;
+            }
+
+            List typesArray = typesList.getExtensibilityElements();
+            //this a list that keeps the already processed schemas
+            List processedSchemas = new ArrayList();
+
+            WSDLExtensibilityElement extensiblityElt;
+
+            Vector xmlObjectsVector = new Vector();
+            //create the type mapper
+            JavaTypeMapper mapper = new JavaTypeMapper();
+
+            for (int i = 0; i < typesArray.size(); i++) {
+                extensiblityElt = (WSDLExtensibilityElement) typesArray.get(i);
+                Schema schema;
+
+                if (ExtensionConstants.SCHEMA.equals(extensiblityElt.getType())) {
+                    schema = (Schema) extensiblityElt;
+
+//                    TODO: FIXME                    
+//                    Map namespaceMap = configuration.getWom().getNamespaces();
+//                    if (namespaceMap != null && !namespaceMap.isEmpty()) {
+//                        Iterator nameSpaces = namespaceMap.keySet().iterator();
+//                        String nsPrefix;
+//                        String nsURI;
+//                        while (nameSpaces.hasNext()) {
+//                            nsPrefix = (String) nameSpaces.next();
+//                            nsURI = namespaceMap.get(nsPrefix).toString();
+//                            parser.addImport(nsURI, null);
+//                        }
+//                    }
+
+                    Stack importedSchemaStack = schema.getImportedSchemaStack();
+                    File schemaFolder = null;
+                    if(debug) {
+                        schemaFolder = new File(configuration.getOutputLocation(), SCHEMA_FOLDER);
+                        schemaFolder.mkdir();
+                    }
+                    //compile these schemas
+                    while (!importedSchemaStack.isEmpty()) {
+                        Element element = (Element) importedSchemaStack.pop();
+                        String tagetNamespace = element.getAttribute("targetNamespace");
+                        if (!processedSchemas.contains(tagetNamespace)) {
+
+                            String s = DOM2Writer.nodeToString(element);
+                            xmlObjectsVector.add(new InputSource(new StringReader(s)));
+                            processedSchemas.add(tagetNamespace);
+                        }
+                    }
+                }
+            }
+
+
+//            TODO: FIXME            
+//            Element[] additionalSchemas = loadAdditionalSchemas();
+//            // Need to add the third party schemas
+//            for (int i = 0; i < additionalSchemas.length; i++) {
+//                String s = DOM2Writer.nodeToString(additionalSchemas[i]);
+//                xmlObjectsVector.add(new InputSource(new StringReader(s)));
+//            }
+
+            File outputDir = new File(configuration.getOutputLocation(), "src");
+
+            JAXBSchemaReader reader = new JAXBSchemaReader();
+            reader.setSupportingExtensions(true);
+
+            GeneratorImpl generator = new GeneratorImpl();
+            generator.setTargetDirectory(outputDir);
+            generator.setForcingOverwrite(false);
+            generator.setSchemaReader(reader);
+
+            for (int i = 0; i < xmlObjectsVector.size(); i++) {
+                SchemaSG sg = generator.generate((InputSource) xmlObjectsVector.elementAt(i));
+                ObjectSG[] elements = sg.getElements();
+                for(int j=0;j<elements.length;j++){
+                    XsQName qName = elements[j].getName();
+                    JavaQName name = elements[j].getClassContext().getXMLInterfaceName();
+                    mapper.addTypeMappingName(new QName(qName.getNamespaceURI(), qName.getLocalName()),

+                                            name.getPackageName() + '.' + name.getClassName());
+                }
+                TypeSG[] types = sg.getTypes();
+                for(int j=0;j<types.length;j++){
+                    XsQName qName = types[j].getName();
+                    JavaQName name = types[j].getRuntimeType();
+                    mapper.addTypeMappingName(new QName(qName.getNamespaceURI(), qName.getLocalName()),

+                                            name.getPackageName() + '.' + name.getClassName());
+                }
+                GroupSG[] groups = sg.getGroups();
+                for(int j=0;j<groups.length;j++){
+                    XsQName qName = groups[j].getName();
+                    JavaQName name = groups[j].getClassContext().getXMLInterfaceName();
+                    mapper.addTypeMappingName(new QName(qName.getNamespaceURI(), qName.getLocalName()),

+                                            name.getPackageName() + '.' + name.getClassName());
+                }
+            }
+
+//            TODO: FIXME                    
+//            // prune the generated schema type system and add the list of base64 types
+//            FindBase64Types(sts);
+//
+//            //get the schematypes and add the document types to the type mapper
+//            SchemaType[] schemaType = sts.documentTypes();
+//            SchemaType type;
+//            for (int j = 0; j < schemaType.length; j++) {
+//                type = schemaType[j];
+//                mapper.addTypeMappingName(type.getDocumentElementName(),
+//                        type.getFullJavaName());
+//            }
+
+            //set the type mapper to the config
+            configuration.setTypeMapper(mapper);
+
+            if(debug) {
+                // write the mapper to a file for later retriival
+                writeMappingsToFile(mapper.getAllMappedNames());
+            }
+
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+
+    }
+
+    private void writeMappingsToFile(Map typeMappings) throws IOException {
+
+        File typeMappingFolder = new File(configuration.getOutputLocation(), MAPPING_FOLDER);
+        if (!typeMappingFolder.exists()) {
+            typeMappingFolder.mkdir();
+        }
+
+        File typeMappingFile = File.createTempFile(MAPPER_FILE_NAME, ".xml", typeMappingFolder);
+        BufferedWriter out = new BufferedWriter(new FileWriter(typeMappingFile));
+        out.write("<" + MAPPINGS + ">");
+
+        Iterator iterator = typeMappings.keySet().iterator();
+        while (iterator.hasNext()) {
+            QName qName = (QName) iterator.next();
+            String fullJavaName = (String) typeMappings.get(qName);
+            out.write("<" + MAPPING + ">");
+            out.write("<" + MESSAGE + ">" + qName.getLocalPart() + "</" + MESSAGE
+ ">");
+            out.write("<" + JAVA_NAME + ">" + fullJavaName + "</" + JAVA_NAME +
">");
+            out.write("</" + MAPPING + ">");
+        }
+        out.write("</" + MAPPINGS + ">");
+        out.close();
+
+    }
+
+//   TODO: FIXME    
+//    /**
+//     * Populate the base64 types
+//     * The algo is to look for simpletypes that have base64 content, and then step out
of that
+//     * onestep and get the element. For now there's an extended check to see whether the
simple type
+//     * is related to the Xmime:contentType!
+//     *
+//     * @param sts
+//     */
+//    private void FindBase64Types(SchemaTypeSystem sts) {
+//        List allSeenTypes = new ArrayList();
+//        List base64ElementQNamesList = new ArrayList();
+//        SchemaType outerType;
+//        //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++) {
+//            SchemaType sType = (SchemaType) allSeenTypes.get(i);
+//
+//            if (sType.getContentType() == SchemaType.SIMPLE_CONTENT && sType.getPrimitiveType()
!= null) {
+//                if (XSLTConstants.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
+//                    SchemaProperty[] properties = sType.getProperties();
+//                    for (int j = 0; j < properties.length; j++) {
+//                        if (XSLTConstants.XMIME_CONTENT_TYPE_QNAME.equals(properties[j].getName()))
{
+//                            base64ElementQNamesList.add(outerType.getDocumentElementName());
+//                            break;
+//                        }
+//                    }
+//                }
+//            }
+//            //add any of the child types if there are any
+//            allSeenTypes.addAll(Arrays.asList(sType.getAnonymousTypes()));
+//        }
+//
+//        configuration.putProperty(XSLTConstants.BASE_64_PROPERTY_KEY, base64ElementQNamesList);
+//    }
+
+    /**
+     * Loading the external schemas.
+     *
+     * @return element array consisting of the the DOM element objects that represent schemas
+     */
+    private Element[] loadAdditionalSchemas() {
+        //load additional schemas
+        String[] schemaNames = ConfigPropertyFileLoader.getThirdPartySchemaNames();
+        Element[] schemaElements;
+
+        try {
+            ArrayList additionalSchemaElements = new ArrayList();
+            DocumentBuilder documentBuilder = getNamespaceAwareDocumentBuilder();
+            for (int i = 0; i < schemaNames.length; i++) {
+                //the location for the third party schema;s is hardcoded
+                if (!"".equals(schemaNames[i].trim())) {
+                    InputStream schemaStream = this.getClass().getResourceAsStream(SCHEMA_PATH
+ schemaNames[i]);
+                    Document doc = documentBuilder.parse(schemaStream);
+                    additionalSchemaElements.add(doc.getDocumentElement());
+                }
+            }
+
+            //Create the Schema element array
+            schemaElements = new Element[additionalSchemaElements.size()];
+            for (int i = 0; i < additionalSchemaElements.size(); i++) {
+                schemaElements[i] = (Element) additionalSchemaElements.get(i);
+
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(CodegenMessages.getMessage("extension.additionalSchemaFailure"),
e);
+        }
+
+        return schemaElements;
+    }
+
+    private DocumentBuilder getNamespaceAwareDocumentBuilder() throws ParserConfigurationException
{
+        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+        documentBuilderFactory.setNamespaceAware(true);
+        return documentBuilderFactory.newDocumentBuilder();
+    }
+
+
+    /**
+     * Checking the compatibilty has to do with generating RPC/encoded stubs.
+     * If the XMLBeans bindings are used encoded binding cannot be done.
+     */
+    private void checkCompatibility() {
+        Map bindingMap = this.configuration.getWom().getBindings();
+        Collection col = bindingMap.values();
+
+        for (Iterator iterator = col.iterator(); iterator.hasNext();) {
+            WSDLBinding b = (WSDLBinding) iterator.next();
+            HashMap bindingOps = b.getBindingOperations();
+            Collection bindingOpsCollection = bindingOps.values();
+            for (Iterator iterator1 = bindingOpsCollection.iterator(); iterator1.hasNext();)
{
+                foo((WSDLBindingOperation) iterator1.next());
+            }
+
+        }
+    }
+
+    protected void foo(WSDLBindingOperation bindingOp) {
+        WSDLBindingMessageReference input = bindingOp.getInput();
+        if (input != null) {
+            Iterator extIterator = input.getExtensibilityElements()
+                    .iterator();
+            while (extIterator.hasNext()) {
+                WSDLExtensibilityElement element = (WSDLExtensibilityElement) extIterator.next();
+                if (ExtensionConstants.SOAP_11_BODY.equals(element.getType()) ||
+                        ExtensionConstants.SOAP_12_BODY.equals(element.getType())) {
+                    if (WSDLConstants.WSDL_USE_ENCODED.equals(
+                            ((SOAPBody) element).getUse())) {
+                        throw new RuntimeException(
+                                CodegenMessages.getMessage("extension.encodedNotSupported"));
+                    }
+                }
+            }
+        }
+    }
+}
+

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties?rev=369183&r1=369182&r2=369183&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties
Sat Jan 14 22:41:15 2006
@@ -23,7 +23,7 @@
 wsdl2code.arg7=-t : Generate TestCase to test the generated code
 wsdl2code.arg8=-ss : Generate server side code (i.e. skeletons). Default is off
 wsdl2code.arg9=-sd : Generate service descriptor (i.e. axis2.xml). Default is off. Valid
with -ss
-wsdl2code.arg10=-d <databinding> : valid databinding(s) are adb and xmlbeans. Default
is adb
+wsdl2code.arg10=-d <databinding> : valid databinding(s) are adb, xmlbeans and jaxme.
Default is adb
 
 ################## prop file loader #################################
 propfileload.frameworkMismatch=Number of frameworks and extension names do not match!

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/jaxmeAntBuildTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/jaxmeAntBuildTemplate.xsl?rev=369183&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/jaxmeAntBuildTemplate.xsl
(added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/jaxmeAntBuildTemplate.xsl
Sat Jan 14 22:41:15 2006
@@ -0,0 +1,243 @@
+<xsl:stylesheet version="1.0" xmlns:xalan="http://xml.apache.org/xslt"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+    <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" xalan:indent-amount="4"/>
+    <xsl:template match="/ant">
+        <xsl:variable name="package"><xsl:value-of select="@package"/></xsl:variable>
+
+        <project basedir="." default="jar.all">
+            <xsl:comment>Auto generated ant build file</xsl:comment>
+            <property environment="env"/>
+            <property name="axis2.home">
+                <xsl:attribute name="value">${env.AXIS2_HOME}</xsl:attribute>
+            </property>
+            <property name="maven.class.path">
+                <xsl:attribute name="value"></xsl:attribute>
+            </property>
+            <property name="name">
+                <xsl:attribute name="value"><xsl:value-of select="@servicename"/></xsl:attribute>
+            </property>
+            <property name="src">
+                <xsl:attribute name="value">${basedir}\src</xsl:attribute>
+            </property>
+            <property name="test">
+                <xsl:attribute name="value">${basedir}\test</xsl:attribute>
+            </property>
+            <property name="build">
+                <xsl:attribute name="value">${basedir}\build</xsl:attribute>
+            </property>
+            <property name="classes">
+                <xsl:attribute name="value">${build}\classes</xsl:attribute>
+            </property>
+            <property name="lib">
+                <xsl:attribute name="value">${build}\lib</xsl:attribute>
+            </property>
+            <property name="resources">
+                <xsl:attribute name="value">${basedir}\resources</xsl:attribute>
+            </property>
+
+            <property name="xbeans.packaged.jar.name" value="XBeans-packaged.jar"></property>
+
+            <property name="jars.ok" value=""></property>
+
+            <path id="axis2.class.path">
+                <pathelement>
+                    <xsl:attribute name="path">${java.class.path}</xsl:attribute>
+                </pathelement>
+                <pathelement>
+                    <xsl:attribute name="path">${maven.class.path}</xsl:attribute>
+                </pathelement>
+                <fileset>
+                    <xsl:attribute name="dir">${axis2.home}</xsl:attribute>
+                    <include>
+                        <xsl:attribute name="name">lib/*.jar</xsl:attribute>
+                    </include>
+                </fileset>
+            </path>
+            
+            <target name="init">
+                <mkdir>
+                    <xsl:attribute name="dir">${build}</xsl:attribute>
+                </mkdir>
+                <mkdir>
+                    <xsl:attribute name="dir">${classes}</xsl:attribute>
+                </mkdir>
+                <mkdir>
+                    <xsl:attribute name="dir">${lib}</xsl:attribute>
+                </mkdir>
+            </target>
+
+            <target name="jar.xbeans">
+                <!-- jar the  XMLbeans stuff to the lib folder-->
+                <jar>
+                    <xsl:attribute name="basedir">${resources}</xsl:attribute>
+                    <xsl:attribute name="destfile">${lib}\${xbeans.packaged.jar.name}</xsl:attribute>
+                    <xsl:attribute name="excludes">**/services.xml</xsl:attribute>
+                </jar>
+            </target>
+
+            <target name="pre.compile.test" depends="init, jar.xbeans">
+                <xsl:comment>Test the classpath for the availability of necesary classes</xsl:comment>
+                <available classname="org.apache.xmlbeans.XmlObject" property="xbeans.available"
classpathref="axis2.class.path"/>
+                <available classname="javax.xml.stream.XMLStreamReader" property="stax.available"
classpathref="axis2.class.path"/>
+                <available classname="org.apache.axis2.engine.AxisEngine" property="axis2.available"
classpathref="axis2.class.path"/>
+                <condition property="jars.ok" >
+                    <and>
+                        <isset property="xbeans.available"/>
+                        <isset property="stax.available"/>
+                        <isset property="axis2.available"/>
+                    </and>
+                </condition>
+
+                <xsl:comment>Print out the availabilities</xsl:comment>
+                <echo>
+                     <xsl:attribute name="message">XmlBeans Availability = ${xbeans.available}</xsl:attribute>
+                </echo>
+                <echo>
+                     <xsl:attribute name="message">Stax Availability= ${stax.available}</xsl:attribute>
+                </echo>
+                <echo>
+                     <xsl:attribute name="message">Axis2 Availability= ${axis2.available}</xsl:attribute>
+                </echo>
+
+            </target>
+
+            <target name="compile.all" depends="pre.compile.test">
+                <xsl:attribute name="if">jars.ok</xsl:attribute>
+                <javac debug="on">
+                    <xsl:attribute name="destdir">${classes}</xsl:attribute>
+                    <xsl:attribute name="srcdir">${src}</xsl:attribute>
+                    <classpath>
+                        <xsl:attribute name="location">${lib}\${xbeans.packaged.jar.name}</xsl:attribute>
+                    </classpath>
+                    <classpath>
+                        <xsl:attribute name="refid">axis2.class.path</xsl:attribute>
+                    </classpath>
+                </javac>
+            </target>
+            <target name="compile.test" depends="pre.compile.test">
+                <xsl:attribute name="if">jars.ok</xsl:attribute>
+                <javac debug="on">
+                    <xsl:attribute name="destdir">${classes}</xsl:attribute>
+                    <src>
+                        <xsl:attribute name="path">${src}</xsl:attribute>
+                    </src>
+                    <src>
+                        <xsl:attribute name="path">${test}</xsl:attribute>
+                    </src>
+                    <classpath>
+                        <xsl:attribute name="location">${lib}\${xbeans.packaged.jar.name}</xsl:attribute>
+                    </classpath>
+                    <classpath>
+                        <xsl:attribute name="refid">axis2.class.path</xsl:attribute>
+                    </classpath>
+                </javac>
+            </target>
+
+            <target name="echo.classpath.problem" depends="pre.compile.test">
+                <xsl:attribute name="unless">jars.ok</xsl:attribute>
+                <echo message="The class path is not set right!
+                               Please make sure the following classes are in the classpath
+                               1. XmlBeans
+                               2. Stax
+                               3. Axis2
+                "></echo>
+            </target>
+            <target name="jar.all" depends="jar.server, jar.client">
+            </target>
+            <target name="jar.server" depends="compile.all,echo.classpath.problem">
+                <xsl:attribute name="if">jars.ok</xsl:attribute>
+                <copy>
+                    <xsl:attribute name="toDir">${classes}/META-INF</xsl:attribute>
+                    <fileset>
+                        <xsl:attribute name="dir">${resources}</xsl:attribute>
+                        <include><xsl:attribute name="name">*.xml</xsl:attribute></include>
+                        <include><xsl:attribute name="name">*.wsdl</xsl:attribute></include>
+                        <exclude><xsl:attribute name="name">**/schemaorg_apache_xmlbean/**</xsl:attribute></exclude>
+                    </fileset>
+                </copy>
+                <copy>
+                    <xsl:attribute name="file">${lib}\${xbeans.packaged.jar.name}</xsl:attribute>
+                    <xsl:attribute name="toDir">${classes}/lib</xsl:attribute>
+                </copy>
+                <jar>
+                    <xsl:attribute name="destfile">${lib}/${name}.aar</xsl:attribute>
+                    <fileset>
+                        <xsl:attribute name="excludes">**/Test.class</xsl:attribute>
+                        <xsl:attribute name="dir">${classes}</xsl:attribute>
+                    </fileset>
+                </jar>
+            </target>
+            <target depends="compile.test" name="jar.client" if="jars.ok">
+                <jar>
+                    <xsl:attribute name="destfile">${lib}/${name}-test-client.jar</xsl:attribute>
+                    <fileset>
+                        <xsl:attribute name="dir">${classes}</xsl:attribute>
+                        <exclude><xsl:attribute name="name">**/META-INF/*.*</xsl:attribute></exclude>
+                        <exclude><xsl:attribute name="name">**/lib/*.*</xsl:attribute></exclude>
+                        <exclude><xsl:attribute name="name">**/*MessageReceiver.class</xsl:attribute></exclude>
+                        <exclude><xsl:attribute name="name">**/*Skeleton.class</xsl:attribute></exclude>
+                    </fileset>
+                    <fileset>
+                        <xsl:attribute name="dir">${resources}</xsl:attribute>
+                        <exclude><xsl:attribute name="name">**/*.wsdl</xsl:attribute></exclude>
+                        <exclude><xsl:attribute name="name">**/*.xml</xsl:attribute></exclude>
+                    </fileset>
+                </jar>
+            </target>
+            <target depends="jar.server" name="make.repo" if="jars.ok">
+                <mkdir>
+                    <xsl:attribute name="dir">${build}/repo/</xsl:attribute>
+                </mkdir>
+                <mkdir>
+                    <xsl:attribute name="dir">${build}/repo/services</xsl:attribute>
+                </mkdir>
+                <copy>
+                    <xsl:attribute name="file">${build}/lib/${name}.aar</xsl:attribute>
+                    <xsl:attribute name="toDir">${build}/repo/services/</xsl:attribute>
+                </copy>
+            </target>
+            <target depends="make.repo" name="start.server" if="jars.ok">
+                <java classname="org.apache.axis2.transport.http.SimpleHTTPServer" fork="true">
+                    <arg>
+                        <xsl:attribute name="value">${build}/repo</xsl:attribute>
+                    </arg>
+                    <classpath>
+                        <xsl:attribute name="refid">axis2.class.path</xsl:attribute>
+                    </classpath>
+                </java>
+            </target>
+            <target if="jars.ok" name="run.test" depends="jar.client">
+                <path id="test.class.path">
+                    <pathelement>
+                        <xsl:attribute name="location">${lib}/${name}-test-client.jar</xsl:attribute>
+                    </pathelement>
+                    <path>
+                        <xsl:attribute name="refid">axis2.class.path</xsl:attribute>
+                    </path>
+                </path>
+                <mkdir>
+                    <xsl:attribute name="dir">${build}/test-reports/</xsl:attribute>
+                </mkdir>
+                <junit printsummary="yes" haltonfailure="yes">
+                    <classpath>
+                        <xsl:attribute name="refid">test.class.path</xsl:attribute>
+                    </classpath>
+                    <formatter type="plain"/>
+                    <batchtest fork="yes">
+                        <xsl:attribute name="toDir">${build}/test-reports/</xsl:attribute>
+                        <fileset>
+                            <xsl:attribute name="dir">${test}</xsl:attribute>
+                            <include>
+                                <xsl:attribute name="name">**/*Test*.java</xsl:attribute>
+                            </include>
+                        </fileset>
+                    </batchtest>			
+                </junit>
+            </target>
+            <target name="clean">
+              <delete>
+                <xsl:attribute name="dir">${build}</xsl:attribute>
+              </delete>
+            </target>
+        </project>
+    </xsl:template>
+</xsl:stylesheet>

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl?rev=369183&r1=369182&r2=369183&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
Sat Jan 14 22:41:15 2006
@@ -79,6 +79,77 @@
     </xsl:if>
     </xsl:template>
     <!-- #################################################################################
 -->
+    <!-- ############################   jaxme template   ##############################
 -->
+    <xsl:template match="databinders[@dbtype='jaxme']">
+
+        <xsl:variable name="base64"><xsl:value-of select="base64Elements/name"/></xsl:variable>
+        <xsl:if test="$base64">
+            private static javax.xml.namespace.QName[] qNameArray = {
+            <xsl:for-each select="base64Elements/name">
+                <xsl:if test="position()>1">,</xsl:if>new javax.xml.namespace.QName("<xsl:value-of
select="@ns-url"/>","<xsl:value-of select="@localName"/>")
+            </xsl:for-each>
+            };
+        </xsl:if>
+
+        private org.apache.axis2.om.OMElement toOM(Object param) {
+            try {
+                javax.xml.bind.JAXBContext ctx = javax.xml.bind.JAXBContext.newInstance(param.getClass().getPackage()
+                                                                                        
   .getName());
+                org.apache.axis2.om.impl.llom.builder.SAXOMBuilder builder = new org.apache.axis2.om.impl.llom.builder.SAXOMBuilder();
+                javax.xml.bind.Marshaller marshaller = ctx.createMarshaller();
+                marshaller.marshal(param, builder);
+                return builder.getRootElement();
+            } catch (javax.xml.bind.JAXBException e) {
+                throw new RuntimeException(e);
+            }
+        }
+
+        private org.apache.axis2.soap.SOAPEnvelope toEnvelope(
+            org.apache.axis2.soap.SOAPFactory factory, Object param) {
+            org.apache.axis2.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
+            envelope.getBody().addChild(toOM(param));
+
+            return envelope;
+        }
+
+        public java.lang.Object fromOM(org.apache.axis2.om.OMElement param,
+        java.lang.Class type){
+            try{
+                javax.xml.transform.Source source =
+                        new javanet.staxutils.StAXSource(param.getXMLStreamReaderWithoutCaching());
+                javax.xml.bind.JAXBContext ctx = javax.xml.bind.JAXBContext.newInstance(
+                        type.getPackage().getName());
+                javax.xml.bind.Unmarshaller u = ctx.createUnmarshaller();
+                return u.unmarshal(source);
+            } catch(java.lang.Exception e) {
+                throw new RuntimeException("Data binding error",e);
+            }
+        }
+    <!-- Generate the base 64 optimize methods only if the base64 items are present -->
   
+   <xsl:if test="$base64">
+   private void optimizeContent(org.apache.axis2.om.OMElement element, javax.xml.namespace.QName[]
qNames){
+        for (int i = 0; i &lt; qNames.length; i++) {
+            markElementsAsOptimized(qNames[i],element);
+        }
+    }
+
+    private void markElementsAsOptimized(javax.xml.namespace.QName qName,org.apache.axis2.om.OMElement
rootElt){
+        if (rootElt.getQName().equals(qName)){
+            //get the text node and mark it
+            org.apache.axis2.om.OMNode node = rootElt.getFirstOMChild();
+            if (node.getType()==org.apache.axis2.om.OMNode.TEXT_NODE){
+                ((org.apache.axis2.om.OMText)node).setOptimize(true);
+            }
+
+        }
+        java.util.Iterator childElements = rootElt.getChildElements();
+        while (childElements.hasNext()) {
+            markElementsAsOptimized(qName,(org.apache.axis2.om.OMElement)childElements.next());
+        }
+    }
+    </xsl:if>
+    </xsl:template>
+    <!-- #################################################################################
 -->
        <!-- ############################   ADB template   ##############################
 -->
        <xsl:template match="databinders[@dbtype='adb']">
 

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl?rev=369183&r1=369182&r2=369183&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl
Sat Jan 14 22:41:15 2006
@@ -28,6 +28,22 @@
 
     </xsl:template>
     <!-- #################################################################################
 -->
+    <!-- ############################   jaxme template   ##############################
 -->
+    <xsl:template match="databinders[@dbtype='jaxme']">
+        //Create the desired Object and provide it as the test object
+        public  java.lang.Object getTestObject(java.lang.Class type) throws Exception{
+            Class factoryClazz = org.apache.axis2.util.Loader.loadClass(type.getPackage().getName()
+ ".ObjectFactory"); 
+            Object factory = factoryClazz.newInstance();   
+            java.lang.reflect.Method creatorMethod = factoryClazz.getMethod("newInstance",
new Class[]{ Class.class });
+            if (creatorMethod != null) {
+                return creatorMethod.invoke(factory, null);
+            } else {
+                throw new Exception("newInstance method not found!");
+            }
+        }
+
+    </xsl:template>
+    <!-- #################################################################################
 -->
     <!-- ############################   ADB template   ###################################
 -->
     <xsl:template match="databinders[@dbtype='adb']">
         //Create an ADBBean and provide it as the test object

Modified: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/wsdl/TestConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/wsdl/TestConstants.java?rev=369183&r1=369182&r2=369183&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/wsdl/TestConstants.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/wsdl/TestConstants.java
Sat Jan 14 22:41:15 2006
@@ -27,7 +27,7 @@
 
     public interface Databinding {
     	public static final String XML_BEANS = "xmlbeans";
-    	public static final String JAXB = "jaxb";
+    	public static final String JAXME = "jaxme";
     	public static final String ADB = "adb";
         public static final String NONE = "none";
     }



Mime
View raw message