Fields Summary |
---|
protected static final int | INHERITED_CLASS_OPTField INHERITED_CLASS_OPT |
protected static final int | SOAPACTION_OPTField SOAPACTION_OPT |
protected static final int | BINDING_NAME_OPTField BINDING_NAME_OPT |
protected static final int | STOP_CLASSES_OPTField STOP_CLASSES_OPT |
protected static final int | IMPORT_SCHEMA_OPTField IMPORT_SCHEMA_OPT |
protected static final int | EXTRA_CLASSES_OPTField EXTRA_CLASSES_OPT |
protected static final int | HELP_OPTField HELP_OPT |
protected static final int | IMPL_CLASS_OPTField IMPL_CLASS_OPT |
protected static final int | INPUT_OPTField INPUT_OPT |
protected static final int | LOCATION_OPTField LOCATION_OPT |
protected static final int | LOCATION_IMPORT_OPTField LOCATION_IMPORT_OPT |
protected static final int | METHODS_ALLOWED_OPTField METHODS_ALLOWED_OPT |
protected static final int | NAMESPACE_OPTField NAMESPACE_OPT |
protected static final int | NAMESPACE_IMPL_OPTField NAMESPACE_IMPL_OPT |
protected static final int | OUTPUT_OPTField OUTPUT_OPT |
protected static final int | OUTPUT_IMPL_OPTField OUTPUT_IMPL_OPT |
protected static final int | PACKAGE_OPTField PACKAGE_OPT |
protected static final int | PORTTYPE_NAME_OPTField PORTTYPE_NAME_OPT |
protected static final int | SERVICE_PORT_NAME_OPTField SERVICE_PORT_NAME_OPT |
protected static final int | SERVICE_ELEMENT_NAME_OPTField SERVICE_ELEMENT_NAME_OPT |
protected static final int | TYPEMAPPING_OPTField TYPEMAPPING_OPT |
protected static final int | USE_OPTField USE_OPT |
protected static final int | OUTPUT_WSDL_MODE_OPTField OUTPUT_WSDL_MODE_OPT |
protected static final int | METHODS_NOTALLOWED_OPTField METHODS_NOTALLOWED_OPT |
protected static final int | CLASSPATH_OPT |
protected static final int | STYLE_OPTField STYLE_OPT |
protected static final int | DEPLOY_OPTField DEPLOY_OPT |
protected org.apache.axis.utils.CLOptionDescriptor[] | optionsDefine the understood options. Each CLOptionDescriptor contains:
- The "long" version of the option. Eg, "help" means that "--help" will
be recognised.
- The option flags, governing the option's argument(s).
- The "short" version of the option. Eg, 'h' means that "-h" will be
recognised.
- A description of the option for the usage message |
protected org.apache.axis.wsdl.fromJava.Emitter | emitterField emitter |
protected String | classNameField className |
protected String | wsdlFilenameField wsdlFilename |
protected String | wsdlImplFilenameField wsdlImplFilename |
protected HashMap | namespaceMapField namespaceMap |
protected int | modeField mode |
boolean | locationSetField locationSet |
protected String | typeMappingVersionField typeMappingVersion |
protected boolean | isDeployField isDeplpy |
Methods Summary |
---|
protected void | addOptions(org.apache.axis.utils.CLOptionDescriptor[] newOptions)addOptions
Add option descriptions to the tool. Allows
extended classes to add additional options.
if ((newOptions != null) && (newOptions.length > 0)) {
CLOptionDescriptor[] allOptions =
new CLOptionDescriptor[options.length + newOptions.length];
System.arraycopy(options, 0, allOptions, 0, options.length);
System.arraycopy(newOptions, 0, allOptions, options.length,
newOptions.length);
options = allOptions;
}
|
protected org.apache.axis.wsdl.fromJava.Emitter | createEmitter()Instantiate an Emitter
return new Emitter();
|
protected void | generateServerSide(org.apache.axis.wsdl.fromJava.Emitter j2w, java.lang.String wsdlFileName)Generate the server side artifacts from the generated WSDL
org.apache.axis.wsdl.toJava.Emitter w2j = new org.apache.axis.wsdl.toJava.Emitter();
File wsdlFile = new File(wsdlFileName);
w2j.setServiceDesc(j2w.getServiceDesc());
w2j.setQName2ClassMap(j2w.getQName2ClassMap());
w2j.setOutputDir(wsdlFile.getParent());
w2j.setServerSide(true);
w2j.setHelperWanted(true);
// setup namespace-to-package mapping
String ns = j2w.getIntfNamespace();
String pkg = j2w.getCls().getPackage().getName();
w2j.getNamespaceMap().put(ns, pkg);
Map nsmap = j2w.getNamespaceMap();
if (nsmap != null) {
for (Iterator i = nsmap.keySet().iterator(); i.hasNext(); ) {
pkg = (String) i.next();
ns = (String) nsmap.get(pkg);
w2j.getNamespaceMap().put(ns, pkg);
}
}
// set 'deploy' mode
w2j.setDeploy(true);
if (j2w.getImplCls() != null) {
w2j.setImplementationClassName(j2w.getImplCls().getName());
} else {
if (!j2w.getCls().isInterface()) {
w2j.setImplementationClassName(j2w.getCls().getName());
} else {
throw new Exception("implementation class is not specified.");
}
}
w2j.run(wsdlFileName);
|
public static void | main(java.lang.String[] args)Main
Run the Java2WSDL emitter with the specified command-line arguments
Java2WSDL java2wsdl = new Java2WSDL();
System.exit(java2wsdl.run(args));
|
protected boolean | parseOption(org.apache.axis.utils.CLOption option)Parse an option
String value;
boolean status = true;
switch (option.getId()) {
case CLOption.TEXT_ARGUMENT:
if (className != null) {
System.out.println(
Messages.getMessage(
"j2wDuplicateClass00", className,
option.getArgument()));
printUsage();
status = false; // error
}
className = option.getArgument();
break;
case METHODS_ALLOWED_OPT:
emitter.setAllowedMethods(option.getArgument());
break;
case INHERITED_CLASS_OPT:
emitter.setUseInheritedMethods(true);
break;
case IMPL_CLASS_OPT:
emitter.setImplCls(option.getArgument());
break;
case HELP_OPT:
printUsage();
status = false;
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(Messages.getMessage("j2wmodeerror",
modeArg));
}
break;
case OUTPUT_OPT:
wsdlFilename = option.getArgument();
break;
case INPUT_OPT:
emitter.setInputWSDL(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 BINDING_NAME_OPT:
emitter.setBindingName(option.getArgument());
break;
case STOP_CLASSES_OPT:
emitter.setStopClasses(option.getArgument());
break;
case TYPEMAPPING_OPT:
value = option.getArgument();
typeMappingVersion = value;
break;
case SOAPACTION_OPT:
value = option.getArgument();
if (value.equalsIgnoreCase("DEFAULT")) {
emitter.setSoapAction("DEFAULT");
} else if (value.equalsIgnoreCase("OPERATION")) {
emitter.setSoapAction("OPERATION");
} else if (value.equalsIgnoreCase("NONE")) {
emitter.setSoapAction("NONE");
} else {
System.out.println(
Messages.getMessage("j2wBadSoapAction00"));
status = false;
}
break;
case STYLE_OPT:
value = option.getArgument();
if (value.equalsIgnoreCase("DOCUMENT")
|| value.equalsIgnoreCase("RPC")
|| value.equalsIgnoreCase("WRAPPED")) {
emitter.setStyle(value);
} else {
System.out.println(Messages.getMessage("j2woptBadStyle00"));
status = false;
}
break;
case USE_OPT:
value = option.getArgument();
if (value.equalsIgnoreCase("LITERAL")
|| value.equalsIgnoreCase("ENCODED")) {
emitter.setUse(value);
} else {
System.out.println(Messages.getMessage("j2woptBadUse00"));
status = false;
}
break;
case EXTRA_CLASSES_OPT:
try {
emitter.setExtraClasses(option.getArgument());
} catch (ClassNotFoundException e) {
System.out.println(Messages.getMessage("j2woptBadClass00",
e.toString()));
status = false;
}
break;
case IMPORT_SCHEMA_OPT:
emitter.setInputSchema(option.getArgument());
break;
case CLASSPATH_OPT:
ClassUtils.setDefaultClassLoader(ClassUtils.createClassLoader(
option.getArgument(),
this.getClass().getClassLoader()));
break;
case DEPLOY_OPT:
isDeploy = true;
break;
default :
break;
}
return status;
|
protected void | printUsage()printUsage
print usage information and quit.
String lSep = System.getProperty("line.separator");
StringBuffer msg = new StringBuffer();
msg.append("Java2WSDL "
+ Messages.getMessage("j2wemitter00")).append(lSep);
msg.append(
Messages.getMessage(
"j2wusage00",
"java " + getClass().getName()
+ " [options] class-of-portType")).append(lSep);
msg.append(Messages.getMessage("j2woptions00")).append(lSep);
msg.append(CLUtil.describeOptions(options).toString());
msg.append(Messages.getMessage("j2wdetails00")).append(lSep);
System.out.println(msg.toString());
|
protected int | run(java.lang.String[] args)run
checks the command-line arguments and runs the tool.
// Parse the arguments
CLArgsParser argsParser = new CLArgsParser(args, options);
// Print parser errors, if any
if (null != argsParser.getErrorString()) {
System.err.println(
Messages.getMessage("j2werror00", argsParser.getErrorString()));
printUsage();
return (1);
}
// Get a list of parsed options
List clOptions = argsParser.getArguments();
int size = clOptions.size();
try {
// Parse the options and configure the emitter as appropriate.
for (int i = 0; i < size; i++) {
if (parseOption((CLOption) clOptions.get(i)) == false) {
return (1);
}
}
// validate argument combinations
if (validateOptions() == false) {
return (1);
}
// Set the namespace map
if (!namespaceMap.isEmpty()) {
emitter.setNamespaceMap(namespaceMap);
}
TypeMappingRegistryImpl tmr = new TypeMappingRegistryImpl();
tmr.doRegisterFromVersion(typeMappingVersion);
emitter.setTypeMappingRegistry(tmr);
// 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);
}
if (isDeploy) {
generateServerSide(emitter, (wsdlImplFilename != null) ? wsdlImplFilename : wsdlFilename);
}
// everything is good
return (0);
} catch (Throwable t) {
t.printStackTrace();
return (1);
}
|
protected boolean | validateOptions()validateOptions
This method is invoked after the options are set to validate
the option settings.
// Can't proceed without a class name
if ((className == null)) {
System.out.println(Messages.getMessage("j2wMissingClass00"));
printUsage();
return false;
}
if (!locationSet
&& ((mode == Emitter.MODE_ALL)
|| (mode == Emitter.MODE_IMPLEMENTATION))) {
System.out.println(Messages.getMessage("j2wMissingLocation00"));
printUsage();
return false;
}
return true; // a-OK
|