Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package io.dropwizard;
 
The base class for Dropwizard applications.

Parameters:
<T> the type of configuration class for this application
public abstract class Application<T extends Configuration> {
    static {
        // make sure spinning up Hibernate Validator doesn't yell at us
        LoggingFactory.bootstrap();
    }

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

    public final Class<T> getConfigurationClass() {
        return Generics.getTypeParameter(getClass(), Configuration.class);
    }

    
Returns the name of the application.

Returns:
the application's name
    public String getName() {
        return getClass().getSimpleName();
    }

    
Initializes the application bootstrap.

Parameters:
bootstrap the application bootstrap
    public void initialize(Bootstrap<T> bootstrap) {
    }

    
When the application runs, this is called after the Bundles are run. Override it to add providers, resources, etc. for your application.

Parameters:
configuration the parsed Configuration object
environment the application's io.dropwizard.setup.Environment
Throws:
java.lang.Exception if something goes wrong
    public abstract void run(T configurationEnvironment environmentthrows Exception;

    
Parses command-line arguments and runs the application. Call this method from a public static void main entry point in your application.

Parameters:
arguments the command-line arguments
Throws:
java.lang.Exception if something goes wrong
    public void run(String... argumentsthrows Exception {
        final Bootstrap<T> bootstrap = new Bootstrap<>(this);
        bootstrap.addCommand(new ServerCommand<>(this));
        bootstrap.addCommand(new CheckCommand<>(this));
        initialize(bootstrap);
        final Cli cli = new Cli(new JarLocation(getClass()), bootstrap..);
        if (!cli.run(arguments)) {
            // only exit if there's an error running the command
            System.exit(1);
        }
    }
New to GrepCode? Check out our FAQ X