use of org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory.AbsModuleGeneratedObjectFactory in project controller by opendaylight.
the class AbsModuleGeneratedObjectFactoryTest method parseGeneratedFile.
private void parseGeneratedFile(ModuleMXBeanEntry moduleMXBeanEntry) throws IOException {
Optional<String> copyright = Optional.absent();
GeneratedObject generatedObject = new AbsModuleGeneratedObjectFactory().toGeneratedObject(moduleMXBeanEntry, copyright);
Entry<FullyQualifiedName, File> entry = generatedObject.persist(generatorOutputPath).get();
File dstFile = entry.getValue();
parse(dstFile);
}
use of org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory.AbsModuleGeneratedObjectFactory 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