Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Sisu/Techniques"
< Sisu
m (→How to add specific bindings to the basic example) |
m |
||
(One intermediate revision by the same user not shown) | |||
Line 24: | Line 24: | ||
@Provides | @Provides | ||
− | |||
WsBusConfig config() { | WsBusConfig config() { | ||
return new WsBusConfig(configFilePathname); | return new WsBusConfig(configFilePathname); | ||
Line 31: | Line 30: | ||
Injector injector = Guice.createInjector( | Injector injector = Guice.createInjector( | ||
− | + | ||
new WireModule(// auto-wires unresolved dependencies | new WireModule(// auto-wires unresolved dependencies | ||
+ | parameterModule, | ||
new SpaceModule(// scans and binds @Named components | new SpaceModule(// scans and binds @Named components | ||
new URLClassSpace(classloader) // abstracts class/resource finding | new URLClassSpace(classloader) // abstracts class/resource finding | ||
Line 40: | Line 40: | ||
} | } | ||
</nowiki> | </nowiki> | ||
+ | |||
+ | [[Category:Sisu]] |
Latest revision as of 22:00, 7 February 2014
How to add specific bindings to the basic Sisu example
Here is an expanded version of the 'getting started' tutorial that adds an additional module to publish some scalar parameters.
public static BusBootstrap Main(final String[] cliArguments, final String configFilePathname) { ClassLoader classloader = BusBootstrap.class.getClassLoader(); AbstractModule parameterModule = new AbstractModule() { @Override protected void configure() { // Add EDSL binding calls here. } @Provides @Parameters String[] cliArguments() { return cliArguments; } @Provides WsBusConfig config() { return new WsBusConfig(configFilePathname); } }; Injector injector = Guice.createInjector( new WireModule(// auto-wires unresolved dependencies parameterModule, new SpaceModule(// scans and binds @Named components new URLClassSpace(classloader) // abstracts class/resource finding ))); return injector.getInstance(BusBootstrap.class); }