Search in sources :

Example 1 with JettyServiceAssembler

use of org.qi4j.library.http.JettyServiceAssembler 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 2 with JettyServiceAssembler

use of org.qi4j.library.http.JettyServiceAssembler in project qi4j-sdk by Qi4j.

the class WebHttpShiroTest 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);
        // END SNIPPET: assembly
        configModule.forMixin(ShiroIniConfiguration.class).declareDefaults().iniResourcePath().set("classpath:web-shiro.ini");
    } 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)

Aggregations

IOException (java.io.IOException)2 AssemblyException (org.qi4j.bootstrap.AssemblyException)2 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)2 JettyConfiguration (org.qi4j.library.http.JettyConfiguration)2 JettyServiceAssembler (org.qi4j.library.http.JettyServiceAssembler)2 ShiroIniConfiguration (org.qi4j.library.shiro.ini.ShiroIniConfiguration)2 HttpShiroAssembler (org.qi4j.library.shiro.web.assembly.HttpShiroAssembler)2 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)2