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);
}
}
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);
}
}
Aggregations