package org.jboss.axis.wsdl;
import org.jboss.axis.enums.Scope;
import org.jboss.axis.utils.CLOption;
import org.jboss.axis.utils.CLOptionDescriptor;
import org.jboss.axis.utils.JavaUtils;
import org.jboss.axis.utils.Messages;
import org.jboss.axis.wsdl.gen.Parser;
import org.jboss.axis.wsdl.gen.WSDL2;
import org.jboss.axis.wsdl.toJava.Emitter;
public class WSDL2Java extends WSDL2
{
protected static final int SERVER_OPT = 's';
protected static final int SKELETON_DEPLOY_OPT = 'S';
protected static final int NAMESPACE_OPT = 'N';
protected static final int NAMESPACE_FILE_OPT = 'f';
protected static final int OUTPUT_OPT = 'o';
protected static final int SCOPE_OPT = 'd';
protected static final int TEST_OPT = 't';
protected static final int PACKAGE_OPT = 'p';
protected static final int ALL_OPT = 'a';
protected static final int TYPEMAPPING_OPT = 'T';
protected static final int FACTORY_CLASS_OPT = 'F';
protected static final int HELPER_CLASS_OPT = 'H';
protected static final int USERNAME_OPT = 'U';
protected static final int PASSWORD_OPT = 'P';
protected boolean bPackageOpt = false;
private Emitter emitter;
protected static final CLOptionDescriptor[] options = new CLOptionDescriptor[]{
new CLOptionDescriptor("server-side",
CLOptionDescriptor.ARGUMENT_DISALLOWED,
SERVER_OPT,
Messages.getMessage("optionSkel00")),
new CLOptionDescriptor("skeletonDeploy",
CLOptionDescriptor.ARGUMENT_REQUIRED,
SKELETON_DEPLOY_OPT,
Messages.getMessage("optionSkeletonDeploy00")),
new CLOptionDescriptor("NStoPkg",
CLOptionDescriptor.DUPLICATES_ALLOWED + CLOptionDescriptor.ARGUMENTS_REQUIRED_2,
NAMESPACE_OPT,
Messages.getMessage("optionNStoPkg00")),
new CLOptionDescriptor("fileNStoPkg",
CLOptionDescriptor.ARGUMENT_REQUIRED,
NAMESPACE_FILE_OPT,
Messages.getMessage("optionFileNStoPkg00")),
new CLOptionDescriptor("package",
CLOptionDescriptor.ARGUMENT_REQUIRED,
PACKAGE_OPT,
Messages.getMessage("optionPackage00")),
new CLOptionDescriptor("output",
CLOptionDescriptor.ARGUMENT_REQUIRED,
OUTPUT_OPT,
Messages.getMessage("optionOutput00")),
new CLOptionDescriptor("deployScope",
CLOptionDescriptor.ARGUMENT_REQUIRED,
SCOPE_OPT,
Messages.getMessage("optionScope00")),
new CLOptionDescriptor("testCase",
CLOptionDescriptor.ARGUMENT_DISALLOWED,
TEST_OPT,
Messages.getMessage("optionTest00")),
new CLOptionDescriptor("all",
CLOptionDescriptor.ARGUMENT_DISALLOWED,
ALL_OPT,
Messages.getMessage("optionAll00")),
new CLOptionDescriptor("typeMappingVersion",
CLOptionDescriptor.ARGUMENT_REQUIRED,
TYPEMAPPING_OPT,
Messages.getMessage("optionTypeMapping00")),
new CLOptionDescriptor("factory",
CLOptionDescriptor.ARGUMENT_REQUIRED,
FACTORY_CLASS_OPT,
Messages.getMessage("optionFactory00")),
new CLOptionDescriptor("helperGen",
CLOptionDescriptor.ARGUMENT_DISALLOWED,
HELPER_CLASS_OPT,
Messages.getMessage("optionHelper00")),
new CLOptionDescriptor("user",
CLOptionDescriptor.ARGUMENT_REQUIRED,
USERNAME_OPT,
Messages.getMessage("optionUsername")),
new CLOptionDescriptor("password",
CLOptionDescriptor.ARGUMENT_REQUIRED,
PASSWORD_OPT,
Messages.getMessage("optionPassword"))
};
protected WSDL2Java()
{
emitter = (Emitter)parser;
addOptions(options);
}
protected Parser createParser()
{
return new Emitter();
}
protected void parseOption(CLOption option)
{
switch (option.getId())
{
case FACTORY_CLASS_OPT:
emitter.setFactory(option.getArgument());
break;
case HELPER_CLASS_OPT:
emitter.setHelperWanted(true);
break;
case SKELETON_DEPLOY_OPT:
emitter.setSkeletonWanted(JavaUtils.isTrueExplicitly(option.getArgument(0)));
case SERVER_OPT:
emitter.setServerSide(true);
break;
case NAMESPACE_OPT:
String namespace = option.getArgument(0);
String packageName = option.getArgument(1);
emitter.getNamespaceMap().put(namespace, packageName);
break;
case NAMESPACE_FILE_OPT:
emitter.setNStoPkg(option.getArgument());
break;
case PACKAGE_OPT:
bPackageOpt = true;
emitter.setPackageName(option.getArgument());
break;
case OUTPUT_OPT:
emitter.setOutputDir(option.getArgument());
break;
case SCOPE_OPT:
String arg = option.getArgument();
Scope scope = Scope.getScope(arg, null);
if (scope != null)
{
emitter.setScope(scope);
}
else
{
System.err.println(Messages.getMessage("badScope00", arg));
}
break;
case TEST_OPT:
emitter.setTestCaseWanted(true);
break;
case ALL_OPT:
emitter.setAllWanted(true);
break;
case TYPEMAPPING_OPT:
String tmValue = option.getArgument();
if (tmValue.equals("1.1"))
{
emitter.setTypeMappingVersion("1.1");
}
else if (tmValue.equals("1.2"))
{
emitter.setTypeMappingVersion("1.2");
}
else
{
System.out.println(Messages.getMessage("badTypeMappingOption00"));
}
break;
case USERNAME_OPT:
emitter.setUsername(option.getArgument());
break;
case PASSWORD_OPT:
emitter.setPassword(option.getArgument());
break;
default:
super.parseOption(option);
}
}
protected void validateOptions()
{
super.validateOptions();
if (emitter.isSkeletonWanted() && !emitter.isServerSide())
{
System.out.println(Messages.getMessage("badSkeleton00"));
printUsage();
}
if (!emitter.getNamespaceMap().isEmpty() && bPackageOpt)
{
System.out.println(Messages.getMessage("badpackage00"));
printUsage();
}
}
public static void main(String args[])
{
WSDL2Java wsdl2java = new WSDL2Java();
wsdl2java.run(args);
}
}