Last active
April 12, 2016 14:10
-
-
Save andrus/45014b1a89ac893923ee3fe28780eb9b to your computer and use it in GitHub Desktop.
Bootique tip of the day: calling services directly bypassing commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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