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

Java Command类代码示例

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

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



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

示例1: command_binds_work

import io.dropwizard.cli.Command; //导入依赖的package包/类
@Test
public void command_binds_work() {
    final Command command = mock(Command.class);
    final Class<TestCommand> commandClass = TestCommand.class;

    Injector injector = Guice.createInjector(new AbstractPlugin() {
        @Override
        protected void configure() {
            bindCommand(command);
            bindCommand(commandClass);
        }
    });

    Set<Command> commandSet = injector.getInstance(Keys.Commands);
    Set<Class<? extends Command>> commandClassSet = injector.getInstance(Keys.CommandClasses);

    assertThat(commandSet, hasSize(1));
    assertThat(commandSet, hasItem(command));
    assertThat(commandClassSet, hasSize(1));
    assertThat(commandClassSet, hasItem(TestCommand.class));
}
 
开发者ID:graceland,项目名称:graceland-core,代码行数:22,代码来源:AbstractPluginTest.java


示例2: initialize_adds_commands

import io.dropwizard.cli.Command; //导入依赖的package包/类
@Test
public void initialize_adds_commands() {
    final Command command = mock(Command.class);
    final Class<TestCommand> commandClass = TestCommand.class;

    Application application = buildApplication(
            new AbstractPlugin() {
                @Override
                protected void configure() {
                    bindCommand(command);
                    bindCommand(commandClass);
                }
            }
    );

    new Platform(application).initialize(bootstrap);

    verify(bootstrap).addCommand(eq(command));
    verify(bootstrap).addCommand(isA(TestCommand.class));
}
 
开发者ID:graceland,项目名称:graceland-core,代码行数:21,代码来源:PlatformTest.java


示例3: addCommand

import io.dropwizard.cli.Command; //导入依赖的package包/类
private void addCommand(Subparser subparser, Command command) {
    commands.put(command.getName(), command);
    subparser.addSubparsers().help("available commands");

    final Subparser commandSubparser =
            subparser.addSubparsers().addParser(command.getName(), false);

    command.configure(commandSubparser);

    commandSubparser.addArgument("-h", "--help")
            .action(new HelpArgumentAction())
            .help("show this help message and exit")
            .setDefault(Arguments.SUPPRESS);

    commandSubparser.description(command.getDescription())
            .setDefault(COMMAND_NAME_ATTR, command.getName())
            .defaultHelp(true);
}
 
开发者ID:adamkewley,项目名称:jobson,代码行数:19,代码来源:HierarchicalCommand.java


示例4: generateSubCommands

import io.dropwizard.cli.Command; //导入依赖的package包/类
private static SortedMap<String, Command> generateSubCommands() {
    final SortedMap<String, Command> commands = new TreeMap<>();
    final UseraddCommand useraddCommand = new UseraddCommand();
    commands.put(useraddCommand.getName(), useraddCommand);
    final PasswdCommand passwdCommand = new PasswdCommand();
    commands.put(passwdCommand.getName(), passwdCommand);
    return commands;
}
 
开发者ID:adamkewley,项目名称:jobson,代码行数:9,代码来源:UsersCommand.java


示例5: generateSubCommands

import io.dropwizard.cli.Command; //导入依赖的package包/类
private static SortedMap<String, Command> generateSubCommands() {
    final SortedMap<String, Command> commands = new TreeMap<>();
    final GenerateRequestCommand generateRequestCommand = new GenerateRequestCommand();
    commands.put(generateRequestCommand.getName(), generateRequestCommand);
    final GenerateSpecsCommand generateSpecsCommand = new GenerateSpecsCommand();
    commands.put(generateSpecsCommand.getName(), generateSpecsCommand);
    return commands;
}
 
开发者ID:adamkewley,项目名称:jobson,代码行数:9,代码来源:GenerateCommand.java


示例6: initialize

import io.dropwizard.cli.Command; //导入依赖的package包/类
@Override
public void initialize(Bootstrap<?> bootstrap) {
    this.application = bootstrap.getApplication();

    listServices(Bundle.class).forEach(bootstrap::addBundle);
    listServices(ConfiguredBundle.class).forEach(bootstrap::addBundle);
    listServices(Command.class).forEach(bootstrap::addCommand);
}
 
开发者ID:alex-shpak,项目名称:dropwizard-hk2bundle,代码行数:9,代码来源:HK2Bundle.java


示例7: runDropwizardCommandUsingConfig

import io.dropwizard.cli.Command; //导入依赖的package包/类
/**
 * Runs a command for the {@link TestApplication} with the given yaml configuration.
 *
 * @param yamlConfig a <code>String</code> containing the yaml configuration
 * @return the TestApplication if successful
 * @throws Exception if the command failed
 */
public static TestApplication runDropwizardCommandUsingConfig(final String yamlConfig,
        final Function<TestApplication, Command> commandInstantiator) throws Exception {
    final TestApplication application = new TestApplication();
    final Bootstrap<TestConfiguration> bootstrap = new Bootstrap<>(application);
    bootstrap.setConfigurationSourceProvider(new StringConfigurationSourceProvider());
    final Command command = commandInstantiator.apply(application);
    command.run(bootstrap, new Namespace(Collections.singletonMap("file", yamlConfig)));
    return application;
}
 
开发者ID:msteinhoff,项目名称:dropwizard-grpc,代码行数:17,代码来源:Utils.java


示例8: main

import io.dropwizard.cli.Command; //导入依赖的package包/类
public static void main(String[] args)
{
    System.out.println("This is simply a way of making sure things compile");
    Command ec = new Command("Stuff", "Things"){

        @Override
        public void configure(Subparser subparser){}
        

        @Override
        public void run(Bootstrap<?> bootstrap, Namespace namespace) throws Exception{}
        
    };
    System.out.println("" + ec.getName());
}
 
开发者ID:Spedge,项目名称:hangar,代码行数:16,代码来源:Project1.java


示例9: printCommands

import io.dropwizard.cli.Command; //导入依赖的package包/类
private void printCommands(final DiagnosticConfig config, final StringBuilder res) {
    final List<Class<Command>> commands = service.getCommands();
    if (!config.isPrintCommands() || commands.isEmpty()) {
        return;
    }
    // modules will never be empty
    res.append(NEWLINE).append(NEWLINE).append(TAB).append("COMMANDS = ").append(NEWLINE);
    final List<String> markers = Lists.newArrayList();
    for (Class<Command> command : commands) {
        markers.clear();
        final CommandItemInfo info = service.getData().getInfo(command);
        commonMarkers(markers, info);
        if (info.isEnvironmentCommand()) {
            markers.add("GUICE_ENABLED");
        }
        res.append(TAB).append(TAB).append(renderClassLine(command, markers)).append(NEWLINE);
    }
}
 
开发者ID:xvik,项目名称:dropwizard-guicey,代码行数:19,代码来源:DiagnosticRenderer.java


示例10: registerCommands

import io.dropwizard.cli.Command; //导入依赖的package包/类
/**
 * Register commands resolved with classpath scan.
 *
 * @param commands installed commands
 * @see ru.vyarus.dropwizard.guice.GuiceBundle.Builder#searchCommands()
 */
public void registerCommands(final List<Class<Command>> commands) {
    setScope(ClasspathScanner.class);
    for (Class<Command> cmd : commands) {
        register(ConfigItem.Command, cmd);
    }
    closeScope();
}
 
开发者ID:xvik,项目名称:dropwizard-guicey,代码行数:14,代码来源:ConfigurationContext.java


示例11: initCommands

import io.dropwizard.cli.Command; //导入依赖的package包/类
/**
 * Inject dependencies into all registered environment commands. (only field and setter injection could be used)
 * There is no need to process other commands, because only environment commands will run bundles and so will
 * start the injector.
 *
 * @param commands registered commands
 * @param injector guice injector object
 * @param tracker  stats tracker
 */
public static void initCommands(final List<Command> commands, final Injector injector,
                                final StatsTracker tracker) {
    final Stopwatch timer = tracker.timer(CommandTime);
    if (commands != null) {
        for (Command cmd : commands) {
            if (cmd instanceof EnvironmentCommand) {
                injector.injectMembers(cmd);
            }
        }
    }
    timer.stop();
}
 
开发者ID:xvik,项目名称:dropwizard-guicey,代码行数:22,代码来源:CommandSupport.java


示例12: buildBinders

import io.dropwizard.cli.Command; //导入依赖的package包/类
private void buildBinders() {
    if (!bindersBuilt) {
        jerseyBinder = Multibinder.newSetBinder(binder(), Object.class, Graceland.class);
        managedBinder = Multibinder.newSetBinder(binder(), Managed.class, Graceland.class);
        managedClassBinder = Multibinder.newSetBinder(binder(), TypeLiterals.ManagedClass, Graceland.class);
        healthCheckBinder = Multibinder.newSetBinder(binder(), HealthCheck.class, Graceland.class);
        healthCheckClassBinder = Multibinder.newSetBinder(binder(), TypeLiterals.HealthCheckClass, Graceland.class);
        taskBinder = Multibinder.newSetBinder(binder(), Task.class, Graceland.class);
        taskClassBinder = Multibinder.newSetBinder(binder(), TypeLiterals.TaskClass, Graceland.class);
        bundleBinder = Multibinder.newSetBinder(binder(), Bundle.class, Graceland.class);
        bundleClassBinder = Multibinder.newSetBinder(binder(), TypeLiterals.BundleClass, Graceland.class);
        commandBinder = Multibinder.newSetBinder(binder(), Command.class, Graceland.class);
        commandClassBinder = Multibinder.newSetBinder(binder(), TypeLiterals.CommandClass, Graceland.class);
        initializerBinder = Multibinder.newSetBinder(binder(), Initializer.class, Graceland.class);
        initializerClassBinder = Multibinder.newSetBinder(binder(), TypeLiterals.InitializerClass, Graceland.class);
        configuratorBinder = Multibinder.newSetBinder(binder(), Configurator.class, Graceland.class);
        configuratorClassBinder = Multibinder.newSetBinder(binder(), TypeLiterals.ConfiguratorClass, Graceland.class);

        bindersBuilt = true;
    }
}
 
开发者ID:graceland,项目名称:graceland-core,代码行数:22,代码来源:AbstractPlugin.java


示例13: initialize

import io.dropwizard.cli.Command; //导入依赖的package包/类
/**
 * Ran when the Dropwizard service initializes. This method is responsible for setting up the
 * {@link io.dropwizard.Bundle}s and {@link io.dropwizard.cli.Command}s.
 *
 * @param bootstrap Provided by Dropwizard.
 */
@Override
public void initialize(Bootstrap<PlatformConfiguration> bootstrap) {
    for (Initializer initializer : wrapper.getInitializers()) {
        initializer.initialize(bootstrap);
        LOGGER.debug("Registered Initializer: {}", initializer.getClass().getCanonicalName());
    }

    for (Bundle bundle : wrapper.getBundles()) {
        bootstrap.addBundle(bundle);
        LOGGER.debug("Registered Bundle: {}", bundle.getClass().getCanonicalName());
    }

    for (Command command : wrapper.getCommands()) {
        bootstrap.addCommand(command);
        LOGGER.debug("Registered Command: {}", command.getClass().getCanonicalName());
    }
}
 
开发者ID:graceland,项目名称:graceland-core,代码行数:24,代码来源:Platform.java


示例14: HierarchicalCommand

import io.dropwizard.cli.Command; //导入依赖的package包/类
protected HierarchicalCommand(String name, String description, SortedMap<String, Command> commands) {
    super(name, description);
    this.commands = commands;

}
 
开发者ID:adamkewley,项目名称:jobson,代码行数:6,代码来源:HierarchicalCommand.java


示例15: configure

import io.dropwizard.cli.Command; //导入依赖的package包/类
@Override
public void configure(Subparser subparser) {
    for (Map.Entry<String, Command> command : commands.entrySet()) {
        addCommand(subparser, command.getValue());
    }
}
 
开发者ID:adamkewley,项目名称:jobson,代码行数:7,代码来源:HierarchicalCommand.java


示例16: run

import io.dropwizard.cli.Command; //导入依赖的package包/类
@Override
protected void run(Bootstrap<ApplicationConfig> bootstrap, Namespace namespace, ApplicationConfig applicationConfig) throws Exception {
    final Command command = commands.get(namespace.getString(COMMAND_NAME_ATTR));
    command.run(bootstrap, namespace);
}
 
开发者ID:adamkewley,项目名称:jobson,代码行数:6,代码来源:HierarchicalCommand.java


示例17: generateSubCommands

import io.dropwizard.cli.Command; //导入依赖的package包/类
private static SortedMap<String, Command> generateSubCommands() {
    final SortedMap<String, Command> commands = new TreeMap<>();
    final ValidateSpecCommand validateSpecCommand = new ValidateSpecCommand();
    commands.put(validateSpecCommand.getName(), validateSpecCommand);
    return commands;
}
 
开发者ID:adamkewley,项目名称:jobson,代码行数:7,代码来源:ValidateCommand.java


示例18: getCommands

import io.dropwizard.cli.Command; //导入依赖的package包/类
/**
 * @return list of installed commands or empty list
 */
public List<Class<Command>> getCommands() {
    return commands;
}
 
开发者ID:xvik,项目名称:dropwizard-guicey,代码行数:7,代码来源:CommandSupport.java


示例19: bindCommand

import io.dropwizard.cli.Command; //导入依赖的package包/类
protected void bindCommand(Command command) {
    Preconditions.checkNotNull(command, "Command cannot be null.");
    buildBinders();
    commandBinder.addBinding().toInstance(command);
}
 
开发者ID:graceland,项目名称:graceland-core,代码行数:6,代码来源:AbstractPlugin.java


示例20: getCommands

import io.dropwizard.cli.Command; //导入依赖的package包/类
public ImmutableSet<Command> getCommands() {
    return getAndBuildInstances(Keys.Commands, Keys.CommandClasses);
}
 
开发者ID:graceland,项目名称:graceland-core,代码行数:4,代码来源:InjectorWrapper.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java PlatformEventNotifier类代码示例发布时间:2022-05-22
下一篇:
Java Solution类代码示例发布时间: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