File outDir = new File((String)context.get(WadlToolConstants.CFG_OUTPUTDIR));
String wadlURL = getAbsoluteWadlURL();
String wadl = readWadl(wadlURL);
SourceGenerator sg = new SourceGenerator();
sg.setBus(getBus());
boolean generateImpl = context.optionSet(WadlToolConstants.CFG_IMPL);
sg.setGenerateImplementation(generateImpl);
if (generateImpl) {
sg.setGenerateInterfaces(context.optionSet(WadlToolConstants.CFG_INTERFACE));
}
sg.setPackageName((String)context.get(WadlToolConstants.CFG_PACKAGENAME));
sg.setResourceName((String)context.get(WadlToolConstants.CFG_RESOURCENAME));
String wadlNs = (String)context.get(WadlToolConstants.CFG_WADL_NAMESPACE);
if (wadlNs != null) {
sg.setWadlNamespace(wadlNs);
}
sg.setSupportMultipleXmlReps(context.optionSet(WadlToolConstants.CFG_MULTIPLE_XML_REPS));
// set the base path
sg.setWadlPath(wadlURL);
CustomizationParser parser = new CustomizationParser(context);
parser.parse(context);
List<InputSource> bindingFiles = parser.getJaxbBindings();
sg.setBindingFiles(bindingFiles);
sg.setCompilerArgs(parser.getCompilerArgs());
List<InputSource> schemaPackageFiles = parser.getSchemaPackageFiles();
sg.setSchemaPackageFiles(schemaPackageFiles);
sg.setSchemaPackageMap(context.getNamespacePackageMap());
sg.setJavaTypeMap(DEFAULT_JAVA_TYPE_MAP);
sg.setSchemaTypeMap(getSchemaTypeMap());
sg.setMediaTypeMap(getMediaTypeMap());
sg.setGenerateEnums(context.optionSet(WadlToolConstants.CFG_GENERATE_ENUMS));
sg.setInheritResourceParams(context.optionSet(WadlToolConstants.CFG_INHERIT_PARAMS));
sg.setSkipSchemaGeneration(context.optionSet(WadlToolConstants.CFG_NO_TYPES));
boolean noVoidForEmptyResponses = context.optionSet(WadlToolConstants.CFG_NO_VOID_FOR_EMPTY_RESPONSES);
if (noVoidForEmptyResponses) {
sg.setUseVoidForEmptyResponses(false);
}
// generate
String codeType = context.optionSet(WadlToolConstants.CFG_TYPES)
? SourceGenerator.CODE_TYPE_GRAMMAR : SourceGenerator.CODE_TYPE_PROXY;
sg.generateSource(wadl, outDir, codeType);
// compile
if (context.optionSet(WadlToolConstants.CFG_COMPILE)) {
ClassCollector collector = createClassCollector();
List<String> generatedServiceClasses = sg.getGeneratedServiceClasses();
for (String className : generatedServiceClasses) {
int index = className.lastIndexOf(".");
collector.addServiceClassName(className.substring(0, index),
className.substring(index + 1),
className);
}
List<String> generatedTypeClasses = sg.getGeneratedTypeClasses();
for (String className : generatedTypeClasses) {
int index = className.lastIndexOf(".");
collector.addTypesClassName(className.substring(0, index),
className.substring(index + 1),
className);