本文整理汇总了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);
}
示例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();
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
示例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());
}
示例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());
}
}
示例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";
}
};
}
示例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";
}
};
}
示例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";
}
};
}
示例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());
}
示例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());
}