int size = clOptions.size();
try {
// Instantiate the emitter
Emitter emitter = new Emitter();
// Parse the options and configure the emitter as appropriate.
for (int i = 0; i < size; i++) {
CLOption option = (CLOption)clOptions.get(i);
switch (option.getId()) {
case CLOption.TEXT_ARGUMENT:
if (className != null) {
printUsage();
}
className = option.getArgument();
break;
case METHODS_ALLOWED_OPT:
emitter.setAllowedMethods(option.getArgument());
break;
case INHERITED_CLASS_OPT:
emitter.setUseInheritedMethods(true);
break;
case FACTORY_CLASS_OPT:
emitter.setFactory(option.getArgument());
break;
case IMPL_CLASS_OPT:
emitter.setImplCls(option.getArgument());
break;
case HELP_OPT:
printUsage();
break;
case OUTPUT_WSDL_MODE_OPT:
String modeArg = option.getArgument();
if ("All".equalsIgnoreCase(modeArg))
mode = Emitter.MODE_ALL;
else if ("Interface".equalsIgnoreCase(modeArg))
mode = Emitter.MODE_INTERFACE;
else if ("Implementation".equalsIgnoreCase(modeArg))
mode = Emitter.MODE_IMPLEMENTATION;
else {
mode = Emitter.MODE_ALL;
System.err.println(JavaUtils.getMessage("j2wmodeerror", modeArg));
}
break;
case OUTPUT_OPT:
wsdlFilename = option.getArgument();
break;
case OUTPUT_IMPL_OPT:
wsdlImplFilename = option.getArgument();
break;
case PACKAGE_OPT:
String packageName = option.getArgument(0);
String namespace = option.getArgument(1);
namespaceMap.put(packageName, namespace);
break;
case NAMESPACE_OPT:
emitter.setIntfNamespace(option.getArgument());
break;
case NAMESPACE_IMPL_OPT:
emitter.setImplNamespace(option.getArgument());
break;
case SERVICE_ELEMENT_NAME_OPT:
emitter.setServiceElementName(option.getArgument());
break;
case SERVICE_PORT_NAME_OPT:
emitter.setServicePortName(option.getArgument());
break;
case LOCATION_OPT:
emitter.setLocationUrl(option.getArgument());
locationSet = true;
break;
case LOCATION_IMPORT_OPT:
emitter.setImportUrl(option.getArgument());
break;
case METHODS_NOTALLOWED_OPT:
emitter.setDisallowedMethods(option.getArgument());
break;
case PORTTYPE_NAME_OPT:
emitter.setPortTypeName(option.getArgument());
break;
case STOP_CLASSES_OPT:
emitter.setStopClasses(option.getArgument());
break;
case TYPEMAPPING_OPT:
String value = option.getArgument();
if (value.equals("1.1")) {
emitter.setDefaultTypeMapping(
DefaultTypeMappingImpl.getSingleton());
} else if (value.equals("1.2")) {
emitter.setDefaultTypeMapping(
DefaultSOAP12TypeMappingImpl.create());
} else {
System.out.println(JavaUtils.getMessage("j2wBadTypeMapping00"));
}
break;
}
}
// Can't proceed without a class name
if ((className == null)) {
printUsage();
}
if (!locationSet && (mode == Emitter.MODE_ALL ||
mode == Emitter.MODE_IMPLEMENTATION)) {
System.out.println(JavaUtils.getMessage("j2wMissingLocation00"));
printUsage();
}
// Default to SOAP 1.2 JAX-RPC mapping
if (emitter.getDefaultTypeMapping() == null) {
emitter.setDefaultTypeMapping(DefaultSOAP12TypeMappingImpl.create());
}
if (!namespaceMap.isEmpty()) {
emitter.setNamespaceMap(namespaceMap);
}
// Find the class using the name
emitter.setCls(className);
// Generate a full wsdl, or interface & implementation wsdls
if (wsdlImplFilename == null) {
emitter.emit(wsdlFilename, mode);
} else {
emitter.emit(wsdlFilename, wsdlImplFilename);
}
}
catch (Throwable t) {
t.printStackTrace();
}