Skip to content

Instantly share code, notes, and snippets.

@andrus
Last active April 12, 2016 14:10
Show Gist options
  • Save andrus/45014b1a89ac893923ee3fe28780eb9b to your computer and use it in GitHub Desktop.
Save andrus/45014b1a89ac893923ee3fe28780eb9b to your computer and use it in GitHub Desktop.
Bootique tip of the day: calling services directly bypassing commands
public class App {
public static void main(String[] args) {
// "Imperative" Bootique style...
// While generally you need to setup command dispatch mechanism to run
// your app, here is an example of "imperative" Bootique. Instead of
// calling Bootique.run(), we create a runtime, get a service out of it,
// and call some methods.
// create runtime, but don't run it
BQRuntime runtime = Bootique.app(args).autoLoadModules().createRuntime();
// get any service from DI container
ConfigurationFactory factory = runtime.getInstance(ConfigurationFactory.class);
// do something with this service
factory.config(String.class, "config.prefix");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment