Search in sources :

Example 1 with GenericGeneratedObjectFactory

use of org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory.GenericGeneratedObjectFactory in project controller by opendaylight.

the class CodeWriter method writeSie.

public File writeSie(final ServiceInterfaceEntry sie, final File outputBaseDir) {
    try {
        GeneralInterfaceTemplate generalInterfaceTemplate = TemplateFactory.serviceInterfaceFromSie(sie);
        GeneratedObject go = new GenericGeneratedObjectFactory().toGeneratedObject(generalInterfaceTemplate, COPYRIGHT);
        return go.persist(outputBaseDir).get().getValue();
    } catch (Exception e) {
        String message = "An error occurred during Service interface generating, sie:" + sie.getTypeName() + ", " + sie.getFullyQualifiedName();
        LOG.error(message, e);
        throw new RuntimeException(message, e);
    }
}
Also used : GeneralInterfaceTemplate(org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.GeneralInterfaceTemplate) GeneratedObject(org.opendaylight.controller.config.yangjmxgenerator.plugin.java.GeneratedObject) GenericGeneratedObjectFactory(org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory.GenericGeneratedObjectFactory) IOException(java.io.IOException)

Example 2 with GenericGeneratedObjectFactory

use of org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory.GenericGeneratedObjectFactory in project controller by opendaylight.

the class CodeWriter method writeMbe.

public List<File> writeMbe(final ModuleMXBeanEntry mbe, final File targetBaseDir, final File mainBaseDir) {
    try {
        List<File> generatedFiles = Lists.newArrayList();
        Map<GeneratedObject, Boolean> /*overwrite*/
        gos = new HashMap<>();
        // generate mx interface and abstract factory
        // TOs
        Map<String, GeneralClassTemplate> tosFromMbe = TemplateFactory.tOsFromMbe(mbe);
        for (GeneralClassTemplate template : tosFromMbe.values()) {
            gos.put(new GenericGeneratedObjectFactory().toGeneratedObject(template, COPYRIGHT), true);
        }
        // MXBean interface
        GeneralInterfaceTemplate ifcTemplate = TemplateFactory.mXBeanInterfaceTemplateFromMbe(mbe);
        gos.put(new GenericGeneratedObjectFactory().toGeneratedObject(ifcTemplate, COPYRIGHT), true);
        // generate abstract factory
        gos.put(new AbsFactoryGeneratedObjectFactory().toGeneratedObject(mbe, COPYRIGHT), true);
        // generate abstract module
        gos.put(new AbsModuleGeneratedObjectFactory().toGeneratedObject(mbe, COPYRIGHT), true);
        // generate concrete factory
        StubFactoryTemplate concreteFactory = TemplateFactory.stubFactoryTemplateFromMbe(mbe);
        gos.put(new GenericGeneratedObjectFactory().toGeneratedObject(concreteFactory, COPYRIGHT), false);
        // generate concrete module
        gos.put(new ConcreteModuleGeneratedObjectFactory().toGeneratedObject(mbe, COPYRIGHT, Optional.<String>absent()), false);
        // write runtime bean MXBeans and registrators
        List<FtlTemplate> allFtlFiles = getRuntimeBeanFtlTemplates(mbe.getRuntimeBeans());
        for (FtlTemplate template : allFtlFiles) {
            gos.put(new GenericGeneratedObjectFactory().toGeneratedObject(template, COPYRIGHT), true);
        }
        generatedFiles.addAll(persistGeneratedObjects(targetBaseDir, mainBaseDir, gos));
        // purge nulls
        for (Iterator<File> it = generatedFiles.iterator(); it.hasNext(); ) {
            if (it.next() == null) {
                it.remove();
            }
        }
        return generatedFiles;
    } catch (Exception e) {
        String message = "An error occurred during Module generating, mbe:" + mbe.getJavaNamePrefix();
        LOG.error(message, e);
        throw new RuntimeException(message, e);
    }
}
Also used : GeneralInterfaceTemplate(org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.GeneralInterfaceTemplate) HashMap(java.util.HashMap) GeneralClassTemplate(org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.GeneralClassTemplate) AbsFactoryGeneratedObjectFactory(org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory.AbsFactoryGeneratedObjectFactory) GenericGeneratedObjectFactory(org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory.GenericGeneratedObjectFactory) IOException(java.io.IOException) ConcreteModuleGeneratedObjectFactory(org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory.ConcreteModuleGeneratedObjectFactory) GeneratedObject(org.opendaylight.controller.config.yangjmxgenerator.plugin.java.GeneratedObject) StubFactoryTemplate(org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.StubFactoryTemplate) AbsModuleGeneratedObjectFactory(org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory.AbsModuleGeneratedObjectFactory) FtlTemplate(org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.FtlTemplate) RuntimeRegistratorFtlTemplate(org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.RuntimeRegistratorFtlTemplate) File(java.io.File)

Aggregations

IOException (java.io.IOException)2 GeneralInterfaceTemplate (org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.GeneralInterfaceTemplate)2 GenericGeneratedObjectFactory (org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory.GenericGeneratedObjectFactory)2 GeneratedObject (org.opendaylight.controller.config.yangjmxgenerator.plugin.java.GeneratedObject)2 File (java.io.File)1 HashMap (java.util.HashMap)1 FtlTemplate (org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.FtlTemplate)1 GeneralClassTemplate (org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.GeneralClassTemplate)1 RuntimeRegistratorFtlTemplate (org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.RuntimeRegistratorFtlTemplate)1 StubFactoryTemplate (org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.StubFactoryTemplate)1 AbsFactoryGeneratedObjectFactory (org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory.AbsFactoryGeneratedObjectFactory)1 AbsModuleGeneratedObjectFactory (org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory.AbsModuleGeneratedObjectFactory)1 ConcreteModuleGeneratedObjectFactory (org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory.ConcreteModuleGeneratedObjectFactory)1