use of org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor in project qi4j-sdk by Qi4j.
the class VisitableDetailTest method visit.
@Test
public void visit() throws AssemblyException, ActivationException {
ApplicationDescriptor application = new Energy4Java().newApplicationModel(new ApplicationAssembler() {
@Override
public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
ApplicationAssembly app = applicationFactory.newApplicationAssembly();
app.setName("UnderTestApp");
app.withActivators(ApplicationActivator.class);
LayerAssembly layer = app.layer("LayerName");
layer.withActivators(LayerActivator.class);
ModuleAssembly module = layer.module("ModuleName");
module.withActivators(ModuleActivator.class);
return app;
}
});
ApplicationDetailDescriptor detail = createApplicationDetailDescriptor(application);
Visitor visitor = new Visitor();
detail.accept(visitor);
assertThat(visitor.events, equalTo(Arrays.asList(// Application
"visitEnter( UnderTestApp )", "visit( " + ApplicationActivator.class.getName() + " )", // Layer
"visitEnter( LayerName )", "visit( " + LayerActivator.class.getName() + " )", // Module
"visitEnter( ModuleName )", "visit( " + ModuleActivator.class.getName() + " )", // Leaving Structure
"visitLeave( ModuleName )", "visitLeave( LayerName )", "visitLeave( UnderTestApp )")));
}
use of org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor in project qi4j-sdk by Qi4j.
the class EntityViewer method initEntityCombo.
private void initEntityCombo(DefaultComboBoxModel entityComboModel) {
// create the visitor to traverse the QI4J to find the module
ApplicationDetailDescriptor visitor = ApplicationDetailDescriptorBuilder.createApplicationDetailDescriptor(model);
// find all entities
Iterable<LayerDetailDescriptor> layerDescIter = visitor.layers();
for (LayerDetailDescriptor layerDesc : layerDescIter) {
Iterable<ModuleDetailDescriptor> moduleDescIter = layerDesc.modules();
for (ModuleDetailDescriptor moduleDesc : moduleDescIter) {
Iterable<EntityDetailDescriptor> entityDescIter = moduleDesc.entities();
for (EntityDetailDescriptor entity : entityDescIter) {
entityComboModel.addElement(entity);
}
}
}
}
use of org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor in project qi4j-sdk by Qi4j.
the class TreePanel method reload.
public void reload() {
// build the visitor which allow traverse qi4j model
ApplicationDetailDescriptor visitor = ApplicationDetailDescriptorBuilder.createApplicationDetailDescriptor(model);
DefaultTreeModel treeModel = new DefaultTreeModel(new TreeModelBuilder().build(visitor));
applicationTree.setModel(treeModel);
}
use of org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor in project qi4j-sdk by Qi4j.
the class ServiceUsageFinder method findServiceUsage.
public List<ServiceUsage> findServiceUsage(ServiceDetailDescriptor descriptor) {
usages = new ArrayList<ServiceUsage>();
this.descriptor = descriptor;
// traverse the appDescritor/model to find the usage
ApplicationDetailDescriptor appDescriptor = descriptor.module().layer().application();
collectUsage(appDescriptor);
return usages;
}
use of org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor in project qi4j-sdk by Qi4j.
the class ServiceConfigurationFinder method findConfigurationDescriptor.
public Object findConfigurationDescriptor(ServiceDetailDescriptor descriptor) {
Class<?> configType = descriptor.descriptor().configurationType();
if (configType == null) {
return null;
}
// traverse the appDescritor to find the configurationDescriptor
ApplicationDetailDescriptor appDescriptor = descriptor.module().layer().application();
Object obj = findConfigurationDescriptor(appDescriptor, configType);
if (obj == null) {
return null;
}
return obj;
}
Aggregations