Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.yammer.dropwizard.cli;
A command whose first parameter is the location of a YAML configuration file. That file is parsed into an instance of a com.yammer.dropwizard.config.Configuration subclass, which is then validated. If the configuration is valid, the command is run.

<T> the com.yammer.dropwizard.config.Configuration subclass which is loaded from the configuration file
See also:
public abstract class ConfiguredCommand<T extends Configurationextends Command {
    protected ConfiguredCommand(String nameString description) {

Returns the java.lang.Class of the configuration type.

the java.lang.Class of the configuration type
    protected Class<T> getConfigurationClass() {
        return Generics.getTypeParameter(getClass(), Configuration.class);

Configure the command's net.sourceforge.argparse4j.inf.Subparser.

N.B.: if you override this method, you must call super.override(subparser) in order to preserve the configuration file parameter in the subparser.

subparser the net.sourceforge.argparse4j.inf.Subparser specific to the command
    public void configure(Subparser subparser) {
        subparser.addArgument("file").nargs("?").help("service configuration file");
    public final void run(Bootstrap<?> bootstrapNamespace namespacethrows Exception {
        final T configuration = parseConfiguration(namespace.getString("file"),
        if (configuration != null) {
            new LoggingFactory(configuration.getLoggingConfiguration(),
        run((Bootstrap<T>) bootstrapnamespaceconfiguration);

Runs the command with the given com.yammer.dropwizard.config.Bootstrap and com.yammer.dropwizard.config.Configuration.

bootstrap the bootstrap bootstrap
namespace the parsed command line namespace
configuration the configuration object
java.lang.Exception if something goes wrong
    protected abstract void run(Bootstrap<T> bootstrap,
                                Namespace namespace,
                                T configurationthrows Exception;
    private T parseConfiguration(String filename,
                                 Class<T> configurationClass,
                                 ObjectMapperFactory objectMapperFactorythrows IOExceptionConfigurationException {
        final ConfigurationFactory<T> configurationFactory =
                ConfigurationFactory.forClass(configurationClassnew Validator(), objectMapperFactory);
        if (filename != null) {
            final File file = new File(filename);
            if (!file.exists()) {
                throw new FileNotFoundException("File " + file + " not found");
New to GrepCode? Check out our FAQ X