1 16 17 package org.apache.axis2.wsdl.codegen; 18 19 import org.apache.axis2.wsdl.databinding.TypeMapper; 20 import org.apache.wsdl.WSDLDescription; 21 22 import java.io.File ; 23 import java.util.Map ; 24 25 29 public class CodeGenConfiguration implements CommandLineOptionConstants { 30 31 private WSDLDescription wom; 32 private CommandLineOptionParser parser; 33 private File outputLocation; 34 private int outputLanguage = XSLTConstants.LanguageTypes.JAVA; 35 private int databindingType = XSLTConstants.DataBindingTypes.XML_BEANS; private boolean advancedCodeGenEnabled=false; 37 38 39 private boolean asyncOn=true; 40 private boolean syncOn=true; 41 private boolean serverSide=false; 42 private boolean generateDeployementDescriptor=true; 43 private boolean writeTestCase=false; 44 private boolean writeMessageReceiver = true; 45 private String packageName=XSLTConstants.DEFAULT_PACKAGE_NAME; 46 47 48 private TypeMapper typeMapper; 49 50 public TypeMapper getTypeMapper() { 51 return typeMapper; 52 } 53 54 public void setTypeMapper(TypeMapper typeMapper) { 55 this.typeMapper = typeMapper; 56 } 57 58 public int getDatabindingType() { 59 return databindingType; 60 } 61 62 public void setDatabindingType(int databindingType) { 63 this.databindingType = databindingType; 64 } 65 66 70 public CodeGenConfiguration(WSDLDescription wom, 71 CommandLineOptionParser parser) { 72 this(wom,parser.getAllOptions()); 73 this.parser = parser; 74 } 75 76 public CodeGenConfiguration(WSDLDescription wom,Map optionMap) { 77 this.wom = wom; 78 79 String outputLocation = ((CommandLineOption)optionMap.get(OUTPUT_LOCATION_OPTION)).getOptionValue(); 80 this.outputLocation = new File (outputLocation); 81 82 serverSide = (optionMap.get(SERVER_SIDE_CODE_OPTION)!=null); 83 generateDeployementDescriptor = (optionMap.get(GENERATE_SERVICE_DESCRIPTION_OPTION)!=null); 84 writeTestCase = (optionMap.get(GENERATE_TEST_CASE_OPTION)!=null); 85 86 boolean asyncFlagPresent = (optionMap.get(CODEGEN_ASYNC_ONLY_OPTION)!=null); 87 boolean syncFlagPresent = (optionMap.get(CODEGEN_SYNC_ONLY_OPTION)!=null); 88 if (asyncFlagPresent) {this.asyncOn=true;this.syncOn=false;} 89 if (syncFlagPresent) {this.asyncOn=false;this.syncOn=true;} 90 91 CommandLineOption packageOption = (CommandLineOption)optionMap.get(PACKAGE_OPTION); 92 if(packageOption!=null) {this.packageName = packageOption.getOptionValue();} 93 94 CommandLineOption langOption = (CommandLineOption)optionMap.get(STUB_LANGUAGE_OPTION); 95 if (langOption!=null){ 96 loadLanguge(langOption.getOptionValue()); 97 } 98 99 100 101 } 102 103 104 105 106 private void loadLanguge(String langName) { 107 if (LanguageNames.JAVA.equalsIgnoreCase(langName)){ 108 this.outputLanguage = XSLTConstants.LanguageTypes.JAVA; 109 }else if (LanguageNames.C_SHARP.equalsIgnoreCase(langName)){ 110 this.outputLanguage = XSLTConstants.LanguageTypes.C_SHARP; 111 }else if (LanguageNames.C_PLUS_PLUS.equalsIgnoreCase(langName)){ 112 this.outputLanguage = XSLTConstants.LanguageTypes.C_PLUS_PLUS; 113 }else if (LanguageNames.VB_DOT_NET.equalsIgnoreCase(langName)){ 114 this.outputLanguage = XSLTConstants.LanguageTypes.VB_DOT_NET; 115 } 116 } 117 118 121 public CommandLineOptionParser getParser() { 122 return parser; 123 } 124 125 128 public WSDLDescription getWom() { 129 return wom; 130 } 131 132 133 136 public File getOutputLocation() { 137 return outputLocation; 138 } 139 140 public int getOutputLanguage() { 141 return outputLanguage; 142 } 143 144 public boolean isAdvancedCodeGenEnabled() { 145 return advancedCodeGenEnabled; 146 } 147 148 149 150 153 public String getPackageName() { 154 return packageName; 155 } 156 159 public void setPackageName(String packageName) { 160 this.packageName = packageName; 161 } 162 163 164 public boolean isAsyncOn() { 165 return asyncOn; 166 } 167 168 169 public boolean isSyncOn() { 170 return syncOn; 171 } 172 173 public boolean isServerSide() { 174 return serverSide; 175 } 176 177 public boolean isGenerateDeployementDescriptor() { 178 return generateDeployementDescriptor; 179 } 180 181 public boolean isWriteTestCase() { 182 return writeTestCase; 183 } 184 185 186 public boolean isWriteMessageReceiver() { 187 return writeMessageReceiver; 188 } 189 public void setWriteMessageReceiver(boolean writeMessageReceiver) { 190 this.writeMessageReceiver = writeMessageReceiver; 191 } 192 } | Popular Tags |