LOG.log(Level.FINE, msg.toString(), e);
if (opts != null) {
String pluginUsage = getPluginUsageString(opts);
msg.append(System.getProperty("line.separator"));
if (args.contains("-X")) {
throw new ToolException(pluginUsage, e);
} else {
msg.append(pluginUsage);
}
}
throw new ToolException(msg.toString(), e);
}
}
if (context.optionSet(ToolConstants.CFG_MARK_GENERATED)) {
// Add the @Generated annotation in the Java files generated. This is done by passing
// '-mark-generated' attribute to jaxb xjc.
try {
opts.parseArgument(new String[] {"-mark-generated" }, 0);
} catch (BadCommandLineException e) {
LOG.log(Level.SEVERE, e.getMessage());
throw new ToolException(e);
}
}
addSchemas(opts, schemaCompiler, schemas);
addBindingFiles(opts, jaxbBindings, schemas);
for (String ns : context.getNamespacePackageMap().keySet()) {
File file = JAXBUtils.getPackageMappingSchemaBindingFile(ns, context.mapPackageName(ns));
try {
InputSource ins = new InputSource(file.toURI().toString());
schemaCompiler.parseSchema(ins);
} finally {
FileUtils.delete(file);
}
}
if (context.getPackageName() != null) {
schemaCompiler.setDefaultPackageName(context.getPackageName());
}
rawJaxbModelGenCode = schemaCompiler.bind();
addedEnumClassToCollector(schemas, allocator);
if (context.get(ToolConstants.CFG_DEFAULT_VALUES) != null) {
String cname = (String)context.get(ToolConstants.CFG_DEFAULT_VALUES);
if (StringUtils.isEmpty(cname)) {
defaultValues = new RandomValueProvider();
} else {
if (cname.charAt(0) == '=') {
cname = cname.substring(1);
}
try {
defaultValues = (DefaultValueProvider)Class.forName(cname).newInstance();
} catch (Exception e) {
LOG.log(Level.SEVERE, e.getMessage());
throw new ToolException(e);
}
}
}
initialized = true;