Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 77415 invoked from network); 1 Dec 2005 18:19:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Dec 2005 18:19:50 -0000 Received: (qmail 20409 invoked by uid 500); 1 Dec 2005 18:19:48 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 20382 invoked by uid 500); 1 Dec 2005 18:19:47 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 20371 invoked by uid 500); 1 Dec 2005 18:19:47 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 20368 invoked by uid 99); 1 Dec 2005 18:19:47 -0000 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 01 Dec 2005 10:19:46 -0800 Received: (qmail 77319 invoked by uid 65534); 1 Dec 2005 18:19:26 -0000 Message-ID: <20051201181926.77318.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r350293 - in /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2: databinding/schema/ databinding/schema/writer/ wsdl/codegen/ wsdl/codegen/emitter/ wsdl/codegen/extension/ wsdl/codegen/writer/ wsdl/template/general/ Date: Thu, 01 Dec 2005 18:19:24 -0000 To: axis2-cvs@ws.apache.org From: ajith@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: ajith Date: Thu Dec 1 10:19:09 2005 New Revision: 350293 URL: http://svn.apache.org/viewcvs?rev=350293&view=rev Log: 1. Added a mechanism to set the package name in the generated ADB code. 2. Updated SimpleDBExtension.java to add the 'adb' prefix into the generated code. 3. Updated the ant build write class to write a custom antbuild for ADB stuff as well * Added the template for this new ant build Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/adbAntBuildTemplate.xsl Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/CompilerOptions.java 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/BeanWriter.java webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/JavaBeanWriter.java 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/codegen/emitter/MultiLanguageClientEmitter.java webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/AntBuildWriter.java Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/CompilerOptions.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/CompilerOptions.java?rev=350293&r1=350292&r2=350293&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/CompilerOptions.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/CompilerOptions.java Thu Dec 1 10:19:09 2005 @@ -1,6 +1,8 @@ package org.apache.axis2.databinding.schema; import java.io.File; +import java.util.regex.Pattern; +import java.util.regex.Matcher; /* * Copyright 2004,2005 The Apache Software Foundation. * @@ -29,6 +31,23 @@ * Generated output file */ File outputLocation; + String packageName=null; + + public String getPackageName() { + return packageName; + } + + public CompilerOptions setPackageName(String packageName) { + //validate the package name + //should be ***.***.***. type value + if (packageName!=null && testValue(packageName)){ + this.packageName = packageName; + }else{ + throw new RuntimeException("Unsupported value!"); + } + + return this; + } public File getOutputLocation() { return outputLocation; @@ -39,4 +58,9 @@ return this; } + private boolean testValue(String wordToMatch){ + Pattern pat = Pattern.compile("^(\\w+\\.)+$"); + Matcher m= pat.matcher(wordToMatch); + return m.matches(); + } } 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=350293&r1=350292&r2=350293&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 10:19:09 2005 @@ -75,7 +75,7 @@ //load the writer this.writer = SchemaPropertyLoader.getBeanWriterInstance(); - this.writer.init(this.options.getOutputLocation()); + this.writer.init(this.options); //laod the base types baseSchemaTypeMap =SchemaPropertyLoader.getTypeMapperInstance().getTypeMap(); @@ -284,7 +284,7 @@ } }else if (schemaType instanceof XmlSchemaSimpleType){ //process simple type - processSimpleSchemaType((XmlSchemaSimpleType)schemaType); + processSimpleSchemaType(xsElt,(XmlSchemaSimpleType)schemaType); } } @@ -520,7 +520,7 @@ * Handle the simple content * @param simpleType */ - private void processSimpleSchemaType(XmlSchemaSimpleType simpleType){ + private void processSimpleSchemaType(XmlSchemaElement xsElt,XmlSchemaSimpleType simpleType){ // handle the restriction XmlSchemaSimpleTypeContent content = simpleType.getContent(); if (content!=null){ @@ -537,9 +537,13 @@ this.changedTypeMap.put(simpleType.getQName(),baseTypeName); }else{ //recurse + if (restriction.getBaseType()!= null){ + processSimpleSchemaType(xsElt, restriction.getBaseType()); + } //processSimpleSchemaType(xsElt, new XmlSchemaSimpleType()); } } + //We still don't handle UNIONS of simple types } Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/BeanWriter.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/BeanWriter.java?rev=350293&r1=350292&r2=350293&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/BeanWriter.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/writer/BeanWriter.java Thu Dec 1 10:19:09 2005 @@ -5,6 +5,7 @@ import org.apache.ws.commons.schema.XmlSchemaSimpleType; import org.apache.axis2.databinding.schema.BeanWriterMetaInfoHolder; import org.apache.axis2.databinding.schema.SchemaCompilationException; +import org.apache.axis2.databinding.schema.CompilerOptions; import java.io.File; import java.io.IOException; @@ -37,6 +38,15 @@ * @throws IOException */ public void init(File rootDir) throws IOException ; + + /** + * Init the write with compiler options + * @param options + * @throws IOException + */ + public void init(CompilerOptions options) throws IOException ; + + /** * Write a complex type 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=350293&r1=350292&r2=350293&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 10:19:09 2005 @@ -6,6 +6,7 @@ import org.apache.axis2.util.*; import org.apache.axis2.databinding.schema.BeanWriterMetaInfoHolder; import org.apache.axis2.databinding.schema.SchemaCompilationException; +import org.apache.axis2.databinding.schema.CompilerOptions; import org.apache.axis2.databinding.schema.util.SchemaPropertyLoader; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -49,6 +50,8 @@ private List namesList; private static int count = 0; + private String packageName=null; + private File rootDir; @@ -59,6 +62,11 @@ public JavaBeanWriter(){ } + public void init(CompilerOptions options) throws IOException { + init(options.getOutputLocation()); + this.packageName = options.getPackageName(); + } + /** * @see BeanWriter#init(java.io.File) * @param rootDir @@ -111,7 +119,14 @@ * @throws Exception */ private String process(QName qName, BeanWriterMetaInfoHolder metainf, Map typeMap, boolean isElement) throws Exception { - String packageName = URLProcessor.getNameSpaceFromURL(qName.getNamespaceURI()); + + String nameSpaceFromURL = URLProcessor.getNameSpaceFromURL(qName.getNamespaceURI()); + String packageName = this.packageName==null? + nameSpaceFromURL : + this.packageName +nameSpaceFromURL; + + + String originalName = qName.getLocalPart(); String className = getNonConflictingName(this.namesList,originalName); @@ -168,7 +183,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(); @@ -270,7 +285,6 @@ public String write(XmlSchemaElement element, Map typeMap, BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException{ try { - //determine the package for this type. QName qName = element.getQName(); return process(qName, metainf, typeMap, true); } catch (Exception e) { 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=350293&r1=350292&r2=350293&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 Thu Dec 1 10:19:09 2005 @@ -48,7 +48,9 @@ java.dbsupporter.adb.template=org.apache.axis2.wsdl.codegen.writer.DatabindingSupportClassWriter,/org/apache/axis2/wsdl/template/java/ADBSupporterTemplate.xsl ########### java.dbsupporter.default.template=org.apache.axis2.wsdl.codegen.writer.DatabindingSupportClassWriter,/org/apache/axis2/wsdl/template/java/DefaultDataBindingSupporterTemplate.xsl -java.antbuild.template=org.apache.axis2.wsdl.codegen.writer.AntBuildWriter,/org/apache/axis2/wsdl/template/general/xmlbeansAntBuildTemplate.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 # file extension for generated files from this language java.filename.extension=java # Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java?rev=350293&r1=350292&r2=350293&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java Thu Dec 1 10:19:09 2005 @@ -420,9 +420,10 @@ axisInterface, axisBinding); - ClassWriter antBuildWriter = new AntBuildWriter( + AntBuildWriter antBuildWriter = new AntBuildWriter( this.configuration.getOutputLocation(), this.configuration.getOutputLanguage()); + antBuildWriter.setDatabindingFramework(this.configuration.getDatabindingType()); writeClass(skeletonModel, antBuildWriter); } Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java?rev=350293&r1=350292&r2=350293&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java Thu Dec 1 10:19:09 2005 @@ -42,6 +42,8 @@ * */ public class SimpleDBExtension extends AbstractCodeGenerationExtension { + public static final String ADB_PACKAGE_NAME_PREFIX = "adb."; + public void init(CodeGenConfiguration configuration) { this.configuration = configuration; } @@ -95,6 +97,8 @@ } //call the schema compiler CompilerOptions options = new CompilerOptions().setOutputLocation(configuration.getOutputLocation()); + options.setPackageName(ADB_PACKAGE_NAME_PREFIX); + SchemaCompiler schemaCompiler = new SchemaCompiler(options); schemaCompiler .compile(xmlSchemaTypeVector); Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/AntBuildWriter.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/AntBuildWriter.java?rev=350293&r1=350292&r2=350293&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/AntBuildWriter.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/AntBuildWriter.java Thu Dec 1 10:19:09 2005 @@ -1,9 +1,12 @@ package org.apache.axis2.wsdl.codegen.writer; import org.apache.axis2.util.FileWriter; +import org.apache.axis2.wsdl.codegen.XSLTConstants; import java.io.File; import java.io.FileOutputStream; +import java.util.Map; +import java.util.Iterator; /* * Copyright 2004,2005 The Apache Software Foundation. * @@ -21,6 +24,9 @@ */ public class AntBuildWriter extends ClassWriter{ + + int databindingFramework = 0; + public AntBuildWriter(String outputFileLocation) { this.outputFileLocation = new File(outputFileLocation); } @@ -30,7 +36,9 @@ this.language = language; } - + public void setDatabindingFramework(int databindingFramework) { + this.databindingFramework = databindingFramework; + } public void createOutFile(String packageName, String fileName) throws Exception { File outputFile = FileWriter.createClassFile(outputFileLocation, @@ -42,5 +50,49 @@ if (!fileExists){ this.stream = new FileOutputStream(outputFile); } + } + + //overridden to get the correct behavior + protected String findTemplate(Map languageSpecificPropertyMap) { + String ownClazzName = this.getClass().getName(); + String key; + String propertyValue; + String templateName = null; + Iterator keys = languageSpecificPropertyMap.keySet().iterator(); + String databindString; + + //set the correct databinding type string + switch(this.databindingFramework) { + case XSLTConstants.DataBindingTypes.XML_BEANS: + databindString = "xmlbeans"; + break; + case XSLTConstants.DataBindingTypes.JAXB: + databindString = "jaxb"; + break; + case XSLTConstants.DataBindingTypes.ADB: + databindString = "adb"; + break; + default: + databindString = "default"; + } + + while (keys.hasNext()) { + //check for template entries + key = keys.next().toString(); + if (key.endsWith(TEMPLATE_SUFFIX)){ + // check if the class name is there + propertyValue = languageSpecificPropertyMap.get(key).toString(); + if (propertyValue.startsWith(ownClazzName)){ + if (key.indexOf(databindString)!=-1){ + templateName = propertyValue.substring(propertyValue.indexOf(SEPERATOR_STRING)+1) ; + break; + } + } + } + + } + + return templateName; + } } Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/adbAntBuildTemplate.xsl URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/adbAntBuildTemplate.xsl?rev=350293&view=auto ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/adbAntBuildTemplate.xsl (added) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/adbAntBuildTemplate.xsl Thu Dec 1 10:19:09 2005 @@ -0,0 +1,133 @@ + + + + + + + Auto generated ant build file + + ${basedir}\src + + + ${basedir}\classes + + + ${basedir}\bin + + + ${basedir}\other + + + + + + + + + + first move the generated packages + + ${src} + + ${basedir} + \**\ + + + + move the adb stuff to the src too + + ${src} + + ${basedir} + adb\**\ + + + move the rest of the stuff to the other folder + + ${other} + + ${basedir} + ${mappings.folder.name}\**\ + + + + ${other} + + ${basedir} + ${schemas.folder.name}\**\ + + + + + + + + ${src} + + + ${classes} + + + ${bin} + + + + + + Test the classpath for the availability of necesary classes + + + + + + + + + + + + Print out the availabilities + + Stax Availability= ${stax.available} + + + Axis2 Availability= ${axis2.available} + + + + + + ${jars.ok} + + ${classes} + ${src} + + ${bin}\${xbeans.packaged.jar.name} + + + ${java.class.path} + + + + + + ${jars.ok} + + + + ${jars.ok} + + ${classes} + ${bin} + + + + +