org.eclipse.jetty.util.component.ContainerLifeCycle Java Examples

The following examples show how to use org.eclipse.jetty.util.component.ContainerLifeCycle. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AllTablesReportCommand.java    From emodb with Apache License 2.0 5 votes vote down vote up
@Override
protected void run(Environment environment, Namespace namespace, EmoConfiguration configuration)
        throws Exception {
    String id = namespace.getString("id");

    AllTablesReportOptions options = new AllTablesReportOptions();
    options.setReadOnly(namespace.getBoolean("readOnly"));

    List<String> placements = namespace.getList("placements");
    if (placements != null && !placements.isEmpty()) {
        options.setPlacements(ImmutableSet.copyOf(placements));
    }

    Integer shardId = namespace.getInt("shard");
    if (shardId != null) {
        options.setFromShardId(shardId);
    }

    String table = namespace.getString("table");
    if (table != null) {
        options.setFromTableUuid(TableUuidFormat.decode(table));
    }

    Injector injector = Guice.createInjector(new EmoModule(configuration, environment, EmoServiceMode.CLI_TOOL));

    ContainerLifeCycle containerLifeCycle = new ContainerLifeCycle();
    environment.lifecycle().attach(containerLifeCycle);
    containerLifeCycle.start();
    try {
        AllTablesReportGenerator generator = injector.getInstance(AllTablesReportGenerator.class);
        AllTablesReportResult result = generator.runReport(id, options);

        System.out.println(result);
    } finally {
        containerLifeCycle.stop();
    }
}
 
Example #2
Source File: TestCommand.java    From dropwizard-guicey with MIT License 5 votes vote down vote up
@Override
protected void run(final Environment environment, final Namespace namespace,
                   final C configuration) throws Exception {
    // simulating managed objects lifecycle support
    container = new ContainerLifeCycle();
    environment.lifecycle().attach(container);
    container.start();
}