Search in sources :

Example 41 with Application

use of org.qi4j.api.structure.Application in project qi4j-sdk by Qi4j.

the class Qi95IssueTest method canCreateAndQueryWithNativeRdfAndJdbm.

@Test
public void canCreateAndQueryWithNativeRdfAndJdbm() throws Exception {
    Application application = createApplication(nativeRdf, jdbmStore, domain);
    try {
        application.activate();
        Module domain = application.findModule("Domain", "Domain");
        UnitOfWorkFactory unitOfWorkFactory = domain;
        createABunchOfStuffAndDoQueries(unitOfWorkFactory, domain);
    } finally {
        application.passivate();
    }
}
Also used : UnitOfWorkFactory(org.qi4j.api.unitofwork.UnitOfWorkFactory) Module(org.qi4j.api.structure.Module) Application(org.qi4j.api.structure.Application) Test(org.junit.Test)

Example 42 with Application

use of org.qi4j.api.structure.Application in project qi4j-sdk by Qi4j.

the class Main method main.

public static void main(String[] args) throws Exception {
    Energy4Java qi4j = new Energy4Java();
    // Instantiate the Application Model.
    Application application = qi4j.newApplication(new ApplicationAssembler() {

        @Override
        public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
            return applicationFactory.newApplicationAssembly(new MyAssembler());
        }
    });
    application.activate();
}
Also used : Application(org.qi4j.api.structure.Application)

Example 43 with Application

use of org.qi4j.api.structure.Application in project qi4j-sdk by Qi4j.

the class Assembler method assembleInfrastructureLayer.

private void assembleInfrastructureLayer(LayerAssembly infrastructureLayer) throws AssemblyException {
    ModuleAssembly serializationModule = infrastructureLayer.module("INFRASTRUCTURE-Serialization");
    serializationModule.services(OrgJsonValueSerializationService.class).taggedWith(ValueSerialization.Formats.JSON).setMetaInfo(new Function<Application, Module>() {

        @Override
        public Module map(Application application) {
            return application.findModule("CONTEXT", "CONTEXT-ContextSupport");
        }
    }).visibleIn(application);
    ModuleAssembly indexingModule = infrastructureLayer.module("INFRASTRUCTURE-Indexing");
    indexingModule.objects(EntityStateSerializer.class, EntityTypeSerializer.class);
    indexingModule.addServices(MemoryRepositoryService.class, RdfIndexingEngineService.class).instantiateOnStartup().visibleIn(application);
    ModuleAssembly entityStoreModule = infrastructureLayer.module("INFRASTRUCTURE-EntityStore");
    entityStoreModule.addServices(MemoryEntityStoreService.class, UuidIdentityGeneratorService.class).instantiateOnStartup().visibleIn(application);
    ModuleAssembly externalServiceModule = infrastructureLayer.module("INFRASTRUCTURE-ExternalService");
    externalServiceModule.importedServices(GraphTraversalService.class).setMetaInfo(new GraphTraversalServiceImpl(new GraphDAO())).visibleIn(application);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) Function(org.qi4j.functional.Function) OrgJsonValueSerializationService(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationService) GraphTraversalServiceImpl(org.qi4j.sample.dcicargo.pathfinder_a.internal.GraphTraversalServiceImpl) Application(org.qi4j.api.structure.Application) GraphDAO(org.qi4j.sample.dcicargo.pathfinder_a.internal.GraphDAO)

Example 44 with Application

use of org.qi4j.api.structure.Application in project qi4j-sdk by Qi4j.

the class Assembler method assembleInfrastructureLayer.

private void assembleInfrastructureLayer(LayerAssembly infrastructureLayer) throws AssemblyException {
    ModuleAssembly serializationModule = infrastructureLayer.module("INFRASTRUCTURE-Serialization");
    serializationModule.services(OrgJsonValueSerializationService.class).taggedWith(ValueSerialization.Formats.JSON).setMetaInfo(new Function<Application, Module>() {

        @Override
        public Module map(Application application) {
            return application.findModule("CONTEXT", "CONTEXT-RoleMap");
        }
    }).visibleIn(application);
    ModuleAssembly indexingModule = infrastructureLayer.module("INFRASTRUCTURE-Indexing");
    indexingModule.objects(EntityStateSerializer.class, EntityTypeSerializer.class);
    indexingModule.services(MemoryRepositoryService.class, RdfIndexingEngineService.class).instantiateOnStartup().visibleIn(application);
    ModuleAssembly entityStoreModule = infrastructureLayer.module("INFRASTRUCTURE-EntityStore");
    entityStoreModule.services(MemoryEntityStoreService.class, UuidIdentityGeneratorService.class).instantiateOnStartup().visibleIn(application);
    ModuleAssembly externalServiceModule = infrastructureLayer.module("INFRASTRUCTURE-ExternalService");
    externalServiceModule.importedServices(GraphTraversalService.class).setMetaInfo(new GraphTraversalServiceImpl(new GraphDAO())).visibleIn(application);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) Function(org.qi4j.functional.Function) OrgJsonValueSerializationService(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationService) GraphTraversalServiceImpl(org.qi4j.sample.dcicargo.pathfinder_b.internal.GraphTraversalServiceImpl) Application(org.qi4j.api.structure.Application) GraphDAO(org.qi4j.sample.dcicargo.pathfinder_b.internal.GraphDAO)

Example 45 with Application

use of org.qi4j.api.structure.Application in project qi4j-sdk by Qi4j.

the class TestAssembler method assembleInfrastructureLayer.

private void assembleInfrastructureLayer(LayerAssembly infrastructureLayer) throws AssemblyException {
    ModuleAssembly serializationModule = infrastructureLayer.module("INFRASTRUCTURE-Serialization");
    serializationModule.services(OrgJsonValueSerializationService.class).taggedWith(ValueSerialization.Formats.JSON).setMetaInfo(new Function<Application, Module>() {

        @Override
        public Module map(Application application) {
            return application.findModule("CONTEXT", "CONTEXT-ContextSupport");
        }
    }).visibleIn(application);
    ModuleAssembly indexingModule = infrastructureLayer.module("INFRASTRUCTURE-Indexing");
    indexingModule.objects(EntityStateSerializer.class, EntityTypeSerializer.class);
    indexingModule.addServices(MemoryRepositoryService.class, RdfIndexingEngineService.class).visibleIn(application);
    ModuleAssembly entityStoreModule = infrastructureLayer.module("INFRASTRUCTURE-EntityStore");
    entityStoreModule.addServices(MemoryEntityStoreService.class, UuidIdentityGeneratorService.class).visibleIn(application);
    ModuleAssembly externalServiceModule = infrastructureLayer.module("INFRASTRUCTURE-ExternalService");
    externalServiceModule.importedServices(GraphTraversalService.class).setMetaInfo(new GraphTraversalServiceImpl(new GraphDAO())).visibleIn(application);
}
Also used : MemoryEntityStoreService(org.qi4j.entitystore.memory.MemoryEntityStoreService) UuidIdentityGeneratorService(org.qi4j.spi.uuid.UuidIdentityGeneratorService) ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) Function(org.qi4j.functional.Function) OrgJsonValueSerializationService(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationService) RdfIndexingEngineService(org.qi4j.index.rdf.RdfIndexingEngineService) GraphTraversalServiceImpl(org.qi4j.sample.dcicargo.pathfinder_a.internal.GraphTraversalServiceImpl) MemoryRepositoryService(org.qi4j.library.rdf.repository.MemoryRepositoryService) Application(org.qi4j.api.structure.Application) GraphDAO(org.qi4j.sample.dcicargo.pathfinder_a.internal.GraphDAO)

Aggregations

Application (org.qi4j.api.structure.Application)50 Test (org.junit.Test)32 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)26 Module (org.qi4j.api.structure.Module)18 Energy4Java (org.qi4j.bootstrap.Energy4Java)18 Assembler (org.qi4j.bootstrap.Assembler)13 ApplicationAssemblerAdapter (org.qi4j.bootstrap.ApplicationAssemblerAdapter)10 SingletonAssembler (org.qi4j.bootstrap.SingletonAssembler)10 AssemblyException (org.qi4j.bootstrap.AssemblyException)8 Function (org.qi4j.functional.Function)7 ApplicationAssembler (org.qi4j.bootstrap.ApplicationAssembler)6 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)6 UnitOfWorkFactory (org.qi4j.api.unitofwork.UnitOfWorkFactory)5 ApplicationAssemblyFactory (org.qi4j.bootstrap.ApplicationAssemblyFactory)5 LayerAssembly (org.qi4j.bootstrap.LayerAssembly)4 MemoryEntityStoreService (org.qi4j.entitystore.memory.MemoryEntityStoreService)4 UuidIdentityGeneratorService (org.qi4j.spi.uuid.UuidIdentityGeneratorService)4 OrgJsonValueSerializationService (org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationService)4 ArrayList (java.util.ArrayList)3 ApplicationDescriptor (org.qi4j.api.structure.ApplicationDescriptor)3