Search in sources :

Example 11 with AssemblyException

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

the class AbstractSQLIndexQueryAssembler method assemble.

@Override
public final void assemble(ModuleAssembly module) throws AssemblyException {
    try {
        SQLVendor sqlVendor = getSQLVendor();
        if (sqlVendor == null) {
            throw new AssemblyException("SQL Vendor could not be determined.");
        }
        module.services(getIndexQueryServiceType()).identifiedBy(identity()).setMetaInfo(sqlVendor).visibleIn(visibility()).instantiateOnStartup();
    } catch (IOException ex) {
        throw new AssemblyException("SQL Vendor could not be created", ex);
    }
    module.services(ReindexerService.class).visibleIn(Visibility.module);
    module.services(ReindexingStrategy.class).withMixins(reindexingStrategy).visibleIn(Visibility.module);
    if (hasConfig()) {
        configModule().entities(SQLConfiguration.class, ReindexerConfiguration.class).visibleIn(configVisibility());
    }
}
Also used : AssemblyException(org.qi4j.bootstrap.AssemblyException) ReindexerService(org.qi4j.index.reindexer.ReindexerService) ReindexerConfiguration(org.qi4j.index.reindexer.ReindexerConfiguration) SQLVendor(org.sql.generation.api.vendor.SQLVendor) SQLConfiguration(org.qi4j.library.sql.common.SQLConfiguration) IOException(java.io.IOException)

Example 12 with AssemblyException

use of org.qi4j.bootstrap.AssemblyException 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 13 with AssemblyException

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

the class WebRealmServiceTest method assemble.

@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
    try {
        ModuleAssembly configModule = module;
        new EntityTestAssembler().assemble(configModule);
        // START SNIPPET: assembly
        new JettyServiceAssembler().withConfig(configModule, Visibility.layer).assemble(module);
        // END SNIPPET: assembly
        port = FreePortFinder.findFreePortOnLoopback();
        JettyConfiguration config = module.forMixin(JettyConfiguration.class).declareDefaults();
        config.hostName().set("127.0.0.1");
        config.port().set(port);
        // START SNIPPET: assembly
        new HttpShiroAssembler().withConfig(configModule, Visibility.layer).assemble(module);
        module.services(MyRealmService.class);
        // END SNIPPET: assembly
        configModule.forMixin(ShiroIniConfiguration.class).declareDefaults().iniResourcePath().set("classpath:web-shiro.ini");
        addServlets(serve("/*").with(MyServletService.class)).to(module);
    } catch (IOException ex) {
        throw new AssemblyException("Unable to find free port to bind to", ex);
    }
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) AssemblyException(org.qi4j.bootstrap.AssemblyException) JettyConfiguration(org.qi4j.library.http.JettyConfiguration) ShiroIniConfiguration(org.qi4j.library.shiro.ini.ShiroIniConfiguration) HttpShiroAssembler(org.qi4j.library.shiro.web.assembly.HttpShiroAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) JettyServiceAssembler(org.qi4j.library.http.JettyServiceAssembler) IOException(java.io.IOException)

Example 14 with AssemblyException

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

the class AbstractEntityStorePerformanceTest method warmup.

@Before
public void warmup() throws Exception {
    try {
        Assembler assembler = new Assembler() {

            @Override
            public void assemble(ModuleAssembly module) throws AssemblyException {
                module.entities(SimpleProduct.class);
            }
        };
        createQi4jRuntime(assembler);
        for (int i = 0; i < 10000; i++) {
            try (UnitOfWork uow = module.newUnitOfWork(newUsecase("Warmup " + i))) {
                SimpleProduct product = uow.newEntity(SimpleProduct.class);
                String id = product.identity().get();
            }
        }
    } catch (Exception ex) {
        logger.error("Unable to warmup: {}", ex.getMessage(), ex);
        throw ex;
    } finally {
        cleanUp();
    }
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Assembler(org.qi4j.bootstrap.Assembler) IOException(java.io.IOException) AssemblyException(org.qi4j.bootstrap.AssemblyException) Before(org.junit.Before)

Example 15 with AssemblyException

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

the class AbstractEntityStorePerformanceTest method whenCreateEntityWithSinglePropertyThenRecordIterationsPerSecond.

@Test
public void whenCreateEntityWithSinglePropertyThenRecordIterationsPerSecond() throws Exception {
    try {
        Assembler assembler = new Assembler() {

            @Override
            public void assemble(ModuleAssembly module) throws AssemblyException {
                module.entities(SimpleProduct.class);
            }
        };
        createQi4jRuntime(assembler);
        profile(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                Report report = new Report(storeName);
                report.start("createEntityWithSingleProperty");
                for (int i = 0; i < ITERATIONS; i++) {
                    try (UnitOfWork uow = module.newUnitOfWork(newUsecase("createEntityWithSingleProperty " + i))) {
                        SimpleProduct product = uow.newEntity(SimpleProduct.class);
                        String id = product.identity().get();
                        uow.complete();
                    }
                    if (i % 1000 == 0) {
                        logger.info("Iteration {}", i);
                    }
                }
                report.stop(ITERATIONS);
                writeReport(report);
                return null;
            }
        });
    } finally {
        cleanUp();
    }
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Assembler(org.qi4j.bootstrap.Assembler) IOException(java.io.IOException) AssemblyException(org.qi4j.bootstrap.AssemblyException) Test(org.junit.Test)

Aggregations

AssemblyException (org.qi4j.bootstrap.AssemblyException)38 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)27 Test (org.junit.Test)23 Module (org.qi4j.api.structure.Module)14 SingletonAssembler (org.qi4j.bootstrap.SingletonAssembler)14 IOException (java.io.IOException)10 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)10 ApplicationAssembler (org.qi4j.bootstrap.ApplicationAssembler)10 Assembler (org.qi4j.bootstrap.Assembler)10 ApplicationAssemblyFactory (org.qi4j.bootstrap.ApplicationAssemblyFactory)9 Application (org.qi4j.api.structure.Application)8 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)8 Energy4Java (org.qi4j.bootstrap.Energy4Java)8 LayerAssembly (org.qi4j.bootstrap.LayerAssembly)5 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)5 AmbiguousTypeException (org.qi4j.api.composite.AmbiguousTypeException)4 ApplicationDescriptor (org.qi4j.api.structure.ApplicationDescriptor)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 JettyConfiguration (org.qi4j.library.http.JettyConfiguration)2