当前位置: 首页>>代码示例>>Java>>正文


Java BQCoreModule类代码示例

本文整理汇总了Java中io.bootique.BQCoreModule的典型用法代码示例。如果您正苦于以下问题:Java BQCoreModule类的具体用法?Java BQCoreModule怎么用?Java BQCoreModule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BQCoreModule类属于io.bootique包,在下文中一共展示了BQCoreModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configure

import io.bootique.BQCoreModule; //导入依赖的package包/类
@Override
public void configure(Binder binder) {

    //programmatically configured cache
    Configuration<String, String> programmaticCache =
            new MutableConfiguration<String, String>()
                    .setTypes(String.class, String.class)
                    .setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ONE_HOUR))
                    .setReadThrough(true)
                    .setWriteThrough(true)
                    .addCacheEntryListenerConfiguration(new MyCache2EntryListenerConfiguration());

    //contribute the cache into BQ
    JCacheModule.extend(binder).setConfiguration("myCache2", programmaticCache);

    BQCoreModule.extend(binder).addCommand(DemoHazelcastCommand.class);
}
 
开发者ID:bootique-examples,项目名称:bootique-jcache-demo,代码行数:18,代码来源:Application.java

示例2: startApp

import io.bootique.BQCoreModule; //导入依赖的package包/类
private void startApp(String config) {

        Module extensions = (binder) -> {
            JerseyModule.extend(binder).addResource(Resource.class);

            // TODO: this test is seriously dirty.. we don't start the client from Bootique,
            // yet we reuse Bootique Logback configuration for client logging.
            // so here we are turning off logging from the server....
            BQCoreModule.extend(binder)
                    .setLogLevel("org.eclipse.jetty.server", Level.OFF)
                    .setLogLevel("org.eclipse.jetty.util", Level.OFF);
        };

        Function<BQRuntime, Boolean> startupCheck = r -> r.getInstance(Server.class).isStarted();

        serverFactory.app("--server", "--config=src/test/resources/io/bootique/jersey/client/" + config)
                .modules(JettyModule.class, JerseyModule.class, LogbackModule.class)
                .module(extensions)
                .startupCheck(startupCheck)
                .start();
    }
 
开发者ID:bootique,项目名称:bootique-jersey-client,代码行数:22,代码来源:HttpClientFactoryFactory_LoggingIT.java

示例3: testWithContextBase_FilePath

import io.bootique.BQCoreModule; //导入依赖的package包/类
@Test
public void testWithContextBase_FilePath() {

    testFactory.app("-s")
            .module(b -> {
                JettyModule.extend(b).useDefaultServlet();
                BQCoreModule.extend(b).setProperty("bq.jetty.staticResourceBase",
                        "src/test/resources/io/bootique/jetty/StaticResourcesIT_docroot/");
            })
            .createRuntime()
            .run();

    WebTarget base = ClientBuilder.newClient().target("http://localhost:8080");

    // resources are mapped relative to "user.dir".
    Response r = base.path("/other.txt").request().get();
    assertEquals(Status.OK.getStatusCode(), r.getStatus());
    assertEquals("I am a text file", r.readEntity(String.class));
}
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:20,代码来源:StaticResourcesIT.java

示例4: testWithContextBase_FileUrl

import io.bootique.BQCoreModule; //导入依赖的package包/类
@Test
public void testWithContextBase_FileUrl() throws MalformedURLException {

    File baseDir = new File("src/test/resources/io/bootique/jetty/StaticResourcesIT_docroot/");
    String baseUrl = baseDir.getAbsoluteFile().toURI().toURL().toString();

    testFactory.app("-s")
            .module(b -> {
                JettyModule.extend(b).useDefaultServlet();
                BQCoreModule.extend(b).setProperty("bq.jetty.staticResourceBase", baseUrl);
            })
            .createRuntime()
            .run();

    WebTarget base = ClientBuilder.newClient().target("http://localhost:8080");

    Response r = base.path("/other.txt").request().get();
    assertEquals(Status.OK.getStatusCode(), r.getStatus());
    assertEquals("I am a text file", r.readEntity(String.class));
}
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:21,代码来源:StaticResourcesIT.java

示例5: testWithContextBase_ClasspathUrl

import io.bootique.BQCoreModule; //导入依赖的package包/类
@Test
public void testWithContextBase_ClasspathUrl() {

    testFactory.app("-s")
            .module(b -> {
                JettyModule.extend(b).useDefaultServlet();
                BQCoreModule.extend(b).setProperty("bq.jetty.staticResourceBase",
                        "classpath:io/bootique/jetty/StaticResourcesIT_docroot");
            })
            .run();

    WebTarget base = ClientBuilder.newClient().target("http://localhost:8080");

    Response r = base.path("/other.txt").request().get();
    assertEquals(Status.OK.getStatusCode(), r.getStatus());
    assertEquals("I am a text file", r.readEntity(String.class));
}
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:18,代码来源:StaticResourcesIT.java

示例6: testWithContextBase_FilePath_ImplicitIndex

import io.bootique.BQCoreModule; //导入依赖的package包/类
@Test
public void testWithContextBase_FilePath_ImplicitIndex() {

    testFactory.app("-s")
            .module(b -> {
                JettyModule.extend(b).useDefaultServlet();
                BQCoreModule.extend(b).setProperty("bq.jetty.staticResourceBase",
                        "src/test/resources/io/bootique/jetty/StaticResourcesIT_docroot/");
            })
            .run();

    WebTarget base = ClientBuilder.newClient().target("http://localhost:8080");

    Response r = base.path("/").request().get();
    assertEquals(Status.OK.getStatusCode(), r.getStatus());
    assertEquals("<html><body><h2>Hi!</h2></body></html>", r.readEntity(String.class));
}
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:18,代码来源:StaticResourcesIT.java

示例7: testWithContextBase_FilePath_DotSlash

import io.bootique.BQCoreModule; //导入依赖的package包/类
@Test
public void testWithContextBase_FilePath_DotSlash() {

    testFactory.app("-s")
            .module(b -> {
                JettyModule.extend(b).useDefaultServlet();
                BQCoreModule.extend(b).setProperty("bq.jetty.staticResourceBase",
                        "./src/test/resources/io/bootique/jetty/StaticResourcesIT_docroot/");
            })
            .run();

    WebTarget base = ClientBuilder.newClient().target("http://localhost:8080");

    Response r = base.path("/").request().get();
    assertEquals(Status.OK.getStatusCode(), r.getStatus());
    assertEquals("<html><body><h2>Hi!</h2></body></html>", r.readEntity(String.class));
}
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:18,代码来源:StaticResourcesIT.java

示例8: configure

import io.bootique.BQCoreModule; //导入依赖的package包/类
@Override
public void configure(Binder binder) {

    BQCoreModule.extend(binder).addCommand(ExecCommand.class)
            .addCommand(ListCommand.class)
            .addCommand(ScheduleCommand.class);

    // trigger extension points creation and provide default contributions
    JobModuleExtender extender = JobModule.extend(binder).initAllExtensions();
    jobTypes.forEach(extender::addJob);

    // TODO: move this to extender API
    MapBinder<LockType, LockHandler> lockHandlers = MapBinder.newMapBinder(binder, LockType.class,
            LockHandler.class);
    lockHandlers.addBinding(LockType.local).to(LocalLockHandler.class);
    lockHandlers.addBinding(LockType.clustered).to(ZkClusterLockHandler.class);
}
 
开发者ID:bootique,项目名称:bootique-job,代码行数:18,代码来源:JobModule.java

示例9: testCreateRuntime_Streams_NoTrace

import io.bootique.BQCoreModule; //导入依赖的package包/类
@Test
public void testCreateRuntime_Streams_NoTrace() {

    TestIO io = TestIO.noTrace();

    CommandOutcome result = testFactory.app("-x")
            .autoLoadModules()
            .module(b -> BQCoreModule.extend(b).addCommand(XCommand.class))
            .bootLogger(io.getBootLogger())
            .createRuntime()
            .run();

    assertTrue(result.isSuccess());
    assertEquals("--out--", io.getStdout().trim());
    assertEquals("--err--", io.getStderr().trim());
}
 
开发者ID:bootique,项目名称:bootique,代码行数:17,代码来源:BQTestFactoryIT.java

示例10: testStart_StartupFailure

import io.bootique.BQCoreModule; //导入依赖的package包/类
@Test
public void testStart_StartupFailure() {

    CommandOutcome failed = CommandOutcome.failed(-1, "Intended failure");

    try {
        testFactory.app("")
                .module(b ->
                        BQCoreModule.extend(b).setDefaultCommand(cli -> failed))
                .startupCheck(r -> false)
                .start();
    } catch (BootiqueException e) {
        assertEquals(-1, e.getOutcome().getExitCode());
        assertEquals("Daemon failed to start: " + failed, e.getOutcome().getMessage());
    }
}
 
开发者ID:bootique,项目名称:bootique,代码行数:17,代码来源:BQDaemonTestFactoryIT.java

示例11: build

import io.bootique.BQCoreModule; //导入依赖的package包/类
public BQModuleProvider build() {

            return new BQModuleProvider() {

                @Override
                public Module module() {
                    return commands;
                }

                @Override
                public Collection<Class<? extends Module>> overrides() {
                    return Collections.singleton(BQCoreModule.class);
                }

                @Override
                public String name() {
                    return "Commands.Builder";
                }
            };
        }
 
开发者ID:bootique,项目名称:bootique,代码行数:21,代码来源:Commands.java

示例12: createPropertiesProvider

import io.bootique.BQCoreModule; //导入依赖的package包/类
protected BQModuleProvider createPropertiesProvider() {
    return new BQModuleProvider() {

        @Override
        public Module module() {
            return binder -> BQCoreModule.extend(binder).setProperties(properties);
        }

        @Override
        public BQModule.Builder moduleBuilder() {
            return BQModuleProvider.super
                    .moduleBuilder()
                    .name("BQInternalTestFactory:Builder:properties");
        }

        @Override
        public String name() {
            return "BQInternalTestFactory:Builder:properties:provider";
        }
    };
}
 
开发者ID:bootique,项目名称:bootique,代码行数:22,代码来源:BQInternalTestFactory.java

示例13: createVariablesProvider

import io.bootique.BQCoreModule; //导入依赖的package包/类
protected BQModuleProvider createVariablesProvider() {
    return new BQModuleProvider() {

        @Override
        public Module module() {
            return binder -> {
                BQCoreModule.extend(binder).setVars(variables).declareVars(declaredVars);
            };
        }

        @Override
        public BQModule.Builder moduleBuilder() {
            return BQModuleProvider.super
                    .moduleBuilder()
                    .name("BQInternalTestFactory:Builder:variables");
        }

        @Override
        public String name() {
            return "BQInternalTestFactory:Builder:variables:provider";
        }
    };
}
 
开发者ID:bootique,项目名称:bootique,代码行数:24,代码来源:BQInternalTestFactory.java

示例14: testMultipleDecoratorsForTheSameCommand

import io.bootique.BQCoreModule; //导入依赖的package包/类
@Test
public void testMultipleDecoratorsForTheSameCommand() {

    Command c1 = mock(Command.class);
    when(c1.run(any())).thenReturn(CommandOutcome.succeeded());

    Command c2 = mock(Command.class);
    when(c2.run(any())).thenReturn(CommandOutcome.succeeded());

    testFactory.app("--a")
            .module(b -> BQCoreModule.extend(b)
                    .addCommand(mainCommand)
                    .decorateCommand(mainCommand.getClass(), CommandDecorator.beforeRun(c1))
                    .decorateCommand(mainCommand.getClass(), CommandDecorator.beforeRun(c2)))
            .createRuntime()
            .run();

    verify(c1).run(any(Cli.class));
    verify(c2).run(any(Cli.class));
    assertTrue(mainCommand.isExecuted());
}
 
开发者ID:bootique,项目名称:bootique,代码行数:22,代码来源:CommandDecoratorIT.java

示例15: testDefaultAndHelpAndModuleCommands

import io.bootique.BQCoreModule; //导入依赖的package包/类
@Test
public void testDefaultAndHelpAndModuleCommands() {

    Command defaultCommand = cli -> CommandOutcome.succeeded();
    Module defaultCommandModule = binder -> BQCoreModule.extend(binder).setDefaultCommand(defaultCommand);

    BQRuntime runtime = runtimeFactory.app().modules(M0.class, M1.class).module(defaultCommandModule).createRuntime();

    CommandManager commandManager = runtime.getInstance(CommandManager.class);

    assertEquals(5, commandManager.getAllCommands().size());
    assertSame(M0.mockCommand, commandManager.lookupByName("m0command").getCommand());
    assertSame(M1.mockCommand, commandManager.lookupByName("m1command").getCommand());
    assertSame(defaultCommand, commandManager.getPublicDefaultCommand().get());
    assertSame(runtime.getInstance(HelpCommand.class), commandManager.getPublicHelpCommand().get());
}
 
开发者ID:bootique,项目名称:bootique,代码行数:17,代码来源:CommandManagerIT.java


注:本文中的io.bootique.BQCoreModule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。