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());
}
}
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();
}
}
});
}
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);
}
}
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();
}
}
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();
}
}
Aggregations