• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CommandOutcome类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: run

import io.bootique.command.CommandOutcome; //导入依赖的package包/类
@Override
public CommandOutcome run(Cli cli) {

    //retrieve the cache defined in the declaration file hazelcast.xml
    Cache<String, Integer> declarativeCache = cacheManager.get()
            .getCache("myCache1", String.class, Integer.class);

    //put an entry...
    //CacheEntryCreatedListener fires afterwards
    declarativeCache.put("1", 1);

    //retrieve the cache configured programmatically and contributed into Bootique
    Cache<String, String> programmaticCache = cacheManager.get()
            .getCache("myCache2", String.class, String.class);

    //put an entry...
    //CacheEntryCreatedListener fires afterwards
    programmaticCache.put("key1", "value1");

    return CommandOutcome.succeeded();
}
 
开发者ID:bootique-examples,项目名称:bootique-jcache-demo,代码行数:22,代码来源:DemoHazelcastCommand.java


示例2: run

import io.bootique.command.CommandOutcome; //导入依赖的package包/类
@Override
public CommandOutcome run(Cli cli) {

    //retrieve the cache defined in ehcache.xml
    Cache<String, Integer> cache = cacheManager.get()
            .getCache("myCache1", String.class, Integer.class);

    //put an entry...
    //CacheEntryCreatedListener fires afterwards
    cache.put("1", 1);

    //retrieve the cache configured programmatically and contributed into Bootique
    Cache<Long, Long> myCache2 = cacheManager.get()
            .getCache("myCache2", Long.class, Long.class);

    //put an entry...
    //CacheEntryCreatedListener fires afterwards
    myCache2.put(1L, 1L);

    return CommandOutcome.succeeded();
}
 
开发者ID:bootique-examples,项目名称:bootique-jcache-demo,代码行数:22,代码来源:DemoEhcacheCommand.java


示例3: run

import io.bootique.command.CommandOutcome; //导入依赖的package包/类
@Override
public CommandOutcome run(Cli cli) {

    String topic = cli.optionString(TOPIC_OPT);
    if (topic == null) {
        return CommandOutcome.failed(-1, "No --topic specified");
    }

    ProducerConfig<byte[], String> config = ProducerConfig
            .charValueConfig()
            .bootstrapServers(cli.optionStrings(BOOTSTRAP_SERVER_OPT))
            .build();

    Producer<byte[], String> producer = kafkaProvider.get().createProducer(DEFAULT_CLUSTER_NAME, config);

    shutdownManager.addShutdownHook(() -> {
        producer.close();
        // give a bit of time to stop..
        Thread.sleep(200);
    });

    return runConsole(topic, producer);
}
 
开发者ID:bootique-examples,项目名称:bootique-kafka-producer,代码行数:24,代码来源:KafkaProducerCommand.java


示例4: run

import io.bootique.command.CommandOutcome; //导入依赖的package包/类
public CommandOutcome run(Consumer<BQRuntime> beforeShutdownCallback, String... args) {

        BootLogger logger = createBootLogger();
        Bootique bootique = Bootique.app(args).bootLogger(logger);
        configure(bootique);

        BQRuntime runtime = bootique.createRuntime();
        try {
            return runtime.getInstance(Runner.class).run();
        } catch (Exception e) {
            logger.stderr("Error", e);
            return CommandOutcome.failed(1, getStderr());
        } finally {

            try {
                beforeShutdownCallback.accept(runtime);
            }
            finally {
                runtime.shutdown();
            }
        }
    }
 
开发者ID:bootique,项目名称:bootique-bom,代码行数:23,代码来源:BomTestApp.java


示例5: run

import io.bootique.command.CommandOutcome; //导入依赖的package包/类
@Override
public CommandOutcome run(Cli cli) {

	DataSource dataSource = dataSourceFactoryProvider.get().forName("test1");

	try (Connection c = dataSource.getConnection()) {
		prepareDB(c);

		for (String sql : cli.optionStrings("sql")) {
			runSELECT(c, sql);
		}

	} catch (SQLException ex) {
		logger.stderr("Error....", ex);
	}

	return CommandOutcome.succeeded();
}
 
开发者ID:bootique,项目名称:bootique-bom,代码行数:19,代码来源:RunSQLCommand.java


示例6: testSchedule

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

    BomJob.COUNTER.set(0);
    BomParameterizedJob.COUNTER.set(0);

    CommandOutcome outcome = app.run(r -> {
                // wait for scheduler to run jobs...
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            },
            "--schedule", "-c", "classpath:io/bootique/bom/job/test.yml");

    assertEquals(0, outcome.getExitCode());

    assertTrue("Unexpected job count: " + BomJob.COUNTER.get(), BomJob.COUNTER.get() > 3);
    assertTrue(BomParameterizedJob.COUNTER.get() > 17 * 3);
    assertEquals(0, BomParameterizedJob.COUNTER.get() % 17);
}
 
开发者ID:bootique,项目名称:bootique-bom,代码行数:23,代码来源:JobAppIT.java


示例7: testRun_Debug

import io.bootique.command.CommandOutcome; //导入依赖的package包/类
@Test
public void testRun_Debug() throws IOException {
    File logFile = prepareLogFile("target/logback/testRun_Debug.log");

    BQRuntime runtime = app
            .app("--config=src/test/resources/io/bootique/bom/logback/test-debug.yml").createRuntime();
    CommandOutcome outcome = runtime.run();

    // stopping runtime to ensure the logs are flushed before we start making assertions...
    runtime.shutdown();

    assertEquals(0, outcome.getExitCode());

    assertTrue(logFile.isFile());

    String logfileContents = Files.lines(logFile.toPath()).collect(joining("\n"));
    assertTrue(logfileContents.contains("i.b.b.l.LogbackTestCommand: logback-test-debug"));
    assertTrue(logfileContents.contains("i.b.b.l.LogbackTestCommand: logback-test-info"));
    assertTrue(logfileContents.contains("i.b.b.l.LogbackTestCommand: logback-test-warn"));
    assertTrue(logfileContents.contains("i.b.b.l.LogbackTestCommand: logback-test-error"));
}
 
开发者ID:bootique,项目名称:bootique-bom,代码行数:22,代码来源:LogbackAppIT.java


示例8: testRun_Warn

import io.bootique.command.CommandOutcome; //导入依赖的package包/类
@Test
public void testRun_Warn() throws IOException {
    File logFile = prepareLogFile("target/logback/testRun_Warn.log");

    BQRuntime runtime = app.app("--config=src/test/resources/io/bootique/bom/logback/test-warn.yml")
            .createRuntime();
    CommandOutcome outcome = runtime.run();

    // stopping runtime to ensure the logs are flushed before we start making assertions...
    runtime.shutdown();

    assertEquals(0, outcome.getExitCode());

    assertTrue(logFile.isFile());

    String logfileContents = Files.lines(logFile.toPath()).collect(joining("\n"));
    assertFalse(logfileContents.contains("i.b.b.l.LogbackTestCommand: logback-test-debug"));
    assertFalse(logfileContents.contains("i.b.b.l.LogbackTestCommand: logback-test-info"));
    assertTrue("Logfile contents: " + logfileContents,
            logfileContents.contains("i.b.b.l.LogbackTestCommand: logback-test-warn"));
    assertTrue(logfileContents.contains("i.b.b.l.LogbackTestCommand: logback-test-error"));
}
 
开发者ID:bootique,项目名称:bootique-bom,代码行数:23,代码来源:LogbackAppIT.java


示例9: testRun_Help

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

    TestIO io = TestIO.noTrace();

    BQRuntime runtime = app.app("--help")
            .bootLogger(io.getBootLogger())
            .startupAndWaitCheck()
            // using longer startup timeout .. sometimes this fails on Travis..
            .startupTimeout(8, TimeUnit.SECONDS)
            .start();

    CommandOutcome outcome = app.getOutcome(runtime).get();
    assertEquals(0, outcome.getExitCode());

    assertTrue(io.getStdout().contains("--help"));
    assertTrue(io.getStdout().contains("--config"));
}
 
开发者ID:bootique,项目名称:bootique-bom,代码行数:19,代码来源:LinkRestAppIT.java


示例10: run

import io.bootique.command.CommandOutcome; //导入依赖的package包/类
@Override
public CommandOutcome run(Cli cli) {
	System.out.println("SNOMED-CT interactive browser and search.");
	boolean quit = false;
	while (!quit) {
		if (currentConcept() != null) {
			System.out.println("****************************************");
			System.out.println("Current: "+currentConcept().getConceptId()  + ": " + currentConcept().getFullySpecifiedName());
			System.out.println("****************************************");
		}
		System.out.println("Enter command:");
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
		try {
			String line = bufferedReader.readLine();
			quit = performCommand(line.trim());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	return CommandOutcome.succeeded();
}
 
开发者ID:wardle,项目名称:rsterminology,代码行数:23,代码来源:Browser.java


示例11: testRun

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

    CommandOutcome outcome = testFactory.app("-s")
            .module(b -> UndertowModule.extend(b).addController(TestController.class))
            .run();

    assertTrue(outcome.isSuccess());
    assertTrue(outcome.forkedToBackground());

    // testing that the server is in the operational state by the time ServerCommand exits...
    WebTarget base = ClientBuilder.newClient().target("http://localhost:8080");

    Response r = base.path("/").request().get();
    assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
    assertEquals("Hello World!", r.readEntity(String.class));
}
 
开发者ID:bootique,项目名称:bootique-undertow,代码行数:18,代码来源:ServerCommandIT.java


示例12: testRun

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

    CommandOutcome outcome = testFactory.app("-s")
            .module(b -> JettyModule.extend(b).addServlet(new TestServlet(), "x", "/"))
            .run();

    assertTrue(outcome.isSuccess());
    assertTrue(outcome.forkedToBackground());

    // testing that the server is in the operational state by the time ServerCommand exits...
    WebTarget base = ClientBuilder.newClient().target("http://localhost:8080");

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


示例13: run

import io.bootique.command.CommandOutcome; //导入依赖的package包/类
@Override
public CommandOutcome run(Cli cli) {
    Scheduler scheduler = schedulerProvider.get();

    int jobCount;

    List<String> jobNames = cli.optionStrings(JOB_OPTION);
    if (jobNames == null || jobNames.isEmpty()) {
        LOGGER.info("Starting scheduler");
        jobCount = scheduler.start();
    } else {
        LOGGER.info("Starting scheduler for jobs: " + jobNames);
        jobCount = scheduler.start(jobNames);
    }

    LOGGER.info("Started scheduler with {} trigger(s).", jobCount);
    return CommandOutcome.succeededAndForkedToBackground();
}
 
开发者ID:bootique,项目名称:bootique-job,代码行数:19,代码来源:ScheduleCommand.java


示例14: run

import io.bootique.command.CommandOutcome; //导入依赖的package包/类
@Override
public CommandOutcome run(Cli cli) {

	List<String> jobNames = cli.optionStrings(JOB_OPTION);
	if (jobNames == null || jobNames.isEmpty()) {
		return CommandOutcome.failed(1,
				String.format("No jobs specified. Use '--%s' option to provide job names", JOB_OPTION));
	}

	LOGGER.info("Will run job(s): " + jobNames);

	Scheduler scheduler = schedulerProvider.get();

	CommandOutcome outcome;
	if (cli.hasOption(SERIAL_OPTION)) {
		outcome = runSerial(jobNames, scheduler);
	} else {
		outcome = runParallel(jobNames, scheduler);
	}
	return outcome;
}
 
开发者ID:bootique,项目名称:bootique-job,代码行数:22,代码来源:ExecCommand.java


示例15: checkStartupOutcome

import io.bootique.command.CommandOutcome; //导入依赖的package包/类
private Optional<CommandOutcome> checkStartupOutcome() {
    // Either the command has finished, or it is still running, but the custom check is successful.
    // The later test may be used for blocking commands that start some background processing and
    // wait till the end.

    if (outcome != null) {
        return Optional.of(outcome);
    }

    if (startupCheck.apply(runtime)) {
        // command is still running (perhaps waiting for a background task execution, or listening for
        // requests), but the stack is in the state that can be tested already.
        return Optional.of(CommandOutcome.succeededAndForkedToBackground());
    }

    logger.stderr("Daemon runtime hasn't started yet...");
    return Optional.empty();
}
 
开发者ID:bootique,项目名称:bootique,代码行数:19,代码来源:BQRuntimeDaemon.java


示例16: testCreateRuntime_Streams_NoTrace

import io.bootique.command.CommandOutcome; //导入依赖的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


示例17: testStart_StartupFailure

import io.bootique.command.CommandOutcome; //导入依赖的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


示例18: bareCommand

import io.bootique.command.CommandOutcome; //导入依赖的package包/类
private Command bareCommand() {
    if (cli.commandName() != null) {
        ManagedCommand explicitCommand = commandManager.getAllCommands().get(cli.commandName());
        if (explicitCommand == null || explicitCommand.isHidden() || explicitCommand.isDefault()) {
            throw new IllegalStateException("Not a valid command: " + cli.commandName());
        }

        return explicitCommand.getCommand();
    }

    // command not found in CLI .. go through defaults

    return commandManager.getPublicDefaultCommand() // 1. runtime default command
            .orElse(commandManager.getPublicHelpCommand() // 2. help command
                    .orElse(cli -> CommandOutcome.succeeded())); // 3. placeholder noop command
}
 
开发者ID:bootique,项目名称:bootique,代码行数:17,代码来源:DefaultRunner.java


示例19: testModules_CircularOverrides

import io.bootique.command.CommandOutcome; //导入依赖的package包/类
@Test
public void testModules_CircularOverrides() {
    CommandOutcome out = Bootique.app()
            .module(new ModuleProviderWithOverride1())
            .module(new ModuleProviderWithOverride2())
            .exec();

    assertEquals(1, out.getExitCode());
    assertNull(out.getException());

    final String outMessage = out.getMessage();

    assertTrue(
        "Circular override dependency between DI modules: ModuleWithOverride2 -> ModuleWithOverride1 -> ModuleWithOverride2".equals(outMessage) ||
            "Circular override dependency between DI modules: ModuleWithOverride1 -> ModuleWithOverride2 -> ModuleWithOverride1".equals(outMessage)
    );
}
 
开发者ID:bootique,项目名称:bootique,代码行数:18,代码来源:BootiqueExceptionsHandlerIT.java


示例20: testExec_Failure

import io.bootique.command.CommandOutcome; //导入依赖的package包/类
@Test
public void testExec_Failure() {
    CommandOutcome outcome = Bootique.app("-a").module(b ->
            BQCoreModule.extend(b).addCommand(new Command() {
                @Override
                public CommandOutcome run(Cli cli) {
                    return CommandOutcome.failed(-1, "it failed");
                }

                @Override
                public CommandMetadata getMetadata() {
                    return CommandMetadata.builder("acommand").build();
                }
            })
    ).exec();

    assertFalse(outcome.isSuccess());
    assertEquals(-1, outcome.getExitCode());
    assertEquals("it failed", outcome.getMessage());
}
 
开发者ID:bootique,项目名称:bootique,代码行数:21,代码来源:BootiqueIT.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HFileOutputFormat2类代码示例发布时间:2022-05-22
下一篇:
Java Extension类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap