Search in sources :

Example 61 with ModuleAssembly

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

the class JMXTest method main.

public static void main(String[] args) throws InterruptedException, ActivationException, AssemblyException {
    /*
         Logger logger = Logger.getLogger( "" );
         logger.setLevel( Level.FINE );
         Logger.getLogger("sun.rmi").setLevel( Level.WARNING );

         ConsoleHandler consoleHandler = new ConsoleHandler();
         consoleHandler.setLevel( Level.FINE );
         logger.addHandler( consoleHandler );
         */
    SingletonAssembler assembler = new SingletonAssembler() {

        // START SNIPPET: assembly
        public void assemble(ModuleAssembly module) throws AssemblyException {
            // END SNIPPET: assembly
            new EntityTestAssembler().assemble(module);
            module.services(TestService.class, TestService2.class, TestService3.class).instantiateOnStartup();
            module.entities(TestConfiguration.class);
            module.values(TestValue.class);
            module.objects(TestObject.class);
            // START SNIPPET: assembly
            new JMXAssembler().assemble(module);
            module.services(JMXConnectorService.class).instantiateOnStartup();
            module.entities(JMXConnectorConfiguration.class);
            module.forMixin(JMXConnectorConfiguration.class).declareDefaults().port().set(1099);
        }
    };
    // This allows user to connect using VisualVM/JConsole
    while (true) {
        Thread.sleep(10000);
    }
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler)

Example 62 with ModuleAssembly

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

the class PasswordDomainTest method assemble.

// END SNIPPET: domain
// START SNIPPET: assembly
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
    // END SNIPPET: assembly
    new EntityTestAssembler().assemble(module);
    new RdfMemoryStoreAssembler().assemble(module);
    ModuleAssembly configModule = module;
    // START SNIPPET: assembly
    new StandaloneShiroAssembler().withConfig(configModule, Visibility.layer).assemble(module);
    new PasswordDomainAssembler().withConfig(configModule, Visibility.layer).assemble(module);
    module.entities(User.class);
    module.services(UserFactory.class);
    // END SNIPPET: assembly
    configModule.forMixin(ShiroIniConfiguration.class).declareDefaults().iniResourcePath().set("classpath:standalone-shiro.ini");
// START SNIPPET: assembly
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) ShiroIniConfiguration(org.qi4j.library.shiro.ini.ShiroIniConfiguration) RdfMemoryStoreAssembler(org.qi4j.index.rdf.assembly.RdfMemoryStoreAssembler) StandaloneShiroAssembler(org.qi4j.library.shiro.assembly.StandaloneShiroAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) PasswordDomainAssembler(org.qi4j.library.shiro.assembly.PasswordDomainAssembler)

Example 63 with ModuleAssembly

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

the class StandaloneShiroTest method assemble.

@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
    new EntityTestAssembler().assemble(module);
    ModuleAssembly configModule = module;
    // START SNIPPET: assembly
    new StandaloneShiroAssembler().withConfig(configModule, Visibility.layer).assemble(module);
    // END SNIPPET: assembly
    configModule.forMixin(ShiroIniConfiguration.class).declareDefaults().iniResourcePath().set("classpath:standalone-shiro.ini");
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) ShiroIniConfiguration(org.qi4j.library.shiro.ini.ShiroIniConfiguration) StandaloneShiroAssembler(org.qi4j.library.shiro.assembly.StandaloneShiroAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler)

Example 64 with ModuleAssembly

use of org.qi4j.bootstrap.ModuleAssembly 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 65 with ModuleAssembly

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

the class SchedulerTest method onAssembly.

@Override
protected void onAssembly(ModuleAssembly testAssembly) throws AssemblyException {
    ModuleAssembly moduleAssembly = testAssembly;
    ModuleAssembly configModuleAssembly = testAssembly;
    // START SNIPPET: assembly
    new SchedulerAssembler().visibleIn(Visibility.application).withConfig(configModuleAssembly, Visibility.layer).withTimeline().assemble(moduleAssembly);
// END SNIPPET: assembly
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SchedulerAssembler(org.qi4j.library.scheduler.bootstrap.SchedulerAssembler)

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