Search in sources :

Example 26 with LayerAssembly

use of org.qi4j.bootstrap.LayerAssembly in project qi4j-sdk by Qi4j.

the class ForumAssembler method assemble.

@Override
public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
    ApplicationAssembly assembly = applicationFactory.newApplicationAssembly();
    assembly.setName("Forum");
    LayerAssembly configuration = assembly.layer("Configuration");
    {
        ModuleAssembly configModule = configuration.module("Configuration");
        configModule.entities(NeoConfiguration.class).visibleIn(Visibility.application);
        configModule.services(MemoryEntityStoreService.class);
        configModule.services(UuidIdentityGeneratorService.class);
        new OrgJsonValueSerializationAssembler().assemble(configModule);
    }
    LayerAssembly infrastructure = assembly.layer("Infrastructure").uses(configuration);
    {
        ModuleAssembly entityStore = infrastructure.module("EntityStore");
        entityStore.services(FileConfigurationService.class);
        entityStore.services(NeoEntityStoreService.class).visibleIn(Visibility.application);
        entityStore.services(UuidIdentityGeneratorService.class).visibleIn(Visibility.application);
        new OrgJsonValueSerializationAssembler().visibleIn(Visibility.application).withValuesModuleFinder(new Function<Application, Module>() {

            @Override
            public Module map(Application app) {
                return app.findModule("REST", "Values");
            }
        }).assemble(entityStore);
    }
    LayerAssembly data = assembly.layer("Data").uses(infrastructure);
    {
        ModuleAssembly forum = data.module("Forum");
        for (Class<?> dataClass : filter(hasModifier(Modifier.INTERFACE), filter(isAssignableFrom(EntityComposite.class), ClassScanner.findClasses(User.class)))) {
            forum.entities(dataClass).visibleIn(Visibility.application);
        }
    }
    LayerAssembly context = assembly.layer("Context").uses(data);
    {
        ModuleAssembly contexts = context.module("Context");
        for (Class<?> contextClass : filter(not(hasModifier(Modifier.INTERFACE)), ClassScanner.findClasses(Context.class))) {
            if (contextClass.getName().contains("$")) {
                contexts.transients(contextClass).visibleIn(Visibility.application);
            } else {
                contexts.objects(contextClass).visibleIn(Visibility.application);
            }
        }
        for (Class<?> valueClass : filter(isAssignableFrom(ValueComposite.class), ClassScanner.findClasses(Context.class))) {
            contexts.values(valueClass).visibleIn(Visibility.application);
        }
        contexts.services(EventsService.class);
        context.module("Domain events").values(DomainEventValue.class, ParameterValue.class).visibleIn(Visibility.application);
    }
    LayerAssembly services = assembly.layer("Service").uses(data);
    {
        ModuleAssembly bootstrap = services.module("Bootstrap");
        bootstrap.services(BootstrapData.class).identifiedBy("bootstrap").instantiateOnStartup();
    }
    LayerAssembly rest = assembly.layer("REST").uses(context, data);
    {
        ModuleAssembly values = rest.module("Values");
        {
            new ValueAssembler().assemble(values);
        }
        ModuleAssembly transformation = rest.module("Transformation");
        {
            new RestServerAssembler().assemble(transformation);
            transformation.objects(RequestReaderDelegator.class, ResponseWriterDelegator.class).visibleIn(Visibility.layer);
            new OrgJsonValueSerializationAssembler().assemble(transformation);
        }
        ModuleAssembly resources = rest.module("Resources");
        for (Class<?> resourceClass : ClassScanner.findClasses(RootResource.class)) {
            resources.objects(resourceClass).visibleIn(Visibility.layer);
        }
        ModuleAssembly restlet = rest.module("Restlet");
        restlet.objects(ForumRestlet.class);
        restlet.importedServices(CommandResult.class).setMetaInfo(new DomainCommandResult());
        restlet.importedServices(MetadataService.class);
    }
    return assembly;
}
Also used : MemoryEntityStoreService(org.qi4j.entitystore.memory.MemoryEntityStoreService) UuidIdentityGeneratorService(org.qi4j.spi.uuid.UuidIdentityGeneratorService) RootResource(org.qi4j.samples.forum.rest.resource.RootResource) EntityComposite(org.qi4j.api.entity.EntityComposite) User(org.qi4j.samples.forum.data.entity.User) ResponseWriterDelegator(org.qi4j.library.rest.server.restlet.ResponseWriterDelegator) BootstrapData(org.qi4j.samples.forum.service.BootstrapData) ApplicationAssembly(org.qi4j.bootstrap.ApplicationAssembly) DomainCommandResult(org.qi4j.samples.forum.domainevent.DomainCommandResult) LayerAssembly(org.qi4j.bootstrap.LayerAssembly) MetadataService(org.restlet.service.MetadataService) ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) FileConfigurationService(org.qi4j.library.fileconfig.FileConfigurationService) RequestReaderDelegator(org.qi4j.library.rest.server.restlet.RequestReaderDelegator) RestServerAssembler(org.qi4j.library.rest.server.assembler.RestServerAssembler) Module(org.qi4j.api.structure.Module) ValueAssembler(org.qi4j.library.rest.common.ValueAssembler) Application(org.qi4j.api.structure.Application) EventsService(org.qi4j.samples.forum.context.EventsService) ForumRestlet(org.qi4j.samples.forum.rest.ForumRestlet) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)

Example 27 with LayerAssembly

use of org.qi4j.bootstrap.LayerAssembly in project qi4j-sdk by Qi4j.

the class RentalApplicationAssembler method assemble.

@Override
public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
    ApplicationAssembly assembly = applicationFactory.newApplicationAssembly();
    assembly.setMode(mode);
    LayerAssembly webLayer = assembly.layer("WebLayer");
    new PagesModule().assemble(webLayer.module("PagesModule"));
    LayerAssembly domainLayer = assembly.layer("DomainLayer");
    new RentalModule().assemble(domainLayer.module("RentalModule"));
    LayerAssembly infraLayer = assembly.layer("InfraLayer");
    new StorageModule().assemble(infraLayer.module("StorageModule"));
    webLayer.uses(domainLayer);
    domainLayer.uses(infraLayer);
    return assembly;
}
Also used : ApplicationAssembly(org.qi4j.bootstrap.ApplicationAssembly) LayerAssembly(org.qi4j.bootstrap.LayerAssembly)

Example 28 with LayerAssembly

use of org.qi4j.bootstrap.LayerAssembly in project qi4j-sdk by Qi4j.

the class AppAssembler method assemble.

@Override
public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
    ApplicationAssembly appAss = applicationFactory.newApplicationAssembly();
    appAss.setName("SQL Support Sample");
    // Config
    LayerAssembly configLayer = appAss.layer("config");
    ModuleAssembly configModule = configLayer.module("config");
    {
        configModule.services(OrgJsonValueSerializationService.class).taggedWith(ValueSerialization.Formats.JSON);
        configModule.services(MemoryEntityStoreService.class).visibleIn(Visibility.module);
    // Use a PreferenceEntityStore instead if you want the configuration to be persistent
    // new PreferenceEntityStoreAssembler( Visibility.module ).assemble( configModule );
    }
    // Infra
    LayerAssembly infraLayer = appAss.layer("infra");
    ModuleAssembly persistenceModule = infraLayer.module("persistence");
    {
        persistenceModule.services(OrgJsonValueSerializationService.class).taggedWith(ValueSerialization.Formats.JSON);
        // SQL DataSource Service
        String dataSourceServiceIdentity = "postgresql-datasource-service";
        new DBCPDataSourceServiceAssembler().identifiedBy(dataSourceServiceIdentity).visibleIn(Visibility.module).withConfig(configModule, Visibility.application).assemble(persistenceModule);
        // SQL EntityStore DataSource and Service
        new DataSourceAssembler().withDataSourceServiceIdentity(dataSourceServiceIdentity).identifiedBy("postgresql-es-datasource").visibleIn(Visibility.module).withCircuitBreaker(DataSources.newDataSourceCircuitBreaker()).assemble(persistenceModule);
        new PostgreSQLEntityStoreAssembler().visibleIn(Visibility.application).withConfig(configModule, Visibility.application).assemble(persistenceModule);
        // SQL Index/Query DataSource and Service
        new DataSourceAssembler().withDataSourceServiceIdentity(dataSourceServiceIdentity).identifiedBy("postgresql-index-datasource").visibleIn(Visibility.module).withCircuitBreaker().assemble(persistenceModule);
        new PostgreSQLIndexQueryAssembler().visibleIn(Visibility.application).withConfig(configModule, Visibility.application).assemble(persistenceModule);
    }
    // App
    LayerAssembly appLayer = appAss.layer("app");
    ModuleAssembly domainModule = appLayer.module("domain");
    {
        domainModule.entities(PretextEntity.class);
    }
    // Uses
    infraLayer.uses(configLayer);
    appLayer.uses(infraLayer);
    return appAss;
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) DataSourceAssembler(org.qi4j.library.sql.assembly.DataSourceAssembler) PostgreSQLIndexQueryAssembler(org.qi4j.index.sql.assembly.PostgreSQLIndexQueryAssembler) ApplicationAssembly(org.qi4j.bootstrap.ApplicationAssembly) DBCPDataSourceServiceAssembler(org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler) PostgreSQLEntityStoreAssembler(org.qi4j.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler) LayerAssembly(org.qi4j.bootstrap.LayerAssembly)

Example 29 with LayerAssembly

use of org.qi4j.bootstrap.LayerAssembly in project qi4j-sdk by Qi4j.

the class QueryPerformanceTest method assemble.

@Override
public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
    ApplicationAssembly applicationAssembly = applicationFactory.newApplicationAssembly();
    LayerAssembly infra = createInfrastructureLayer(applicationAssembly);
    LayerAssembly domain = createDomainLayer(applicationAssembly);
    LayerAssembly config = createConfigurationLayer(applicationAssembly);
    infra.uses(config);
    domain.uses(infra);
    return applicationAssembly;
}
Also used : ApplicationAssembly(org.qi4j.bootstrap.ApplicationAssembly) LayerAssembly(org.qi4j.bootstrap.LayerAssembly)

Example 30 with LayerAssembly

use of org.qi4j.bootstrap.LayerAssembly in project qi4j-sdk by Qi4j.

the class QueryPerformanceTest method createInfrastructureLayer.

private LayerAssembly createInfrastructureLayer(ApplicationAssembly applicationAssembly) throws AssemblyException {
    LayerAssembly infrastructureLayer = applicationAssembly.layer(LAYER_INFRASTRUCTURE);
    // Persistence module
    ModuleAssembly persistenceModule = infrastructureLayer.module(MODULE_PERSISTENCE);
    // Indexing
    new RdfNativeSesameStoreAssembler().assemble(persistenceModule);
    // Entity store
    new OrgJsonValueSerializationAssembler().assemble(persistenceModule);
    new MemoryEntityStoreAssembler().visibleIn(Visibility.application).assemble(persistenceModule);
    return infrastructureLayer;
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) RdfNativeSesameStoreAssembler(org.qi4j.index.rdf.assembly.RdfNativeSesameStoreAssembler) MemoryEntityStoreAssembler(org.qi4j.entitystore.memory.MemoryEntityStoreAssembler) LayerAssembly(org.qi4j.bootstrap.LayerAssembly) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)

Aggregations

LayerAssembly (org.qi4j.bootstrap.LayerAssembly)31 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)16 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)15 AssemblyException (org.qi4j.bootstrap.AssemblyException)5 Test (org.junit.Test)4 Application (org.qi4j.api.structure.Application)4 ApplicationAssembler (org.qi4j.bootstrap.ApplicationAssembler)4 ApplicationAssemblyFactory (org.qi4j.bootstrap.ApplicationAssemblyFactory)4 Energy4Java (org.qi4j.bootstrap.Energy4Java)4 ApplicationDescriptor (org.qi4j.api.structure.ApplicationDescriptor)3 HashMap (java.util.HashMap)2 OrgJsonValueSerializationAssembler (org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ActivationEventListener (org.qi4j.api.activation.ActivationEventListener)1 EntityComposite (org.qi4j.api.entity.EntityComposite)1 Layer (org.qi4j.api.structure.Layer)1 LayerDescriptor (org.qi4j.api.structure.LayerDescriptor)1 Module (org.qi4j.api.structure.Module)1 Assembler (org.qi4j.bootstrap.Assembler)1