All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hisrc.jsonix.execution.JsonixInvoker Maven / Gradle / Ivy

There is a newer version: 2.3.9
Show newest version
package org.hisrc.jsonix.execution;

import org.hisrc.jsonix.compilation.ModulesCompiler;
import org.hisrc.jsonix.compilation.ProgramWriter;
import org.hisrc.jsonix.configuration.ModulesConfiguration;
import org.hisrc.jsonix.configuration.ModulesConfigurationUnmarshaller;
import org.hisrc.jsonix.configuration.OutputConfiguration;
import org.hisrc.jsonix.context.DefaultJsonixContext;
import org.hisrc.jsonix.definition.Modules;
import org.hisrc.jsonix.settings.Settings;
import org.jvnet.jaxb2_commons.xjc.model.concrete.XJCCMInfoFactory;
import org.jvnet.jaxb2_commons.xml.bind.model.MModelInfo;

import com.sun.tools.xjc.model.Model;
import com.sun.tools.xjc.model.nav.NClass;
import com.sun.tools.xjc.model.nav.NType;

public class JsonixInvoker {

	public void execute(Settings settings, Model model,
			ProgramWriter programWriter) {

		final DefaultJsonixContext context = new DefaultJsonixContext();

		context.setLogLevel(settings.getLogLevel().asInt());

		final ModulesConfigurationUnmarshaller customizationHandler = new ModulesConfigurationUnmarshaller(
				context);

		final OutputConfiguration defaultOutputConfiguration = new OutputConfiguration(
				settings.getDefaultNaming().getName(),
				OutputConfiguration.STANDARD_FILE_NAME_PATTERN);

		final ModulesConfiguration modulesConfiguration = customizationHandler
				.unmarshal(model, defaultOutputConfiguration);

		final MModelInfo modelinfo = new XJCCMInfoFactory(model)
				.createModel();

		final Modules modules = modulesConfiguration.build(
				context, modelinfo);

		final ModulesCompiler modulesCompiler = new ModulesCompiler(
				modules);

		modulesCompiler.compile(programWriter);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy