1 55 package org.jboss.axis.wsdl; 56 57 import org.jboss.axis.enums.Scope; 58 import org.jboss.axis.utils.CLOption; 59 import org.jboss.axis.utils.CLOptionDescriptor; 60 import org.jboss.axis.utils.JavaUtils; 61 import org.jboss.axis.utils.Messages; 62 import org.jboss.axis.wsdl.gen.Parser; 63 import org.jboss.axis.wsdl.gen.WSDL2; 64 import org.jboss.axis.wsdl.toJava.Emitter; 65 66 69 public class WSDL2Java extends WSDL2 70 { 71 protected static final int SERVER_OPT = 's'; 73 protected static final int SKELETON_DEPLOY_OPT = 'S'; 74 protected static final int NAMESPACE_OPT = 'N'; 75 protected static final int NAMESPACE_FILE_OPT = 'f'; 76 protected static final int OUTPUT_OPT = 'o'; 77 protected static final int SCOPE_OPT = 'd'; 78 protected static final int TEST_OPT = 't'; 79 protected static final int PACKAGE_OPT = 'p'; 80 protected static final int ALL_OPT = 'a'; 81 protected static final int TYPEMAPPING_OPT = 'T'; 82 protected static final int FACTORY_CLASS_OPT = 'F'; 83 protected static final int HELPER_CLASS_OPT = 'H'; 84 protected static final int USERNAME_OPT = 'U'; 85 protected static final int PASSWORD_OPT = 'P'; 86 87 protected boolean bPackageOpt = false; 88 private Emitter emitter; 89 90 99 protected static final CLOptionDescriptor[] options = new CLOptionDescriptor[]{ 100 new CLOptionDescriptor("server-side", 101 CLOptionDescriptor.ARGUMENT_DISALLOWED, 102 SERVER_OPT, 103 Messages.getMessage("optionSkel00")), 104 new CLOptionDescriptor("skeletonDeploy", 105 CLOptionDescriptor.ARGUMENT_REQUIRED, 106 SKELETON_DEPLOY_OPT, 107 Messages.getMessage("optionSkeletonDeploy00")), 108 new CLOptionDescriptor("NStoPkg", 109 CLOptionDescriptor.DUPLICATES_ALLOWED + CLOptionDescriptor.ARGUMENTS_REQUIRED_2, 110 NAMESPACE_OPT, 111 Messages.getMessage("optionNStoPkg00")), 112 new CLOptionDescriptor("fileNStoPkg", 113 CLOptionDescriptor.ARGUMENT_REQUIRED, 114 NAMESPACE_FILE_OPT, 115 Messages.getMessage("optionFileNStoPkg00")), 116 new CLOptionDescriptor("package", 117 CLOptionDescriptor.ARGUMENT_REQUIRED, 118 PACKAGE_OPT, 119 Messages.getMessage("optionPackage00")), 120 new CLOptionDescriptor("output", 121 CLOptionDescriptor.ARGUMENT_REQUIRED, 122 OUTPUT_OPT, 123 Messages.getMessage("optionOutput00")), 124 new CLOptionDescriptor("deployScope", 125 CLOptionDescriptor.ARGUMENT_REQUIRED, 126 SCOPE_OPT, 127 Messages.getMessage("optionScope00")), 128 new CLOptionDescriptor("testCase", 129 CLOptionDescriptor.ARGUMENT_DISALLOWED, 130 TEST_OPT, 131 Messages.getMessage("optionTest00")), 132 new CLOptionDescriptor("all", 133 CLOptionDescriptor.ARGUMENT_DISALLOWED, 134 ALL_OPT, 135 Messages.getMessage("optionAll00")), 136 new CLOptionDescriptor("typeMappingVersion", 137 CLOptionDescriptor.ARGUMENT_REQUIRED, 138 TYPEMAPPING_OPT, 139 Messages.getMessage("optionTypeMapping00")), 140 new CLOptionDescriptor("factory", 141 CLOptionDescriptor.ARGUMENT_REQUIRED, 142 FACTORY_CLASS_OPT, 143 Messages.getMessage("optionFactory00")), 144 new CLOptionDescriptor("helperGen", 145 CLOptionDescriptor.ARGUMENT_DISALLOWED, 146 HELPER_CLASS_OPT, 147 Messages.getMessage("optionHelper00")), 148 new CLOptionDescriptor("user", 149 CLOptionDescriptor.ARGUMENT_REQUIRED, 150 USERNAME_OPT, 151 Messages.getMessage("optionUsername")), 152 new CLOptionDescriptor("password", 153 CLOptionDescriptor.ARGUMENT_REQUIRED, 154 PASSWORD_OPT, 155 Messages.getMessage("optionPassword")) 156 }; 157 158 161 protected WSDL2Java() 162 { 163 emitter = (Emitter)parser; 166 addOptions(options); 167 } 169 172 protected Parser createParser() 173 { 174 return new Emitter(); 175 } 177 182 protected void parseOption(CLOption option) 183 { 184 switch (option.getId()) 185 { 186 case FACTORY_CLASS_OPT: 187 emitter.setFactory(option.getArgument()); 188 break; 189 190 case HELPER_CLASS_OPT: 191 emitter.setHelperWanted(true); 192 break; 193 194 case SKELETON_DEPLOY_OPT: 195 emitter.setSkeletonWanted(JavaUtils.isTrueExplicitly(option.getArgument(0))); 196 198 case SERVER_OPT: 199 emitter.setServerSide(true); 200 break; 201 202 case NAMESPACE_OPT: 203 String namespace = option.getArgument(0); 204 String packageName = option.getArgument(1); 205 emitter.getNamespaceMap().put(namespace, packageName); 206 break; 207 208 case NAMESPACE_FILE_OPT: 209 emitter.setNStoPkg(option.getArgument()); 210 break; 211 212 case PACKAGE_OPT: 213 bPackageOpt = true; 214 emitter.setPackageName(option.getArgument()); 215 break; 216 217 case OUTPUT_OPT: 218 emitter.setOutputDir(option.getArgument()); 219 break; 220 221 case SCOPE_OPT: 222 String arg = option.getArgument(); 223 224 Scope scope = Scope.getScope(arg, null); 227 228 if (scope != null) 229 { 230 emitter.setScope(scope); 231 } 232 else 233 { 234 System.err.println(Messages.getMessage("badScope00", arg)); 235 } 236 237 break; 238 239 case TEST_OPT: 240 emitter.setTestCaseWanted(true); 241 break; 242 243 case ALL_OPT: 244 emitter.setAllWanted(true); 245 break; 246 247 case TYPEMAPPING_OPT: 248 String tmValue = option.getArgument(); 249 if (tmValue.equals("1.1")) 250 { 251 emitter.setTypeMappingVersion("1.1"); 252 } 253 else if (tmValue.equals("1.2")) 254 { 255 emitter.setTypeMappingVersion("1.2"); 256 } 257 else 258 { 259 System.out.println(Messages.getMessage("badTypeMappingOption00")); 260 } 261 break; 262 263 case USERNAME_OPT: 264 emitter.setUsername(option.getArgument()); 265 break; 266 267 case PASSWORD_OPT: 268 emitter.setPassword(option.getArgument()); 269 break; 270 271 default: 272 super.parseOption(option); 273 } 274 } 276 281 protected void validateOptions() 282 { 283 super.validateOptions(); 284 285 if (emitter.isSkeletonWanted() && !emitter.isServerSide()) 287 { 288 System.out.println(Messages.getMessage("badSkeleton00")); 289 printUsage(); 290 } 291 if (!emitter.getNamespaceMap().isEmpty() && bPackageOpt) 292 { 293 System.out.println(Messages.getMessage("badpackage00")); 294 printUsage(); 295 } 296 } 298 304 public static void main(String args[]) 305 { 306 WSDL2Java wsdl2java = new WSDL2Java(); 307 wsdl2java.run(args); 308 } 309 } 310 | Popular Tags |