Search in sources :

Example 6 with AssemblyException

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

the class TypeToCompositeLookupTest method transientsAmbiguousDeclaration.

@Test
public void transientsAmbiguousDeclaration() throws ActivationException, AssemblyException {
    Module module = new SingletonAssembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.transients(SomeOtherFoo.class, BasicFoo.class);
        }
    }.module();
    assertEquals(CATHEDRAL, module.newTransientBuilder(SomeOtherFoo.class).newInstance().bar());
    assertEquals(BAZAR, module.newTransientBuilder(BasicFoo.class).newInstance().bar());
    try {
        module.newTransientBuilder(Foo.class);
        fail("Ambiguous type exception not detected for Transients");
    } catch (AmbiguousTypeException expected) {
    }
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) AssemblyException(org.qi4j.bootstrap.AssemblyException) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Module(org.qi4j.api.structure.Module) AmbiguousTypeException(org.qi4j.api.composite.AmbiguousTypeException) Test(org.junit.Test)

Example 7 with AssemblyException

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

the class TypeToCompositeLookupTest method values.

@Test
public void values() throws ActivationException, AssemblyException {
    Module module = new SingletonAssembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.values(SomeOtherFoo.class);
        }
    }.module();
    assertEquals(CATHEDRAL, module.newValueBuilder(SomeOtherFoo.class).newInstance().bar());
    assertEquals(CATHEDRAL, module.newValueBuilder(BasicFoo.class).newInstance().bar());
    assertEquals(CATHEDRAL, module.newValueBuilder(Foo.class).newInstance().bar());
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) AssemblyException(org.qi4j.bootstrap.AssemblyException) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Module(org.qi4j.api.structure.Module) Test(org.junit.Test)

Example 8 with AssemblyException

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

the class TypeToCompositeLookupTest method objects.

@Test
public void objects() throws ActivationException, AssemblyException {
    Module module = new SingletonAssembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.objects(SomeOtherFooImpl.class);
        }
    }.module();
    assertEquals(CATHEDRAL, module.newObject(SomeOtherFooImpl.class).bar());
    assertEquals(CATHEDRAL, module.newObject(BasicFooImpl.class).bar());
    assertEquals(CATHEDRAL, module.newObject(Foo.class).bar());
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) AssemblyException(org.qi4j.bootstrap.AssemblyException) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Module(org.qi4j.api.structure.Module) Test(org.junit.Test)

Example 9 with AssemblyException

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

the class TypeToCompositeLookupTest method services.

@Test
public void services() throws ActivationException, AssemblyException {
    Module module = new SingletonAssembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.services(SomeOtherFoo.class);
        }
    }.module();
    assertEquals(CATHEDRAL, module.findService(SomeOtherFoo.class).get().bar());
    assertEquals(CATHEDRAL, module.findService(BasicFoo.class).get().bar());
    assertEquals(CATHEDRAL, module.findService(Foo.class).get().bar());
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) AssemblyException(org.qi4j.bootstrap.AssemblyException) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Module(org.qi4j.api.structure.Module) Test(org.junit.Test)

Example 10 with AssemblyException

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

the class AbstractSQLEntityStoreAssembler method assemble.

@Override
public final void assemble(ModuleAssembly module) throws AssemblyException {
    try {
        SQLVendor sqlVendor = this.getSQLVendor();
        if (sqlVendor == null) {
            throw new AssemblyException("SQL Vendor could not be determined.");
        }
        module.services(DatabaseSQLServiceComposite.class).withMixins(DatabaseSQLServiceCoreMixin.class, DatabaseSQLServiceSpi.CommonMixin.class, getDatabaseStringBuilderMixin(), DatabaseSQLServiceStatementsMixin.class, getDatabaseSQLServiceSpecializationMixin()).identifiedBy(hasIdentity() ? identity() : DEFAULT_ENTITYSTORE_IDENTITY).visibleIn(Visibility.module).setMetaInfo(sqlVendor);
    } catch (IOException ioe) {
        throw new AssemblyException(ioe);
    }
    module.services(SQLEntityStoreService.class, UuidIdentityGeneratorService.class).visibleIn(visibility());
    if (hasConfig()) {
        configModule().entities(SQLConfiguration.class).visibleIn(configVisibility());
    }
}
Also used : UuidIdentityGeneratorService(org.qi4j.spi.uuid.UuidIdentityGeneratorService) AssemblyException(org.qi4j.bootstrap.AssemblyException) DatabaseSQLServiceStatementsMixin(org.qi4j.entitystore.sql.internal.DatabaseSQLServiceStatementsMixin) SQLEntityStoreService(org.qi4j.entitystore.sql.SQLEntityStoreService) SQLVendor(org.sql.generation.api.vendor.SQLVendor) SQLConfiguration(org.qi4j.library.sql.common.SQLConfiguration) IOException(java.io.IOException) DatabaseSQLServiceCoreMixin(org.qi4j.entitystore.sql.internal.DatabaseSQLServiceCoreMixin)

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