Search in sources :

Example 51 with ModuleAssembly

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

the class RDFPerformanceTest method assemble.

@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
    module.services(FileConfigurationService.class);
    ModuleAssembly prefModule = module.layer().module("PrefModule");
    prefModule.entities(NativeConfiguration.class).visibleIn(Visibility.application);
    prefModule.forMixin(NativeConfiguration.class).declareDefaults().tripleIndexes().set("spoc,cspo");
    prefModule.forMixin(NativeConfiguration.class).declareDefaults().dataDirectory().set(DATA_DIR.getAbsolutePath());
    new EntityTestAssembler().assemble(prefModule);
    module.entities(ExampleEntity.class);
    EntityTestAssembler testAss = new EntityTestAssembler();
    testAss.assemble(module);
    Assembler rdfAssembler = new RdfNativeSesameStoreAssembler();
    rdfAssembler.assemble(module);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) RdfNativeSesameStoreAssembler(org.qi4j.index.rdf.assembly.RdfNativeSesameStoreAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) Assembler(org.qi4j.bootstrap.Assembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) RdfNativeSesameStoreAssembler(org.qi4j.index.rdf.assembly.RdfNativeSesameStoreAssembler) NativeConfiguration(org.qi4j.library.rdf.repository.NativeConfiguration)

Example 52 with ModuleAssembly

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

the class DividendsMain method main.

public static void main(String[] args) throws Exception {
    SingletonAssembler assembler = new SingletonAssembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.services(ProjectedDividendsService.class).instantiateOnStartup();
            module.values(DivStream.class, DivPoint.class);
            new CxfAssembler().assemble(module);
        }
    };
    final Application application = assembler.application();
    Runtime.getRuntime().addShutdownHook(new Thread() {

        @Override
        public void run() {
            try {
                application.passivate();
            } catch (Exception e) {
                System.err.println("Problem shutting down Qi4j");
                e.printStackTrace();
            }
        }
    });
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Application(org.qi4j.api.structure.Application) AssemblyException(org.qi4j.bootstrap.AssemblyException) CxfAssembler(org.qi4j.library.cxf.CxfAssembler)

Example 53 with ModuleAssembly

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

the class DomainEventSourceResourceSample method main.

public static void main(String[] args) throws Exception {
    Component component = new Component();
    component.getServers().add(Protocol.HTTP, 8080);
    SingletonAssembler assembler = new SingletonAssembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            new EntityTestAssembler().assemble(module);
            module.values(DomainEventValue.class, UnitOfWorkDomainEventsValue.class);
            module.services(MemoryEventStoreService.class).taggedWith("domain");
            module.services(DomainEventFactoryService.class);
            module.importedServices(CurrentUserUoWPrincipal.class).importedBy(ImportedServiceDeclaration.NEW_OBJECT);
            module.objects(CurrentUserUoWPrincipal.class);
            module.objects(DomainEventSourceResource.class, PingResource.class);
            module.entities(TestEntity.class).withConcerns(DomainEventCreationConcern.class);
        }
    };
    component.getDefaultHost().attach("/events", new TestApplication(assembler));
    component.getDefaultHost().attach("/ping", assembler.module().newObject(PingResource.class));
    component.start();
    generateTestData(assembler.module());
}
Also used : MemoryEventStoreService(org.qi4j.library.eventsourcing.domain.source.memory.MemoryEventStoreService) ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) CurrentUserUoWPrincipal(org.qi4j.library.eventsourcing.domain.factory.CurrentUserUoWPrincipal)

Example 54 with ModuleAssembly

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

the class UnitOfWorkRouterTest method testData.

@Before
public void testData() throws ActivationException, AssemblyException {
    SingletonAssembler assembler = new SingletonAssembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.values(UnitOfWorkDomainEventsValue.class, DomainEventValue.class);
        }
    };
    list = new ArrayList<UnitOfWorkDomainEventsValue>();
    {
        ValueBuilder<UnitOfWorkDomainEventsValue> builder = assembler.module().newValueBuilder(UnitOfWorkDomainEventsValue.class);
        builder.prototype().events().get().add(newDomainEvent(assembler, "Test1"));
        builder.prototype().events().get().add(newDomainEvent(assembler, "Test2"));
        builder.prototype().events().get().add(newDomainEvent(assembler, "Test3"));
        builder.prototype().version().set("1.0");
        builder.prototype().timestamp().set(System.currentTimeMillis());
        builder.prototype().usecase().set("Test");
        list.add(builder.newInstance());
    }
    {
        ValueBuilder<UnitOfWorkDomainEventsValue> builder = assembler.module().newValueBuilder(UnitOfWorkDomainEventsValue.class);
        builder.prototype().events().get().add(newDomainEvent(assembler, "Test4"));
        builder.prototype().events().get().add(newDomainEvent(assembler, "Test5"));
        builder.prototype().events().get().add(newDomainEvent(assembler, "Test6"));
        builder.prototype().version().set("1.0");
        builder.prototype().timestamp().set(System.currentTimeMillis());
        builder.prototype().usecase().set("Test2");
        list.add(builder.newInstance());
    }
}
Also used : ValueBuilder(org.qi4j.api.value.ValueBuilder) ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) UnitOfWorkDomainEventsValue(org.qi4j.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue) Before(org.junit.Before)

Example 55 with ModuleAssembly

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

the class FileConfigurationTest method testFileConfigurationOverride.

@Test
public void testFileConfigurationOverride() throws IOException, ActivationException, AssemblyException {
    File testFile = File.createTempFile(FileConfigurationTest.class.getName(), "" + System.currentTimeMillis());
    final File confDir = testFile;
    final File dataDir = testFile;
    final File tempDir = testFile;
    final File cacheDir = testFile;
    final File logDir = testFile;
    SingletonAssembler assembler = new SingletonAssembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            // START SNIPPET: override
            FileConfigurationOverride override = new FileConfigurationOverride().withConfiguration(confDir).withData(dataDir).withTemporary(tempDir).withCache(cacheDir).withLog(logDir);
            new FileConfigurationAssembler().withOverride(override).assemble(module);
        // END SNIPPET: override
        }
    };
    FileConfiguration config = assembler.module().findService(FileConfiguration.class).get();
    assertEquals(testFile.getAbsolutePath(), config.configurationDirectory().getAbsolutePath());
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) File(java.io.File) Test(org.junit.Test)

Aggregations

ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)191 SingletonAssembler (org.qi4j.bootstrap.SingletonAssembler)87 Test (org.junit.Test)82 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)59 AssemblyException (org.qi4j.bootstrap.AssemblyException)27 Application (org.qi4j.api.structure.Application)26 OrgJsonValueSerializationAssembler (org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)24 Assembler (org.qi4j.bootstrap.Assembler)23 Module (org.qi4j.api.structure.Module)19 LayerAssembly (org.qi4j.bootstrap.LayerAssembly)15 Before (org.junit.Before)12 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)12 Energy4Java (org.qi4j.bootstrap.Energy4Java)12 DataSourceAssembler (org.qi4j.library.sql.assembly.DataSourceAssembler)11 DBCPDataSourceServiceAssembler (org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler)9 IOException (java.io.IOException)8 ApplicationAssemblerAdapter (org.qi4j.bootstrap.ApplicationAssemblerAdapter)8 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)8 File (java.io.File)7 OrgJsonValueSerializationService (org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationService)7