use of org.qi4j.api.service.ServiceDescriptor in project qi4j-sdk by Qi4j.
the class ApplicationAssemblerTest method testApplicationAssembler.
@Test
public void testApplicationAssembler() throws AssemblyException {
Energy4Java is = new Energy4Java();
ApplicationDescriptor model = is.newApplicationModel(new ApplicationAssembler() {
@Override
public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
ApplicationAssembly assembly = applicationFactory.newApplicationAssembly();
LayerAssembly layer1 = assembly.layer("Layer1");
ModuleAssembly module = layer1.module("Module1");
module.services(TestService.class);
module.entities(TestEntity.class);
layer1.services(AssemblySpecifications.types(TestService.class)).instantiateOnStartup();
layer1.services(Specifications.<Object>TRUE()).visibleIn(Visibility.layer);
layer1.entities(Specifications.<Object>TRUE()).visibleIn(Visibility.application);
return assembly;
}
});
model.accept(new HierarchicalVisitorAdapter<Object, Object, RuntimeException>() {
@Override
public boolean visitEnter(Object visited) throws RuntimeException {
if (visited instanceof ServiceDescriptor) {
ServiceDescriptor serviceDescriptor = (ServiceDescriptor) visited;
Assert.assertTrue(serviceDescriptor.isInstantiateOnStartup());
Assert.assertTrue(serviceDescriptor.visibility() == Visibility.layer);
return false;
} else if (visited instanceof EntityDescriptor) {
EntityDescriptor entityDescriptor = (EntityDescriptor) visited;
Assert.assertTrue(entityDescriptor.visibility() == Visibility.application);
return false;
}
return true;
}
});
model.newInstance(is.spi());
}
use of org.qi4j.api.service.ServiceDescriptor in project qi4j-sdk by Qi4j.
the class PDFWriter method writeTypeGeneralPage.
private void writeTypeGeneralPage(Object objectDesciptor) {
setFont(header5Font, header5FontSize);
writeString("General: ", headerLineSpace);
setFont(normalFont, normalFontSize);
if (objectDesciptor instanceof ServiceDetailDescriptor) {
ServiceDescriptor descriptor = ((ServiceDetailDescriptor) objectDesciptor).descriptor();
writeString("- identity: " + descriptor.identity());
writeString("- class: " + descriptor.toString());
writeString("- visibility: " + descriptor.visibility().toString());
writeString("- startup: " + ((ServiceDetailDescriptor) objectDesciptor).descriptor().isInstantiateOnStartup());
} else if (objectDesciptor instanceof EntityDetailDescriptor) {
EntityDescriptor descriptor = ((EntityDetailDescriptor) objectDesciptor).descriptor();
writeString("- name: " + descriptor.toString());
writeString("- class: " + descriptor.toString());
writeString("- visibility: " + descriptor.visibility().toString());
} else if (objectDesciptor instanceof ValueDetailDescriptor) {
ValueDescriptor descriptor = ((ValueDetailDescriptor) objectDesciptor).descriptor();
writeString("- name: " + descriptor.toString());
writeString("- class: " + descriptor.toString());
writeString("- visibility: " + descriptor.visibility().toString());
} else if (objectDesciptor instanceof ObjectDetailDescriptor) {
ObjectDescriptor descriptor = ((ObjectDetailDescriptor) objectDesciptor).descriptor();
writeString("- name: " + descriptor.toString());
writeString("- class: " + descriptor.toString());
writeString("- visibility: " + descriptor.visibility().toString());
} else if (objectDesciptor instanceof CompositeDetailDescriptor) {
CompositeDescriptor descriptor = ((CompositeDetailDescriptor) objectDesciptor).descriptor();
writeString("- name: " + descriptor.toString());
writeString("- class: " + descriptor.toString());
writeString("- visibility: " + descriptor.visibility().toString());
}
}
Aggregations