com.sun.tools.xjc.BadCommandLineException Java Examples

The following examples show how to use com.sun.tools.xjc.BadCommandLineException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EjbPlugin.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void onActivated(Options options) throws BadCommandLineException {

	Thread.currentThread().setContextClassLoader(
			getClass().getClassLoader());

	super.onActivated(options);

	final FieldRendererFactory fieldRendererFactory = new FieldRendererFactory() {

		public FieldRenderer getList(JClass coreList) {
			return new UntypedListFieldRenderer(coreList);
		}
	};
	options.setFieldRendererFactory(fieldRendererFactory, this);
}
 
Example #2
Source File: EjbPlugin.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public int parseArgument(Options opt, String[] args, int start)
		throws BadCommandLineException, IOException {
	final int result = super.parseArgument(opt, args, start);

	for (int i = 0; i < args.length; i++) {
		if (args[i].length() != 0) {
			if (args[i].charAt(0) != '-') {
				if (args[i].endsWith(".jar")) {
					episodeURLs.add(new File(args[i]).toURI().toURL());
				}
			}
		}
	}
	return result;
}
 
Example #3
Source File: VisitorPlugin.java    From jaxb-visitor with Apache License 2.0 5 votes vote down vote up
@Override
public int parseArgument(Options opt, String[] args, int index) throws BadCommandLineException, IOException {
	
	// look for the visitor-package argument since we'll use this for package name for our generated code.
    String arg = args[index];
    if (arg.startsWith("-Xvisitor-package:")) {
        packageName = arg.split(":")[1];
        return 1;
    }
    if (arg.startsWith("-Xvisitor-includeType:")) {
        includeType = "true".equalsIgnoreCase(arg.split(":")[1]);
        return 1;
    }
    if (arg.equals("-Xvisitor-includeType")) {
        includeType = true;
        return 1;
    }
    if (arg.equals("-Xvisitor-noClasses")) {
        generateClasses = false;
        return 1;
    }
    if (arg.equals("-Xvisitor-noIdrefTraversal")) {
    	noIdrefTraversal = true;
        return 1;
    }
    return 0;
}
 
Example #4
Source File: JsonixPlugin.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public int parseArgument(Options opt, String[] args, int i)
		throws BadCommandLineException, IOException {

	final PartialCmdLineParser cmdLineParser = new PartialCmdLineParser(
			getSettings());
	try {
		return cmdLineParser.parseArgument(args, i);
	} catch (CmdLineException clex) {
		throw new BadCommandLineException("Error parsing arguments.", clex);
	}
}
 
Example #5
Source File: JsonixPlugin.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onActivated(Options opts) throws BadCommandLineException {
	final ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory();
	if (iLoggerFactory instanceof NOPLoggerFactory) {
		System.err
				.println("You seem to be using the NOP provider of the SLF4j logging facade. "
						+ "With this configuration, log messages will be completely suppressed. "
						+ "Please consider adding a SLF4j provider (for instance slf4j-simple) to enable logging.");
	}
}
 
Example #6
Source File: DummyXjcPlugin.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Override
public int parseArgument(Options opt, String[] args, int i)
    throws BadCommandLineException {
    int ret = 0;
    if (args[i].equals(DUMMY_ARG)) {
        ret = 1;
    }

    return ret;
}
 
Example #7
Source File: Driver.java    From mxjc with MIT License 5 votes vote down vote up
private static void _main( String[] args ) throws Exception {
    try {
        System.exit(run( args, System.out, System.out ));
    } catch (BadCommandLineException e) {
        // there was an error in the command line.
        // print usage and abort.
        if(e.getMessage()!=null) {
            System.out.println(e.getMessage());
            System.out.println();
        }

        usage(e.getOptions(),false);
        System.exit(-1);
    }
}
 
Example #8
Source File: DynamicCompiler.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute() throws IOException, BadCommandLineException {

		final Options options = createOptions();
		final JCodeModel codeModel = createCodeModel();
		final CodeWriter codeWriter = createCodeWriter();
		final ErrorReceiver errorReceiver = createErrorReceiver();
		execute(options, codeModel, codeWriter, errorReceiver);

	}
 
Example #9
Source File: DynamicCompiler.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Options createOptions() throws IOException, BadCommandLineException {
	final Options options = new Options();
	options.targetDir = targetDirectory;
	options.verbose = true;
	options.debugMode = false;
	options.setSchemaLanguage(Language.XMLSCHEMA);
	options.strictCheck = false;
	options.readOnly = false;
	options.compatibilityMode = Options.EXTENSION;
	// options.set

	if (schemas != null) {
		for (final File schema : schemas) {
			options.addGrammar(schema);
		}
	}

	if (bindings != null) {
		for (File binding : bindings) {
			options.addBindFile(binding);
		}
	}

	if (catalog != null) {
		options.addCatalog(catalog);
	}
	options.parseArguments(getArguments());
	return options;
}
 
Example #10
Source File: AlphaMInfoFactoryTest.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@BeforeClass
public static void createModel() throws BadCommandLineException,
		IOException {
	final String generateDirectory = "target/generated-sources/"
			+ AlphaMInfoFactoryTest.class.getPackage().getName();
	new File(generateDirectory).mkdirs();
	final URL schema = AlphaMInfoFactoryTest.class
			.getResource("schema.xsd");
	final URL binding = AlphaMInfoFactoryTest.class
			.getResource("binding.xjb");
	final String[] arguments = new String[] { "-xmlschema",
			schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
			generateDirectory, "-extension" };

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	Assert.assertNotNull(model);

	final XJCCMInfoFactory factory = new XJCCMInfoFactory(model);

	AlphaMInfoFactoryTest.MODEL_INFO = factory.createModel();

	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);

}
 
Example #11
Source File: AbstractParameterizablePlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Parses the arguments and injects values into the beans via properties.
 */
public int parseArgument(Options opt, String[] args, int start)
		throws BadCommandLineException, IOException {

	int consumed = 0;
	final String optionPrefix = "-" + getOptionName() + "-";
	final int optionPrefixLength = optionPrefix.length();

	final String arg = args[start];
	final int equalsPosition = arg.indexOf('=');

	if (arg.startsWith(optionPrefix) && equalsPosition > optionPrefixLength) {
		final String propertyName = arg.substring(optionPrefixLength,
				equalsPosition);

		final String value = arg.substring(equalsPosition + 1);
		consumed++;
		try {
			BeanUtils.setProperty(this, propertyName, value);
		} catch (Exception ex) {
			ex.printStackTrace();
			throw new BadCommandLineException("Error setting property ["
					+ propertyName + "], value [" + value + "].");
		}
	}
	return consumed;
}
 
Example #12
Source File: AbstractPlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onActivated(Options options) throws BadCommandLineException {
	super.onActivated(options);
	try {
		init(options);
	} catch (Exception ex) {
		throw new BadCommandLineException(
				"Could not initialize the plugin [" + getOptionName()
						+ "].", ex);
	}
}
 
Example #13
Source File: AbstractSpringConfigurablePlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void beforeRun(Outline outline, Options options) throws Exception {
	super.beforeRun(outline, options);
	final String[] configLocations = getConfigLocations();
	if (!ArrayUtils.isEmpty(configLocations)) {
		final String configLocationsString = ArrayUtils
				.toString(configLocations);
		logger.debug("Loading application context from ["
				+ configLocationsString + "].");
		try {
			applicationContext = new FileSystemXmlApplicationContext(
					configLocations, false);
			applicationContext.setClassLoader(Thread.currentThread()
					.getContextClassLoader());
			applicationContext.refresh();
			if (getAutowireMode() != AutowireCapableBeanFactory.AUTOWIRE_NO) {
				applicationContext.getBeanFactory().autowireBeanProperties(
						this, getAutowireMode(), isDependencyCheck());
			}
		} catch (Exception ex) {
			ex.printStackTrace();
			ex.getCause().printStackTrace();
			logger.error("Error loading applicaion context from ["
					+ configLocationsString + "].", ex);
			throw new BadCommandLineException(
					"Error loading  applicaion context from ["
							+ configLocationsString + "].", ex);
		}
	}
}
 
Example #14
Source File: JaxbValidationsPlugins.java    From krasa-jaxb-tools with Apache License 2.0 4 votes vote down vote up
@Override
public void onActivated(Options opts) throws BadCommandLineException {
	super.onActivated(opts);
}
 
Example #15
Source File: JaxbValidationsPlugins.java    From krasa-jaxb-tools with Apache License 2.0 4 votes vote down vote up
@Override
public int parseArgument(Options opt, String[] args, int i) throws BadCommandLineException, IOException {
	String arg1 = args[i];
	int consumed = 0;
	int indexOfNamespace = arg1.indexOf(TARGET_NAMESPACE_PARAMETER_NAME);
	if (indexOfNamespace > 0) {
		targetNamespace = arg1.substring(indexOfNamespace + TARGET_NAMESPACE_PARAMETER_NAME.length() + "=".length());
		consumed++;
	}

	int index = arg1.indexOf(JSR_349);
	if (index > 0) {
		jsr349 = Boolean.parseBoolean(arg1.substring(index + JSR_349.length() + "=".length()));
		consumed++;
	}

	int index_generateNotNullAnnotations = arg1.indexOf(GENERATE_NOT_NULL_ANNOTATIONS);
	if (index_generateNotNullAnnotations > 0) {
		notNullAnnotations = Boolean.parseBoolean(arg1.substring(index_generateNotNullAnnotations
				+ GENERATE_NOT_NULL_ANNOTATIONS.length() + "=".length()));
		consumed++;
	}

	int index_notNullCustomMessages = arg1.indexOf(NOT_NULL_ANNOTATIONS_CUSTOM_MESSAGES);
	if (index_notNullCustomMessages > 0) {
		String value = arg1.substring(index_notNullCustomMessages + NOT_NULL_ANNOTATIONS_CUSTOM_MESSAGES.length() + "=".length()).trim();
		notNullCustomMessages = Boolean.parseBoolean(value);
		if (!notNullCustomMessages) {
			if (value.equalsIgnoreCase("classname")) {
				notNullCustomMessages = notNullPrefixFieldName = notNullPrefixClassName = true;
			} else if (value.equalsIgnoreCase("fieldname")) {
				notNullCustomMessages = notNullPrefixFieldName = true;
			} else if (value.length() != 0 && !value.equalsIgnoreCase("false")) {
				notNullCustomMessage = value;
			}
		}
		consumed++;
	}

	int index_verbose = arg1.indexOf(VERBOSE);
	if (index_verbose > 0) {
		verbose = Boolean.parseBoolean(arg1.substring(index_verbose
				+ VERBOSE.length() + "=".length()));
		consumed++;
	}
	int index_generateJpaAnnotations = arg1.indexOf(GENERATE_JPA_ANNOTATIONS);
	if (index_generateJpaAnnotations > 0) {
		jpaAnnotations = Boolean.parseBoolean(arg1.substring(index_generateJpaAnnotations
				+ GENERATE_JPA_ANNOTATIONS.length() + "=".length()));
		consumed++;
	}

	int index_serviceValidationAnnotation = arg1.indexOf(GENERATE_SERVICE_VALIDATION_ANNOTATIONS);
	if (index_serviceValidationAnnotation > 0) {
		serviceValidationAnnotations = arg1.substring(index_serviceValidationAnnotation
				+ GENERATE_SERVICE_VALIDATION_ANNOTATIONS.length() + "=".length()).trim();
		consumed++;
	}

	return consumed;
}
 
Example #16
Source File: Driver.java    From mxjc with MIT License 4 votes vote down vote up
/** Parse XJC-specific options. */
public int parseArgument(String[] args, int i) throws BadCommandLineException {
    if (args[i].equals("-noNS")) {
        noNS = true;
        return 1;
    }
    if (args[i].equals("-mode")) {
        i++;
        if (i == args.length)
            throw new BadCommandLineException(
                Messages.format(Messages.MISSING_MODE_OPERAND));

        String mstr = args[i].toLowerCase();

        for( Mode m : Mode.values() ) {
            if(m.name().toLowerCase().startsWith(mstr) && mstr.length()>2) {
                mode = m;
                return 2;
            }
        }

        throw new BadCommandLineException(
            Messages.format(Messages.UNRECOGNIZED_MODE, args[i]));
    }
    
    if (args[i].equals("-nano")) {
    	module = ModuleName.NANO;
    	return 1;
    }
    
    if (args[i].equals("-pico")) {
    	module = ModuleName.PICO;
    	return 1;
    }
    
    if (args[i].equals("-privateField")) {
    	this.privateField = true;
    	return 1;
    }
    
    if (args[i].equals("-prefix")) {
    	prefix = super.requireArgument("-prefix", args, ++i);
    	return 2;
    }
    
    if (args[i].equals("-help")) {
        usage(this,false);
        throw new WeAreDone();
    }
    if (args[i].equals("-private")) {
        usage(this,true);
        throw new WeAreDone();
    }

    return super.parseArgument(args, i);
}
 
Example #17
Source File: OptionsFactory.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Creates and initializes an instance of XJC options.
 * 
 */
public Options createOptions(OptionsConfiguration optionsConfiguration)
		throws MojoExecutionException {
	final Options options = new Options();

	options.verbose = optionsConfiguration.isVerbose();
	options.debugMode = optionsConfiguration.isDebugMode();

	options.classpaths.addAll(optionsConfiguration.getPlugins());

	options.target = createSpecVersion(optionsConfiguration
			.getSpecVersion());

	final String encoding = optionsConfiguration.getEncoding();

	if (encoding != null) {
		options.encoding = createEncoding(encoding);
	}

	options.setSchemaLanguage(createLanguage(optionsConfiguration
			.getSchemaLanguage()));

	options.entityResolver = optionsConfiguration.getEntityResolver();

	for (InputSource grammar : optionsConfiguration.getGrammars()) {
		options.addGrammar(grammar);
	}

	for (InputSource bindFile : optionsConfiguration.getBindFiles()) {
		options.addBindFile(bindFile);
	}

	// Setup Other Options

	options.defaultPackage = optionsConfiguration.getGeneratePackage();
	options.targetDir = optionsConfiguration.getGenerateDirectory();

	options.strictCheck = optionsConfiguration.isStrict();
	options.readOnly = optionsConfiguration.isReadOnly();
	options.packageLevelAnnotations = optionsConfiguration
			.isPackageLevelAnnotations();
	options.noFileHeader = optionsConfiguration.isNoFileHeader();
	options.enableIntrospection = optionsConfiguration
			.isEnableIntrospection();
	options.disableXmlSecurity = optionsConfiguration
			.isDisableXmlSecurity();

	if (optionsConfiguration.getAccessExternalSchema() != null) {
		System.setProperty("javax.xml.accessExternalSchema",
				optionsConfiguration.getAccessExternalSchema());
	}
	if (optionsConfiguration.getAccessExternalDTD() != null) {
		System.setProperty("javax.xml.accessExternalDTD",
				optionsConfiguration.getAccessExternalDTD());
	}
	if (optionsConfiguration.isEnableExternalEntityProcessing()) {
		System.setProperty("enableExternalEntityProcessing", Boolean.TRUE.toString());
	}
	options.contentForWildcard = optionsConfiguration
			.isContentForWildcard();

	if (optionsConfiguration.isExtension()) {
		options.compatibilityMode = Options.EXTENSION;
	}

	final List<String> arguments = optionsConfiguration.getArguments();
	try {
		options.parseArguments(arguments.toArray(new String[arguments
				.size()]));
	}

	catch (BadCommandLineException bclex) {
		throw new MojoExecutionException("Error parsing the command line ["
				+ arguments + "]", bclex);
	}

	return options;
}
 
Example #18
Source File: GroupInterfacePlugin.java    From jaxb2-rich-contract-plugin with MIT License 4 votes vote down vote up
@Override
public void onActivated(final Options opts) throws BadCommandLineException {
	generateDummyGroupUsages(opts);
}
 
Example #19
Source File: OptionsFactory.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Creates and initializes an instance of XJC options.
 *
 */
public Options createOptions(OptionsConfiguration optionsConfiguration)
		throws MojoExecutionException {
	final Options options = new Options();

	options.verbose = optionsConfiguration.isVerbose();
	options.debugMode = optionsConfiguration.isDebugMode();

	options.classpaths.addAll(optionsConfiguration.getPlugins());

	options.setSchemaLanguage(createLanguage(optionsConfiguration
			.getSchemaLanguage()));

	options.entityResolver = optionsConfiguration.getEntityResolver();

	for (InputSource grammar : optionsConfiguration.getGrammars()) {
		options.addGrammar(grammar);
	}

	for (InputSource bindFile : optionsConfiguration.getBindFiles()) {
		options.addBindFile(bindFile);
	}

	// Setup Other Options

	options.defaultPackage = optionsConfiguration.getGeneratePackage();
	options.targetDir = optionsConfiguration.getGenerateDirectory();

	options.strictCheck = optionsConfiguration.isStrict();
	options.readOnly = optionsConfiguration.isReadOnly();
	options.packageLevelAnnotations = optionsConfiguration
			.isPackageLevelAnnotations();
	options.noFileHeader = optionsConfiguration.isNoFileHeader();
	// options.enableIntrospection =
	// optionsConfiguration.isEnableIntrospection();
	// options.disableXmlSecurity =
	// optionsConfiguration.isDisableXmlSecurity();
	if (optionsConfiguration.getAccessExternalSchema() != null) {
		System.setProperty("javax.xml.accessExternalSchema",
				optionsConfiguration.getAccessExternalSchema());
	}
	if (optionsConfiguration.getAccessExternalDTD() != null) {
		System.setProperty("javax.xml.accessExternalDTD",
				optionsConfiguration.getAccessExternalDTD());
	}
	if (optionsConfiguration.isEnableExternalEntityProcessing()) {
		System.setProperty("enableExternalEntityProcessing", Boolean.TRUE.toString());
	}
	// options.contentForWildcard =
	// optionsConfiguration.isContentForWildcard()

	if (optionsConfiguration.isExtension()) {
		options.compatibilityMode = Options.EXTENSION;
	}

	final List<String> arguments = optionsConfiguration.getArguments();
	try {
		options.parseArguments(arguments.toArray(new String[arguments
				.size()]));
	}

	catch (BadCommandLineException bclex) {
		throw new MojoExecutionException("Error parsing the command line ["
				+ arguments + "]", bclex);
	}

	return options;
}
 
Example #20
Source File: OptionsFactory.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Creates and initializes an instance of XJC options.
 *
 */
public Options createOptions(OptionsConfiguration optionsConfiguration)
		throws MojoExecutionException {
	final Options options = new Options();

	options.verbose = optionsConfiguration.isVerbose();
	options.debugMode = optionsConfiguration.isDebugMode();

	options.classpaths.addAll(optionsConfiguration.getPlugins());

	options.target = SpecVersion.V2_2;

	final String encoding = optionsConfiguration.getEncoding();

	if (encoding != null) {
		options.encoding = createEncoding(encoding);
	}

	options.setSchemaLanguage(createLanguage(optionsConfiguration
			.getSchemaLanguage()));

	options.entityResolver = optionsConfiguration.getEntityResolver();

	for (InputSource grammar : optionsConfiguration.getGrammars()) {
		options.addGrammar(grammar);
	}

	for (InputSource bindFile : optionsConfiguration.getBindFiles()) {
		options.addBindFile(bindFile);
	}

	// Setup Other Options

	options.defaultPackage = optionsConfiguration.getGeneratePackage();
	options.targetDir = optionsConfiguration.getGenerateDirectory();

	options.strictCheck = optionsConfiguration.isStrict();
	options.readOnly = optionsConfiguration.isReadOnly();
	options.packageLevelAnnotations = optionsConfiguration
			.isPackageLevelAnnotations();
	options.noFileHeader = optionsConfiguration.isNoFileHeader();
	options.enableIntrospection = optionsConfiguration
			.isEnableIntrospection();
	options.disableXmlSecurity = optionsConfiguration
			.isDisableXmlSecurity();
	if (optionsConfiguration.getAccessExternalSchema() != null) {
		System.setProperty("javax.xml.accessExternalSchema",
				optionsConfiguration.getAccessExternalSchema());
	}
	if (optionsConfiguration.getAccessExternalDTD() != null) {
		System.setProperty("javax.xml.accessExternalDTD",
				optionsConfiguration.getAccessExternalDTD());
	}
	if (optionsConfiguration.isEnableExternalEntityProcessing()) {
		System.setProperty("enableExternalEntityProcessing", Boolean.TRUE.toString());
	}
	options.contentForWildcard = optionsConfiguration
			.isContentForWildcard();

	if (optionsConfiguration.isExtension()) {
		options.compatibilityMode = Options.EXTENSION;
	}

	final List<String> arguments = optionsConfiguration.getArguments();
	try {
		options.parseArguments(arguments.toArray(new String[arguments
				.size()]));
	}

	catch (BadCommandLineException bclex) {
		throw new MojoExecutionException("Error parsing the command line ["
				+ arguments + "]", bclex);
	}

	return options;
}
 
Example #21
Source File: OptionsFactory.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Creates and initializes an instance of XJC options.
 *
 */
public Options createOptions(OptionsConfiguration optionsConfiguration)
		throws MojoExecutionException {
	final Options options = new Options();

	options.verbose = optionsConfiguration.isVerbose();
	options.debugMode = optionsConfiguration.isDebugMode();

	options.classpaths.addAll(optionsConfiguration.getPlugins());

	options.target = SpecVersion.V2_2;

	final String encoding = optionsConfiguration.getEncoding();

	if (encoding != null) {
		options.encoding = createEncoding(encoding);
	}

	options.setSchemaLanguage(createLanguage(optionsConfiguration
			.getSchemaLanguage()));

	options.entityResolver = optionsConfiguration.getEntityResolver();

	for (InputSource grammar : optionsConfiguration.getGrammars()) {
		options.addGrammar(grammar);
	}

	for (InputSource bindFile : optionsConfiguration.getBindFiles()) {
		options.addBindFile(bindFile);
	}

	// Setup Other Options

	options.defaultPackage = optionsConfiguration.getGeneratePackage();
	options.targetDir = optionsConfiguration.getGenerateDirectory();

	options.strictCheck = optionsConfiguration.isStrict();
	options.readOnly = optionsConfiguration.isReadOnly();
	options.packageLevelAnnotations = optionsConfiguration
			.isPackageLevelAnnotations();
	options.noFileHeader = optionsConfiguration.isNoFileHeader();
	options.enableIntrospection = optionsConfiguration
			.isEnableIntrospection();
	options.disableXmlSecurity = optionsConfiguration
			.isDisableXmlSecurity();
	if (optionsConfiguration.getAccessExternalSchema() != null) {
		System.setProperty("javax.xml.accessExternalSchema",
				optionsConfiguration.getAccessExternalSchema());
	}
	if (optionsConfiguration.getAccessExternalDTD() != null) {
		System.setProperty("javax.xml.accessExternalDTD",
				optionsConfiguration.getAccessExternalDTD());
	}
	if (optionsConfiguration.isEnableExternalEntityProcessing()) {
		System.setProperty("enableExternalEntityProcessing", Boolean.TRUE.toString());
	}
	options.contentForWildcard = optionsConfiguration
			.isContentForWildcard();

	if (optionsConfiguration.isExtension()) {
		options.compatibilityMode = Options.EXTENSION;
	}

	final List<String> arguments = optionsConfiguration.getArguments();
	try {
		options.parseArguments(arguments.toArray(new String[arguments
				.size()]));
	}

	catch (BadCommandLineException bclex) {
		throw new MojoExecutionException("Error parsing the command line ["
				+ arguments + "]", bclex);
	}

	return options;
}
 
Example #22
Source File: ConnectPlugin.java    From kafka-connect-transform-xml with Apache License 2.0 4 votes vote down vote up
@Override
public int parseArgument(Options opt, String[] args, int i)
    throws BadCommandLineException, IOException {
  return 1;
}
 
Example #23
Source File: OptionsFactory.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Creates and initializes an instance of XJC options.
 *
 */
public Options createOptions(OptionsConfiguration optionsConfiguration)
		throws MojoExecutionException {
	final Options options = new Options();

	options.verbose = optionsConfiguration.isVerbose();
	options.debugMode = optionsConfiguration.isDebugMode();

	options.classpaths.addAll(optionsConfiguration.getPlugins());

	options.target = SpecVersion.V2_1;

	options.setSchemaLanguage(createLanguage(optionsConfiguration
			.getSchemaLanguage()));

	options.entityResolver = optionsConfiguration.getEntityResolver();

	for (InputSource grammar : optionsConfiguration.getGrammars()) {
		options.addGrammar(grammar);
	}

	for (InputSource bindFile : optionsConfiguration.getBindFiles()) {
		options.addBindFile(bindFile);
	}

	// Setup Other Options

	options.defaultPackage = optionsConfiguration.getGeneratePackage();
	options.targetDir = optionsConfiguration.getGenerateDirectory();

	options.strictCheck = optionsConfiguration.isStrict();
	options.readOnly = optionsConfiguration.isReadOnly();
	options.packageLevelAnnotations = optionsConfiguration
			.isPackageLevelAnnotations();
	options.noFileHeader = optionsConfiguration.isNoFileHeader();
	options.enableIntrospection = optionsConfiguration
			.isEnableIntrospection();
	// options.disableXmlSecurity =
	// optionsConfiguration.isDisableXmlSecurity();
	if (optionsConfiguration.getAccessExternalSchema() != null) {
		System.setProperty("javax.xml.accessExternalSchema",
				optionsConfiguration.getAccessExternalSchema());
	}
	if (optionsConfiguration.getAccessExternalDTD() != null) {
		System.setProperty("javax.xml.accessExternalDTD",
				optionsConfiguration.getAccessExternalDTD());
	}
	if (optionsConfiguration.isEnableExternalEntityProcessing()) {
		System.setProperty("enableExternalEntityProcessing", Boolean.TRUE.toString());
	}
	options.contentForWildcard = optionsConfiguration
			.isContentForWildcard();

	if (optionsConfiguration.isExtension()) {
		options.compatibilityMode = Options.EXTENSION;
	}

	final List<String> arguments = optionsConfiguration.getArguments();
	try {
		options.parseArguments(arguments.toArray(new String[arguments
				.size()]));
	}

	catch (BadCommandLineException bclex) {
		throw new MojoExecutionException("Error parsing the command line ["
				+ arguments + "]", bclex);
	}

	return options;
}
 
Example #24
Source File: EjbPlugin.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected void beforeRun(Outline outline, Options options) throws Exception {
	super.beforeRun(outline, options);

	if (getModelAndOutlineProcessor() == null) {
		try {
			final Object bean = getApplicationContext().getBean(
					getModelAndOutlineProcessorBeanName());
			if (!(bean instanceof ModelAndOutlineProcessor)) {
				throw new BadCommandLineException("Result bean ["
						+ getModelAndOutlineProcessorBeanName()
						+ "] of class [" + bean.getClass()
						+ "] does not implement ["
						+ ModelAndOutlineProcessor.class.getName()
						+ "] interface.");
			} else {
				@SuppressWarnings("unchecked")
				final ModelAndOutlineProcessor<EjbPlugin> modelAndOutlineProcessor = (ModelAndOutlineProcessor<EjbPlugin>) bean;
				setModelAndOutlineProcessor(modelAndOutlineProcessor);
			}

		} catch (BeansException bex) {
			throw new BadCommandLineException(
					"Could not load variant bean ["
							+ getModelAndOutlineProcessorBeanName() + "].",
					bex);
		}
	}

	if (getNaming() == null) {
		setNaming((Naming) getApplicationContext().getBean("naming",
				Naming.class));
	}

	if (getMapping() == null) {
		setMapping((Mapping) getApplicationContext().getBean("mapping",
				Mapping.class));
	}

	if (getTargetDir() == null) {
		setTargetDir(options.targetDir);
	}
}
 
Example #25
Source File: ConnectPlugin.java    From kafka-connect-transform-xml with Apache License 2.0 4 votes vote down vote up
@Override
public void onActivated(Options opts) throws BadCommandLineException {
  super.onActivated(opts);
  log.info("onActivated");

}