Search in sources :

Example 1 with JMXAssembler

use of org.qi4j.library.jmx.JMXAssembler in project qi4j-sdk by Qi4j.

the class JettyJMXStatisticsTest method assemble.

@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
    ModuleAssembly configModule = module;
    new EntityTestAssembler().assemble(configModule);
    // START SNIPPET: jmx
    new JettyServiceAssembler().withConfig(configModule, Visibility.layer).assemble(module);
    // Assemble both JettyService and JMX
    new JMXAssembler().assemble(module);
    JettyConfiguration config = configModule.forMixin(JettyConfiguration.class).declareDefaults();
    config.hostName().set("127.0.0.1");
    config.port().set(8441);
    // Set statistics default to TRUE in configuration
    config.statistics().set(Boolean.TRUE);
    // Hello world servlet related assembly
    addServlets(serve("/hello").with(HelloWorldServletService.class)).to(module);
// END SNIPPET: jmx
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) JMXAssembler(org.qi4j.library.jmx.JMXAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler)

Example 2 with JMXAssembler

use of org.qi4j.library.jmx.JMXAssembler in project qi4j-sdk by Qi4j.

the class DataSourceConfigurationManagerServiceTest method testDataSources.

@Test
public void testDataSources() throws ActivationException, AssemblyException {
    SingletonAssembler assembler = new SingletonAssembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            new JMXAssembler().assemble(module);
            // Create in-memory store for configurations
            new EntityTestAssembler().visibleIn(Visibility.layer).assemble(module);
            // Set up DataSource service that will manage the connection pools
            new C3P0DataSourceServiceAssembler().identifiedBy("datasource-service").visibleIn(Visibility.layer).assemble(module);
            {
                ModuleAssembly testModule = module.layer().module("TestDS");
                // Create a specific DataSource that uses the "datasource" service to do the main work
                new DataSourceAssembler().withDataSourceServiceIdentity("datasource-service").identifiedBy("testds").visibleIn(Visibility.module).withCircuitBreaker(DataSources.newDataSourceCircuitBreaker()).assemble(testModule);
                // Set up Liquibase service that will create the tables
                testModule.services(LiquibaseService.class).identifiedBy("liquibase1").instantiateOnStartup();
                testModule.entities(LiquibaseConfiguration.class);
                testModule.forMixin(LiquibaseConfiguration.class).declareDefaults().enabled().set(true);
                testModule.forMixin(LiquibaseConfiguration.class).declareDefaults().changeLog().set("changelog.xml");
            }
            {
                ModuleAssembly testModule2 = module.layer().module("TestDS2");
                // Create another specific DataSource that uses the "datasource" service to do the main work
                // Use DataSourceAssembler to assemble the DataSource.
                new DataSourceAssembler().withDataSourceServiceIdentity("datasource-service").identifiedBy("testds2").visibleIn(Visibility.module).withCircuitBreaker(DataSources.newDataSourceCircuitBreaker()).assemble(testModule2);
                // Set up Liquibase service that will create the tables
                testModule2.services(LiquibaseService.class).identifiedBy("liquibase2").instantiateOnStartup();
                testModule2.entities(LiquibaseConfiguration.class);
                testModule2.forMixin(LiquibaseConfiguration.class).declareDefaults().enabled().set(true);
                testModule2.forMixin(LiquibaseConfiguration.class).declareDefaults().changeLog().set("changelog.xml");
            }
            // START SNIPPET: jmx
            new DataSourceJMXAssembler().visibleIn(Visibility.module).assemble(module);
        // END SNIPPET: jmx
        }
    };
//        assembler.application().findModule( "Layer 1","Test" ).objectBuilderFactory().newObjectBuilder( DataSourceConfigurationManagerServiceTest.class ).injectTo( this );
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) C3P0DataSourceServiceAssembler(org.qi4j.library.sql.c3p0.C3P0DataSourceServiceAssembler) DataSourceAssembler(org.qi4j.library.sql.assembly.DataSourceAssembler) DataSourceJMXAssembler(org.qi4j.library.sql.assembly.DataSourceJMXAssembler) JMXAssembler(org.qi4j.library.jmx.JMXAssembler) DataSourceJMXAssembler(org.qi4j.library.sql.assembly.DataSourceJMXAssembler) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) LiquibaseConfiguration(org.qi4j.library.sql.liquibase.LiquibaseConfiguration) LiquibaseService(org.qi4j.library.sql.liquibase.LiquibaseService) Test(org.junit.Test)

Aggregations

ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)2 JMXAssembler (org.qi4j.library.jmx.JMXAssembler)2 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)2 Test (org.junit.Test)1 SingletonAssembler (org.qi4j.bootstrap.SingletonAssembler)1 DataSourceAssembler (org.qi4j.library.sql.assembly.DataSourceAssembler)1 DataSourceJMXAssembler (org.qi4j.library.sql.assembly.DataSourceJMXAssembler)1 C3P0DataSourceServiceAssembler (org.qi4j.library.sql.c3p0.C3P0DataSourceServiceAssembler)1 LiquibaseConfiguration (org.qi4j.library.sql.liquibase.LiquibaseConfiguration)1 LiquibaseService (org.qi4j.library.sql.liquibase.LiquibaseService)1