You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by aj...@apache.org on 2005/09/14 11:15:23 UTC
svn commit: r280805 - in
/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl:
codegen/ codegen/emitter/ codegen/writer/ util/
Author: ajith
Date: Wed Sep 14 02:14:12 2005
New Revision: 280805
URL: http://svn.apache.org/viewcvs?rev=280805&view=rev
Log:
Changed the code generator to load the constants and language specific items from a property file. The details of the property value formats are
included in the property file itself
Modified:
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/CSharpEmitter.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/Emitter.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/JavaEmitter.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/BeanWriter.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/CallbackHandlerWriter.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/DatabindingSupportClassWriter.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/InterfaceImplementationWriter.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/InterfaceWriter.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/LocalTestClassWriter.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/MessageReceiverWriter.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ServiceXMLWriter.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/SkeletonWriter.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/TestClassWriter.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/TestServiceXMLWriter.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/TestSkeletonImplWriter.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/util/FileWriter.java
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java Wed Sep 14 02:14:12 2005
@@ -17,6 +17,7 @@
package org.apache.axis2.wsdl.codegen;
import org.apache.axis2.wsdl.databinding.TypeMapper;
+import org.apache.axis2.wsdl.util.ConfigPropertyFileLoader;
import org.apache.wsdl.WSDLDescription;
import java.io.File;
@@ -31,7 +32,7 @@
private WSDLDescription wom;
private CommandLineOptionParser parser;
private File outputLocation;
- private int outputLanguage = XSLTConstants.LanguageTypes.JAVA;
+ private String outputLanguage = ConfigPropertyFileLoader.getDefaultLanguage();
private int databindingType = XSLTConstants.DataBindingTypes.XML_BEANS; //default is XML beans
private boolean advancedCodeGenEnabled = false;
@@ -153,8 +154,9 @@
CommandLineOption langOption = (CommandLineOption) optionMap.get(
STUB_LANGUAGE_OPTION);
+ //The language here
if (langOption != null) {
- loadLanguge(langOption.getOptionValue());
+ outputLanguage = langOption.getOptionValue();
}
// Unused code commented out by gdaniels...
@@ -166,17 +168,17 @@
}
- private void loadLanguge(String langName) {
- if (LanguageNames.JAVA.equalsIgnoreCase(langName)) {
- this.outputLanguage = XSLTConstants.LanguageTypes.JAVA;
- } else if (LanguageNames.C_SHARP.equalsIgnoreCase(langName)) {
- this.outputLanguage = XSLTConstants.LanguageTypes.C_SHARP;
- } else if (LanguageNames.C_PLUS_PLUS.equalsIgnoreCase(langName)) {
- this.outputLanguage = XSLTConstants.LanguageTypes.C_PLUS_PLUS;
- } else if (LanguageNames.VB_DOT_NET.equalsIgnoreCase(langName)) {
- this.outputLanguage = XSLTConstants.LanguageTypes.VB_DOT_NET;
- }
- }
+// private void loadLanguge(String langName) {
+// if (LanguageNames.JAVA.equalsIgnoreCase(langName)) {
+// this.outputLanguage = XSLTConstants.LanguageTypes.JAVA;
+// } else if (LanguageNames.C_SHARP.equalsIgnoreCase(langName)) {
+// this.outputLanguage = XSLTConstants.LanguageTypes.C_SHARP;
+// } else if (LanguageNames.C_PLUS_PLUS.equalsIgnoreCase(langName)) {
+// this.outputLanguage = XSLTConstants.LanguageTypes.C_PLUS_PLUS;
+// } else if (LanguageNames.VB_DOT_NET.equalsIgnoreCase(langName)) {
+// this.outputLanguage = XSLTConstants.LanguageTypes.VB_DOT_NET;
+// }
+// }
/**
* @return Returns the parser.
@@ -200,7 +202,7 @@
return outputLocation;
}
- public int getOutputLanguage() {
+ public String getOutputLanguage() {
return outputLanguage;
}
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java Wed Sep 14 02:14:12 2005
@@ -29,6 +29,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
/**
* @author chathura@opensource.lk
@@ -40,10 +41,10 @@
private CodeGenConfiguration configuration;
public CodeGenerationEngine(CodeGenConfiguration config) throws CodeGenerationException{
- this.configuration = config;
- loadExtensions();
+ this.configuration = config;
+ loadExtensions();
}
-
+
public CodeGenerationEngine(CommandLineOptionParser parser) throws CodeGenerationException {
WSDLDescription wom;
try {
@@ -59,23 +60,12 @@
}
private void loadExtensions() throws CodeGenerationException{
- try {
- String[] extensions = ConfigPropertyFileLoader.getExtensionClassNames();
- Class extensionClass;
- for (int i = 0; i < extensions.length; i++) {
- //load the Extension class
- extensionClass = this.getClass().getClassLoader().loadClass(extensions[i]);
- addExtension((CodeGenExtension)extensionClass.newInstance());
- }
- } catch (ClassNotFoundException e) {
- throw new CodeGenerationException("Extension class loading problem",e);
- } catch (InstantiationException e) {
- throw new CodeGenerationException("Extension class instantiation problem",e);
- } catch (IllegalAccessException e) {
- throw new CodeGenerationException("Illegal extension!",e);
- } catch (Exception e) {
- throw new CodeGenerationException(e);
+ String[] extensions = ConfigPropertyFileLoader.getExtensionClassNames();
+ for (int i = 0; i < extensions.length; i++) {
+ //load the Extension class
+ addExtension((CodeGenExtension)getObjectFromClassName(extensions[i]));
+
}
}
@@ -90,27 +80,31 @@
((CodeGenExtension) this.moduleEndpoints.get(i)).engage();
}
- Emitter emitter = null;
+ Emitter emitter;
TypeMapper mapper = configuration.getTypeMapper();
- switch (configuration.getOutputLanguage()) {
- case XSLTConstants.LanguageTypes.JAVA:
- emitter = new JavaEmitter(this.configuration, mapper);
- break;
- case XSLTConstants.LanguageTypes.C_SHARP:
- emitter = new CSharpEmitter(this.configuration, mapper);
- break;
- case XSLTConstants.LanguageTypes.C_PLUS_PLUS:
- case XSLTConstants.LanguageTypes.VB_DOT_NET:
-
- default:
- throw new UnsupportedOperationException();
+ Map emitterMap = ConfigPropertyFileLoader.getLanguageEmitterMap();
+ String className = emitterMap.get(this.configuration.getOutputLanguage()).toString();
+ if (className!=null){
+
+ emitter = (Emitter)getObjectFromClassName(className);
+ emitter.setCodeGenConfiguration(this.configuration);
+ emitter.setMapper(mapper);
+ }else{
+ throw new Exception("Emitter class not found!");
}
- if (this.configuration.isServerSide())
+
+
+ if (this.configuration.isServerSide()){
emitter.emitSkeleton();
- else
+ }else{
emitter.emitStub();
+ }
+
+ } catch (ClassCastException e) {
+ throw new CodeGenerationException("Non emitter class found!",e);
+
} catch (Exception e) {
throw new CodeGenerationException(e);
}
@@ -128,4 +122,24 @@
}
+ /**
+ * gets a object from the class
+ * @param className
+ * @return
+ */
+ private Object getObjectFromClassName(String className) throws CodeGenerationException{
+ try {
+ Class extensionClass = this.getClass().getClassLoader().loadClass(className);
+ return extensionClass.newInstance();
+ } catch (ClassNotFoundException e) {
+ throw new CodeGenerationException("Extension class loading problem",e);
+ } catch (InstantiationException e) {
+ throw new CodeGenerationException("Extension class instantiation problem",e);
+ } catch (IllegalAccessException e) {
+ throw new CodeGenerationException("Illegal extension!",e);
+ } catch (Exception e) {
+ throw new CodeGenerationException(e);
+ }
+
+ }
}
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java Wed Sep 14 02:14:12 2005
@@ -49,74 +49,6 @@
public static final int INTERFACE = 1;
public static final int BINDING = 2;
}
- /**
- * Interface templates
- */
- public interface XSLTInterfaceTemplates {
- public static final String JAVA_TEMPLATE = "/org/apache/axis2/wsdl/template/java/InterfaceTemplate.xsl";
- public static final String CSHARP_TEMPLATE = "/org/apache/axis2/wsdl/template/csharp/InterfaceTemplate.xsl";
- }
-
- /**
- * Interface implementation templates
- */
- public interface XSLTInterfaceImplementationTemplates {
- public static final String JAVA_TEMPLATE = "/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl";
- public static final String CSHARP_TEMPLATE = "/org/apache/axis2/wsdl/template/csharp/InterfaceImplementationTemplate.xsl";
- }
-
- /**
- * Interface bean templates
- */
- public interface XSLTBeanTemplates {
- public static final String JAVA_TEMPLATE = "/org/apache/axis2/wsdl/template/java/BeanTemplate.xsl";
- public static final String CSHARP_TEMPLATE = "/org/apache/axis2/wsdl/template/csharp/BeanTemplate.xsl";
- }
-
- /**
- * Interface CallbackHanlder Template
- */
- public interface XSLTCallbackHandlerTemplates {
- public static final String JAVA_TEMPLATE = "/org/apache/axis2/wsdl/template/java/CallbackHandlerTemplate.xsl";
- public static final String CSHARP_TEMPLATE = "/org/apache/axis2/wsdl/template/csharp/CallbackHandlerTemplate.xsl";
- }
-
- /**
- * Interface skeletons
- */
- public interface XSLTSkeletonTemplates {
- public static final String JAVA_TEMPLATE = "/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl";
- public static final String CSHARP_TEMPLATE = "/org/apache/axis2/wsdl/template/csharp/SkeletonTemplate.xsl";
- }
-
- public interface XSLTTestClassTemplates {
- public static final String JAVA_TEMPLATE = "/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl";
- public static final String CSHARP_TEMPLATE = "/org/apache/axis2/wsdl/template/csharp/TestClassTemplate.xsl";
- }
-
- public interface XSLTDatabindingSupporterTemplates {
- public static final String JAVA_TEMPLATE = "/org/apache/axis2/wsdl/template/java/XMLBeansSupporterTemplate.xsl";
- public static final String JAXB_TEMPLATE = "/org/apache/axis2/wsdl/template/java/JAXBSupporterTemplate.xsl";
- public static final String DEFAULT_TEMPLATE = "/org/apache/axis2/wsdl/template/java/DefaultDataBindingSupporterTemplate.xsl";
- //public static final String CSHARP_TEMPLATE = "/org/apache/axis2/wsdl/template/csharp/TestClassTemplate.xsl";
- }
-
- public interface XSLTLocalTestClassTemplates {
- public static final String JAVA_TEMPLATE = "/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl";
- public static final String CSHARP_TEMPLATE = "/org/apache/axis2/wsdl/template/csharp/LocalTestClassTemplate.xsl";
- }
-
- public interface XSLTTestSkeletonImplTemplates {
- public static final String JAVA_TEMPLATE = "/org/apache/axis2/wsdl/template/java/TestSkeletonImplTemplate.xsl";
- }
-
- public interface XSLTServiceXMLTemplates {
- public static final String GENERAL_SERVICE_TEMPLATE = "/org/apache/axis2/wsdl/template/general/ServiceXMLTemplate.xsl";
- }
-
- public interface XSLTMessageReceiverTemplates {
- public static final String JAVA_TEMPLATE = "/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl";
- }
-
+
}
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/codegen-config.properties?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/codegen-config.properties (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/codegen-config.properties Wed Sep 14 02:14:12 2005
@@ -1,9 +1,58 @@
#######################################################################################################################
##################### code generator property file #################################################################
#######################################################################################################################
-#Extensions - The extensions are comma seperated
-#these are loaded in their lexical order
+# Extensions - The extensions are comma seperated
+# these are loaded in their lexical order
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.XMLBeansExtension,org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension
-#The thied party schemas to be loaded. ex. The Xmime extension
-# Note - these will be loaded from the org.apache.axis2.wsdl.codegen.schema package
-codegen.thirdparty.schema=xmime.xsd,soap-enc.xsd
\ No newline at end of file
+# 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.
+# so whatever the third party schema's that are listed here should be present there
+codegen.thirdparty.schema=xmime.xsd,soap-enc.xsd
+#
+#####################################################################################################################
+#####################################################################################################################
+# Language types - these are the language types that the code generator understands. Again this is the name of the
+# language that should be passed from the tool as well
+#
+codegen.languages=java,c-sharp
+# Emitter class is the major code generator class that should be changed according to the language.
+# The emiiters need to implement the org.apache.axis2.wsdl.codegen.emitter.Emitter interface
+# Note - The emitters should appear in the lexical order of the languages. So the language java in the above
+# list corresponds to the org.apache.axis2.wsdl.codegen.emitter.JavaEmitter
+codegen.emitters=org.apache.axis2.wsdl.codegen.emitter.JavaEmitter,org.apache.axis2.wsdl.codegen.emitter.CSharpEmitter
+# Default language, this is the default language that would be picked when no language is specified. it should be
+# one of the languages specified above
+codegen.languages.default=java
+
+#####################################################################################################################
+######################## Language specific section #################################################################
+#####################################################################################################################
+# The language specific section has a special custom style. The language name comes first and seperated from the period
+# a unique name. These parameters will be included in a hashmap that is will be stored in another hash map with the
+# language as the key
+#####################################################################################################################
+# Java section - Templates.
+# The format of the templates is <writer-class-name>,<template-name>
+# Note this section is specific to the emitter logic. One can have anything here!
+java.interface.template=org.apache.axis2.wsdl.codegen.writer.InterfaceWriter,/org/apache/axis2/wsdl/template/java/InterfaceTemplate.xsl
+java.interface.impl.template=org.apache.axis2.wsdl.codegen.writer.InterfaceImplementationWriter,/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
+java.bean.template=org.apache.axis2.wsdl.codegen.writer.BeanWriter,/org/apache/axis2/wsdl/template/java/BeanTemplate.xsl
+java.callback.template=org.apache.axis2.wsdl.codegen.writer.CallbackHandlerWriter,/org/apache/axis2/wsdl/template/java/CallbackHandlerTemplate.xsl
+java.skeleton.template=org.apache.axis2.wsdl.codegen.writer.SkeletonWriter,/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl
+java.testclass.template=org.apache.axis2.wsdl.codegen.writer.TestClassWriter,/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl
+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.dbsupporter.xmlbeans.template=org.apache.axis2.wsdl.codegen.writer.DatabindingSupportClassWriter,/org/apache/axis2/wsdl/template/java/XMLBeansSupporterTemplate.xsl
+java.dbsupporter.jaxb.template=org.apache.axis2.wsdl.codegen.writer.DatabindingSupportClassWriter,/org/apache/axis2/wsdl/template/java/XMLBeansSupporterTemplate.xsl
+java.dbsupporter.default.template=org.apache.axis2.wsdl.codegen.writer.DatabindingSupportClassWriter,/org/apache/axis2/wsdl/template/java/DefaultDataBindingSupporterTemplate.xsl
+#
+# ##################################################################################################################
+# C sharp section - Templates
+c-sharp.interface.template=org.apache.axis2.wsdl.codegen.writer.InterfaceWriter,/org/apache/axis2/wsdl/template/csharp/InterfaceTemplate.xsl
+c-sharp.interface.impl.template=org.apache.axis2.wsdl.codegen.writer.InterfaceImplementationWriter,/org/apache/axis2/wsdl/template/csharp/InterfaceImplementationTemplate.xsl
+c-sharp.bean.template=org.apache.axis2.wsdl.codegen.writer.BeanWriter,/org/apache/axis2/wsdl/template/csharp/BeanTemplate.xsl
+c-sharp.callback.template=org.apache.axis2.wsdl.codegen.writer.CallbackHandlerWriter,/org/apache/axis2/wsdl/template/csharp/CallbackHandlerTemplate.xsl
+c-sharp.skeleton.template=org.apache.axis2.wsdl.codegen.writer.SkeletonWriter,/org/apache/axis2/wsdl/template/csharp/SkeletonTemplate.xsl
+c-sharp.testclass.template=org.apache.axis2.wsdl.codegen.writer.TestClassWriter,/org/apache/axis2/wsdl/template/csharp/TestClassTemplate.xsl
+c-sharp.service.template=org.apache.axis2.wsdl.codegen.writer.ServiceXMLWriter,/org/apache/axis2/wsdl/template/general/ServiceXMLTemplate.xsl
+c-sharp.message.receiver.template=org.apache.axis2.wsdl.codegen.writer.MessageReceiverWriter,/org/apache/axis2/wsdl/template/csharp/MessageReceiverTemplate.xsl
\ No newline at end of file
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/CSharpEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/CSharpEmitter.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/CSharpEmitter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/CSharpEmitter.java Wed Sep 14 02:14:12 2005
@@ -24,9 +24,11 @@
public class CSharpEmitter extends MultiLanguageClientEmitter {
+ public CSharpEmitter(){
+ }
+
public CSharpEmitter(CodeGenConfiguration configuration) {
this.configuration = configuration;
-// this.mapper = new CsharpTypeMapper();
this.mapper = new DefaultTypeMapper();
}
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/Emitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/Emitter.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/Emitter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/Emitter.java Wed Sep 14 02:14:12 2005
@@ -18,6 +18,7 @@
import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
import org.apache.axis2.wsdl.codegen.CodeGenerationException;
+import org.apache.axis2.wsdl.databinding.TypeMapper;
/**
* @author chathura@opensource.lk
@@ -25,6 +26,8 @@
public interface Emitter {
public void setCodeGenConfiguration(CodeGenConfiguration configuration);
+
+ public void setMapper(TypeMapper mapper) ;
public void emitStub() throws CodeGenerationException;
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/JavaEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/JavaEmitter.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/JavaEmitter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/JavaEmitter.java Wed Sep 14 02:14:12 2005
@@ -24,6 +24,9 @@
public class JavaEmitter extends MultiLanguageClientEmitter {
+ public JavaEmitter() {
+ }
+
/**
* @param configuration
*/
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/BeanWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/BeanWriter.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/BeanWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/BeanWriter.java Wed Sep 14 02:14:12 2005
@@ -28,32 +28,9 @@
this.outputFileLocation = new File(outputFileLocation);
}
- public BeanWriter(File outputFileLocation, int language) {
+ public BeanWriter(File outputFileLocation, String language) {
this.outputFileLocation = outputFileLocation;
this.language = language;
}
-
- /**
- * @see org.apache.axis2.wsdl.codegen.writer.ClassWriter#loadTemplate()
- */
- public void loadTemplate() {
- Class clazz = this.getClass();
- switch (language) {
- case XSLTConstants.LanguageTypes.JAVA:
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTBeanTemplates.JAVA_TEMPLATE);
- break;
- case XSLTConstants.LanguageTypes.C_SHARP:
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTBeanTemplates.CSHARP_TEMPLATE);
- break;
- case XSLTConstants.LanguageTypes.C_PLUS_PLUS:
- case XSLTConstants.LanguageTypes.VB_DOT_NET:
- default:
- throw new UnsupportedOperationException();
- }
-
- }
+
}
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/CallbackHandlerWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/CallbackHandlerWriter.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/CallbackHandlerWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/CallbackHandlerWriter.java Wed Sep 14 02:14:12 2005
@@ -29,30 +29,10 @@
this.outputFileLocation = new File(outputFileLocation);
}
- public CallbackHandlerWriter(File outputFileLocation, int language) {
+ public CallbackHandlerWriter(File outputFileLocation, String language) {
this.outputFileLocation = outputFileLocation;
this.language = language;
}
- public void loadTemplate() {
- Class clazz = this.getClass();
- switch (language) {
- case XSLTConstants.LanguageTypes.JAVA:
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTCallbackHandlerTemplates.JAVA_TEMPLATE);
- break;
- case XSLTConstants.LanguageTypes.C_SHARP:
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTCallbackHandlerTemplates.CSHARP_TEMPLATE);
- break;
- case XSLTConstants.LanguageTypes.C_PLUS_PLUS:
- case XSLTConstants.LanguageTypes.VB_DOT_NET:
- default:
- throw new UnsupportedOperationException();
- }
-
- }
-
+
}
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java Wed Sep 14 02:14:12 2005
@@ -1,12 +1,17 @@
package org.apache.axis2.wsdl.codegen.writer;
import org.apache.axis2.wsdl.codegen.XSLTConstants;
+import org.apache.axis2.wsdl.codegen.CodeGenerationException;
import org.apache.axis2.wsdl.util.FileWriter;
import org.apache.axis2.wsdl.util.XSLTTemplateProcessor;
+import org.apache.axis2.wsdl.util.ConfigPropertyFileLoader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
+import java.util.Map;
+import java.util.Enumeration;
+import java.util.Iterator;
/*
* Copyright 2004,2005 The Apache Software Foundation.
@@ -34,21 +39,70 @@
protected File outputFileLocation = null;
protected FileOutputStream stream = null;
protected InputStream xsltStream = null;
- protected int language = XSLTConstants.LanguageTypes.JAVA; //default is again java
+ protected String language = ConfigPropertyFileLoader.getDefaultLanguage(); //default would java
+
+ protected static final String TEMPLATE_SUFFIX = ".template";
+ protected static final String SEPERATOR_STRING = ",";
/**
* Sets the language
*
* @param language
*/
- public void setLanguage(int language) {
+ public void setLanguage(String language) {
this.language = language;
}
/**
* Load the template
*/
- public abstract void loadTemplate();
+ public void loadTemplate() throws CodeGenerationException{
+ // the default behavior for the class writers is to use the property map from the languge specific types
+ // The properties are arranged in the following order
+ // <lang-name>.* .template=<write-class>,<template-name>
+
+ //first get the language specific property map
+ Class clazz = this.getClass();
+ Map languageSpecificPropertyMap = (Map)ConfigPropertyFileLoader.getLanguageSpecificPropertiesMap().get(this.language);
+ if (languageSpecificPropertyMap==null){
+ throw new CodeGenerationException("No language specific properties!!!");
+ }
+
+ String templateName = findTemplate(languageSpecificPropertyMap);
+ if (templateName!=null){
+ this.xsltStream = clazz.getResourceAsStream(templateName);
+ }else{
+ throw new CodeGenerationException("template for this writer is not found");
+ }
+
+
+ }
+
+ protected String findTemplate(Map languageSpecificPropertyMap) {
+ //search through the proprty names to find the template relevant to this class
+
+ String ownClazzName = this.getClass().getName();
+ String key;
+ String propertyValue;
+ String templateName = null;
+ Iterator keys = languageSpecificPropertyMap.keySet().iterator();
+
+ 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)){
+ //bingo! we found the right template
+ templateName = propertyValue.substring(propertyValue.indexOf(SEPERATOR_STRING)+1) ;
+ break;
+ }
+ }
+
+ }
+ return templateName;
+ }
/**
* Creates the output file
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/DatabindingSupportClassWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/DatabindingSupportClassWriter.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/DatabindingSupportClassWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/DatabindingSupportClassWriter.java Wed Sep 14 02:14:12 2005
@@ -3,6 +3,8 @@
import org.apache.axis2.wsdl.codegen.XSLTConstants;
import java.io.File;
+import java.util.Map;
+import java.util.Iterator;
/*
* Copyright 2004,2005 The Apache Software Foundation.
@@ -31,7 +33,7 @@
}
public DatabindingSupportClassWriter(File outputFileLocation,
- int language,
+ String language,
int databindingFramework) {
this.outputFileLocation = outputFileLocation;
this.language = language;
@@ -42,31 +44,44 @@
this.databindingFramework = databindingFramework;
}
- public void loadTemplate() {
- Class clazz = this.getClass();
- if ( XSLTConstants.DataBindingTypes.XML_BEANS ==
- this.databindingFramework) {
- switch (language) {
- case XSLTConstants.LanguageTypes.JAVA:
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTDatabindingSupporterTemplates.JAVA_TEMPLATE);
- break;
- case XSLTConstants.LanguageTypes.C_SHARP:
- case XSLTConstants.LanguageTypes.C_PLUS_PLUS:
- case XSLTConstants.LanguageTypes.VB_DOT_NET:
- default:
- throw new UnsupportedOperationException();
+ //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;
+ 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;
+ }
+ }
}
- } else if (XSLTConstants.DataBindingTypes.JAXB ==
- this.databindingFramework) {
- this.xsltStream = clazz.getResourceAsStream(XSLTConstants.XSLTDatabindingSupporterTemplates.JAXB_TEMPLATE);
- } else if (XSLTConstants.DataBindingTypes.NONE ==
- this.databindingFramework) {
- this.xsltStream = clazz.getResourceAsStream(XSLTConstants.XSLTDatabindingSupporterTemplates.DEFAULT_TEMPLATE);
- }else{
- throw new UnsupportedOperationException(
- "Unsupported Data binding Framework!");
+
}
+
+ return templateName;
+
}
}
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/InterfaceImplementationWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/InterfaceImplementationWriter.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/InterfaceImplementationWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/InterfaceImplementationWriter.java Wed Sep 14 02:14:12 2005
@@ -28,34 +28,12 @@
}
public InterfaceImplementationWriter(File outputFileLocation,
- int language) {
+ String language) {
this.outputFileLocation = outputFileLocation;
this.language = language;
}
- /**
- * @see org.apache.axis2.wsdl.codegen.writer.ClassWriter#loadTemplate()
- */
- public void loadTemplate() {
- Class clazz = this.getClass();
- switch (language) {
- case XSLTConstants.LanguageTypes.JAVA:
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTInterfaceImplementationTemplates.JAVA_TEMPLATE);
- break;
- case XSLTConstants.LanguageTypes.C_SHARP:
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTInterfaceImplementationTemplates.CSHARP_TEMPLATE);
- break;
- case XSLTConstants.LanguageTypes.C_PLUS_PLUS:
- case XSLTConstants.LanguageTypes.VB_DOT_NET:
- default:
- throw new UnsupportedOperationException();
- }
-
- }
+
}
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/InterfaceWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/InterfaceWriter.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/InterfaceWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/InterfaceWriter.java Wed Sep 14 02:14:12 2005
@@ -29,33 +29,10 @@
this.outputFileLocation = new File(outputFileLocation);
}
- public InterfaceWriter(File outputFileLocation, int language) {
+ public InterfaceWriter(File outputFileLocation, String language) {
this.outputFileLocation = outputFileLocation;
this.language = language;
}
- /**
- * @see org.apache.axis2.wsdl.codegen.writer.ClassWriter#loadTemplate()
- */
- public void loadTemplate() {
- Class clazz = this.getClass();
- switch (language) {
- case XSLTConstants.LanguageTypes.JAVA:
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTInterfaceTemplates.JAVA_TEMPLATE);
- break;
- case XSLTConstants.LanguageTypes.C_SHARP:
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTInterfaceTemplates.CSHARP_TEMPLATE);
- break;
- case XSLTConstants.LanguageTypes.C_PLUS_PLUS:
- case XSLTConstants.LanguageTypes.VB_DOT_NET:
- default:
- throw new UnsupportedOperationException();
- }
-
- }
-
+
}
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/LocalTestClassWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/LocalTestClassWriter.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/LocalTestClassWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/LocalTestClassWriter.java Wed Sep 14 02:14:12 2005
@@ -28,28 +28,10 @@
this.outputFileLocation = new File(outputFileLocation);
}
- public LocalTestClassWriter(File outputFileLocation, int language) {
+ public LocalTestClassWriter(File outputFileLocation, String language) {
this.outputFileLocation = outputFileLocation;
this.language = language;
}
- public void loadTemplate() {
- Class clazz = this.getClass();
- switch (language) {
- case XSLTConstants.LanguageTypes.JAVA:
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTLocalTestClassTemplates.JAVA_TEMPLATE);
- break;
- case XSLTConstants.LanguageTypes.C_SHARP:
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTLocalTestClassTemplates.CSHARP_TEMPLATE);
- break;
- case XSLTConstants.LanguageTypes.C_PLUS_PLUS:
- case XSLTConstants.LanguageTypes.VB_DOT_NET:
- default:
- throw new UnsupportedOperationException();
- }
- }
+
}
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/MessageReceiverWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/MessageReceiverWriter.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/MessageReceiverWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/MessageReceiverWriter.java Wed Sep 14 02:14:12 2005
@@ -29,22 +29,10 @@
this.outputFileLocation = new File(outputFileLocation);
}
- public MessageReceiverWriter(File outputFileLocation, int language) {
+ public MessageReceiverWriter(File outputFileLocation, String language) {
this.outputFileLocation = outputFileLocation;
this.language = language;
}
- public void loadTemplate() {
- Class clazz = this.getClass();
- switch (language) {
- case XSLTConstants.LanguageTypes.JAVA:
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTMessageReceiverTemplates.JAVA_TEMPLATE);
- break;
- default:
- throw new UnsupportedOperationException();
- }
- }
-
+
}
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ServiceXMLWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ServiceXMLWriter.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ServiceXMLWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ServiceXMLWriter.java Wed Sep 14 02:14:12 2005
@@ -31,20 +31,12 @@
this.outputFileLocation = new File(outputFileLocation);
}
- public ServiceXMLWriter(File outputFileLocation, int language) {
+ public ServiceXMLWriter(File outputFileLocation, String language) {
this.outputFileLocation = outputFileLocation;
this.language = language;
}
- /**
- * @see org.apache.axis2.wsdl.codegen.writer.ClassWriter#loadTemplate()
- */
- public void loadTemplate() {
- Class clazz = this.getClass();
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTServiceXMLTemplates.GENERAL_SERVICE_TEMPLATE);
- }
+
public void createOutFile(String packageName, String fileName) throws Exception {
File outputFile = FileWriter.createClassFile(outputFileLocation,
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/SkeletonWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/SkeletonWriter.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/SkeletonWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/SkeletonWriter.java Wed Sep 14 02:14:12 2005
@@ -29,33 +29,11 @@
this.outputFileLocation = new File(outputFileLocation);
}
- public SkeletonWriter(File outputFileLocation, int language) {
+ public SkeletonWriter(File outputFileLocation, String language) {
this.outputFileLocation = outputFileLocation;
this.language = language;
}
- /**
- * @see org.apache.axis2.wsdl.codegen.writer.ClassWriter#loadTemplate()
- */
- public void loadTemplate() {
- Class clazz = this.getClass();
- switch (language) {
- case XSLTConstants.LanguageTypes.JAVA:
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTSkeletonTemplates.JAVA_TEMPLATE);
- break;
- case XSLTConstants.LanguageTypes.C_SHARP:
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTSkeletonTemplates.CSHARP_TEMPLATE);
- break;
- case XSLTConstants.LanguageTypes.C_PLUS_PLUS:
- case XSLTConstants.LanguageTypes.VB_DOT_NET:
- default:
- throw new UnsupportedOperationException();
- }
-
- }
+
}
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/TestClassWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/TestClassWriter.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/TestClassWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/TestClassWriter.java Wed Sep 14 02:14:12 2005
@@ -28,28 +28,10 @@
this.outputFileLocation = new File(outputFileLocation);
}
- public TestClassWriter(File outputFileLocation, int language) {
+ public TestClassWriter(File outputFileLocation, String language) {
this.outputFileLocation = outputFileLocation;
this.language = language;
}
- public void loadTemplate() {
- Class clazz = this.getClass();
- switch (language) {
- case XSLTConstants.LanguageTypes.JAVA:
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTTestClassTemplates.JAVA_TEMPLATE);
- break;
- case XSLTConstants.LanguageTypes.C_SHARP:
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTTestClassTemplates.CSHARP_TEMPLATE);
- break;
- case XSLTConstants.LanguageTypes.C_PLUS_PLUS:
- case XSLTConstants.LanguageTypes.VB_DOT_NET:
- default:
- throw new UnsupportedOperationException();
- }
- }
+
}
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/TestServiceXMLWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/TestServiceXMLWriter.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/TestServiceXMLWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/TestServiceXMLWriter.java Wed Sep 14 02:14:12 2005
@@ -30,7 +30,7 @@
super(outputFileLocation);
}
- public TestServiceXMLWriter(File outputFileLocation, int language) {
+ public TestServiceXMLWriter(File outputFileLocation, String language) {
super(outputFileLocation, language);
}
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/TestSkeletonImplWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/TestSkeletonImplWriter.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/TestSkeletonImplWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/TestSkeletonImplWriter.java Wed Sep 14 02:14:12 2005
@@ -29,22 +29,11 @@
this.outputFileLocation = new File(outputFileLocation);
}
- public TestSkeletonImplWriter(File outputFileLocation, int language) {
+ public TestSkeletonImplWriter(File outputFileLocation, String language) {
this.outputFileLocation = outputFileLocation;
this.language = language;
}
- public void loadTemplate() {
- Class clazz = this.getClass();
- switch (language) {
- case XSLTConstants.LanguageTypes.JAVA:
- this.xsltStream =
- clazz.getResourceAsStream(
- XSLTConstants.XSLTTestSkeletonImplTemplates.JAVA_TEMPLATE);
- break;
- default:
- throw new UnsupportedOperationException();
- }
- }
+
}
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java Wed Sep 14 02:14:12 2005
@@ -3,6 +3,9 @@
import java.io.InputStream;
import java.io.IOException;
import java.util.Properties;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Enumeration;
/**
* Tries to load the properties from the config properties
@@ -11,35 +14,92 @@
private static String[] extensionClassNames;
private static String[] thirdPartySchemaNames;
+ private static String[] languageTypes;
+ private static Map languageEmitterMap;
+ private static String defaultLanguage;
+ private static Map languageSpecificPropertiesMap;
+
private static final String CODE_GEN_KEY = "codegen.extension";
private static final String THIRD_PARTY_SCHEMA_KEY = "codegen.thirdparty.schema";
+ private static final String LANGUAGE_TYPE_KEY = "codegen.languages";
+ private static final String DEFAULT_LANGUAGE_TYPE_KEY = "codegen.languages.default";
+ private static final String EMITTER_CLASS_KEY = "codegen.emitters";
+
+ /* Note - Should be a non regular expression character. If not it should be properly escaped */
+ private static final String SEPERATOR_CHAR = ",";
static{
try {
InputStream stream = Object.class.getResourceAsStream("/org/apache/axis2/wsdl/codegen/codegen-config.properties");
- if(stream == null) {
- stream = ConfigPropertyFileLoader.class.getClassLoader().getResourceAsStream("org/apache/axis2/wsdl/codegen/codegen-config.properties");
- }
Properties props = new Properties();
props.load(stream);
- String codeGenExtensionClasses = props.getProperty(CODE_GEN_KEY);
- if (codeGenExtensionClasses!=null){
- extensionClassNames = codeGenExtensionClasses.split(",");
+ //create a new map for the lang specific properties
+ languageSpecificPropertiesMap = new HashMap();
+
+ String tempString = props.getProperty(CODE_GEN_KEY);
+ if (tempString!=null){
+ extensionClassNames = tempString.split(SEPERATOR_CHAR);
}
- String thirdPartySchemas = props.getProperty(THIRD_PARTY_SCHEMA_KEY);
- if (thirdPartySchemas!=null){
- thirdPartySchemaNames = thirdPartySchemas.split(",");
+ tempString = props.getProperty(THIRD_PARTY_SCHEMA_KEY);
+ if (tempString!=null){
+ thirdPartySchemaNames = tempString.split(SEPERATOR_CHAR);
}
+ tempString = props.getProperty(LANGUAGE_TYPE_KEY);
+ if (tempString!=null){
+ languageTypes = tempString.split(SEPERATOR_CHAR);
+
+ //load the language emitter map
+ tempString = props.getProperty(EMITTER_CLASS_KEY);
+ if (tempString==null){
+ throw new Exception("No emitters found");
+ }else{
+ String[] tempClassNames = tempString.split(SEPERATOR_CHAR);
+ //populate the map
+ languageEmitterMap = new HashMap();
+ for (int i = 0; i < tempClassNames.length; i++) {
+ languageEmitterMap.put(languageTypes[i],tempClassNames[i]);
+ }
+
+ }
+ }
+
+ tempString = props.getProperty(DEFAULT_LANGUAGE_TYPE_KEY);
+ if (null==tempString || !languageEmitterMap.containsKey(tempString) ){
+ throw new Exception("Unknown Language specified for default!");
+ }
+ defaultLanguage = tempString;
+
+ // run through the language specific properties and populate the
+ // language specific property map
+ //
+ String languageType;
+ String tempkey;
+ HashMap langSpecificMap ;
+ for (int i = 0; i < languageTypes.length; i++) {
+ languageType = languageTypes[i];
+ langSpecificMap = new HashMap();
+ Enumeration keyEnum = props.keys();
+ while (keyEnum.hasMoreElements()) {
+ tempkey = keyEnum.nextElement().toString();
+ if (tempkey.startsWith(languageType+".")){
+ langSpecificMap.put(tempkey,props.get(tempkey));
+ }
+ }
+ //now add this to the lang specific properties map
+ languageSpecificPropertiesMap.put(languageType,langSpecificMap);
+ }
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new RuntimeException(e);
+ }catch (Exception e){
+ throw new RuntimeException("Unknown Exception in loading the property file",e);
}
}
@@ -50,5 +110,21 @@
public static String[] getThirdPartySchemaNames() {
return thirdPartySchemaNames;
+ }
+
+ public static String[] getLanguageTypes() {
+ return languageTypes;
+ }
+
+ public static Map getLanguageEmitterMap() {
+ return languageEmitterMap;
+ }
+
+ public static String getDefaultLanguage() {
+ return defaultLanguage;
+ }
+
+ public static Map getLanguageSpecificPropertiesMap() {
+ return languageSpecificPropertiesMap;
}
}
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/util/FileWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/util/FileWriter.java?rev=280805&r1=280804&r2=280805&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/util/FileWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/util/FileWriter.java Wed Sep 14 02:14:12 2005
@@ -1,6 +1,5 @@
package org.apache.axis2.wsdl.util;
-import org.apache.axis2.wsdl.codegen.XSLTConstants;
import java.io.File;
import java.io.IOException;
@@ -69,55 +68,5 @@
return returnFile;
}
- /**
- * Creates/ returns a file object
- *
- * @param rootLocation - Location to be written
- * @param packageName - package, can be '.' seperated
- * @param fileName name of the file
- * @param fileType type of the file, java, csharp, cpp etc. Guesses the extension with the
- * file type
- * @return the File that was created
- * @throws IOException
- * @throws Exception
- */
- public static File createClassFile(File rootLocation,
- String packageName,
- String fileName,
- int fileType) throws IOException,
- Exception {
- return createClassFile(rootLocation,
- packageName,
- fileName,
- getExtension(fileType));
-
- }
-
- /**
- * Find the extension for a given file type
- *
- * @param fileType
- * @return
- */
- private static String getExtension(int fileType) {
- String extension = "";
- switch (fileType) {
- case XSLTConstants.LanguageTypes.JAVA:
- extension = ".java";
- break;
- case XSLTConstants.LanguageTypes.C_SHARP:
- extension = ".cs";
- break;
- case XSLTConstants.LanguageTypes.C_PLUS_PLUS:
- extension = ".cpp";
- break;
- case XSLTConstants.LanguageTypes.VB_DOT_NET:
- extension = ".vb";
- break;
- default:
- extension = ".xml";
- }
- return extension;
- }
}