Search in sources :

Example 1 with ServiceDescriptor

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());
}
Also used : ApplicationDescriptor(org.qi4j.api.structure.ApplicationDescriptor) EntityDescriptor(org.qi4j.api.entity.EntityDescriptor) ServiceDescriptor(org.qi4j.api.service.ServiceDescriptor) Test(org.junit.Test)

Example 2 with ServiceDescriptor

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());
    }
}
Also used : EntityDescriptor(org.qi4j.api.entity.EntityDescriptor) ServiceDescriptor(org.qi4j.api.service.ServiceDescriptor) ImportedServiceDescriptor(org.qi4j.api.service.ImportedServiceDescriptor) ValueDescriptor(org.qi4j.api.value.ValueDescriptor) CompositeDescriptor(org.qi4j.api.composite.CompositeDescriptor) ObjectDescriptor(org.qi4j.api.object.ObjectDescriptor)

Aggregations

EntityDescriptor (org.qi4j.api.entity.EntityDescriptor)2 ServiceDescriptor (org.qi4j.api.service.ServiceDescriptor)2 Test (org.junit.Test)1 CompositeDescriptor (org.qi4j.api.composite.CompositeDescriptor)1 ObjectDescriptor (org.qi4j.api.object.ObjectDescriptor)1 ImportedServiceDescriptor (org.qi4j.api.service.ImportedServiceDescriptor)1 ApplicationDescriptor (org.qi4j.api.structure.ApplicationDescriptor)1 ValueDescriptor (org.qi4j.api.value.ValueDescriptor)1