Skip to content

Instantly share code, notes, and snippets.

@cemo
Created September 28, 2014 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cemo/2242a1149f6413576353 to your computer and use it in GitHub Desktop.
Save cemo/2242a1149f6413576353 to your computer and use it in GitHub Desktop.
public abstract class SpringApplication<T extends SpringConfiguration> extends Application<T> {
/**
* When the application runs, this is called after the {@link io.dropwizard.Bundle}s are run. Override it to add
* providers, resources, etc. for your application.
*
* @param configuration the parsed {@link io.dropwizard.Configuration} object
* @param environment the application's {@link io.dropwizard.setup.Environment}
* @throws Exception if something goes wrong
*/
public abstract void run(T configuration, SpringEnvironment environment) throws Exception;
public final void run(T configuration, Environment environment) {}
/**
* Parses command-line arguments and runs the application. Call this method from a {@code public
* static void main} entry point in your application.
*
* @param arguments the command-line arguments
* @throws Exception if something goes wrong
*/
public final void runSpring(String[] arguments) throws Exception {
final Bootstrap<T> bootstrap = new Bootstrap<>(this);
bootstrap.addCommand(new SpringServerCommand<>(this));
bootstrap.addCommand(new CheckCommand<>(this));
initialize(bootstrap);
final Cli cli = new Cli(new JarLocation(getClass()), bootstrap, System.out, System.err);
if (!cli.run(arguments)) {
// only exit if there's an error running the command
System.exit(1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment