| Interface | Description |
|---|---|
| ParameterKeys |
Useful
Keys for binding Parameters. |
| WireModule.Strategy |
Wiring strategy.
|
| Wiring |
Something that can supply bindings for unresolved dependency
Keys. |
| Class | Description |
|---|---|
| AbstractTypeConverter<T> |
Abstract
TypeConverter Module that automatically registers the converter based on the type argument. |
| ChildWireModule |
Child
WireModule that avoids wiring dependencies that already exist in a parent Injector. |
| EntryListAdapter<V> | |
| EntryMapAdapter<K,V> | |
| EntrySetAdapter<V> | |
| LocatorWiring |
Adds
BeanLocator-backed bindings for unresolved bean dependencies. |
| MergedModule |
Guice
Module that discards any duplicate or broken bindings. |
| WireModule |
Guice
Module that automatically adds BeanLocator-backed bindings for unresolved dependencies. |
The WireModule should enclose all modules in your application:
Guice.createInjector( new WireModule( bootModule, configModule, mainModule ) );Use the
ChildWireModule when you want to wire child injectors:
injector.createChildInjector( new ChildWireModule( serviceModule, subModule ) );
LocatorWiring which can supply the following bindings via the BeanLocator:
@Inject MyType bean
@Inject @Named("hint") MyType namedBean
@Inject @MyQualifier MyType qualifiedBean
@Inject Provider<MyType> beanProvider
@Inject @Named("${my.property.name}") File file // supports basic type conversion
@Inject @Named("${my.property.name:-http://example.org/}") URL url // can give default in case property is not set
@Inject @Named("${my.property.name:-development}") MyType bean // can be used to pick specific @Named beans
@Inject @Named("my.property.name") int port // shorthand syntax
You can bind your configuration at runtime as follows:
bind( ParameterKeys.PROPERTIES ).toInstance( myConfiguration ); // multiple bindings are merged into one view
BeanLocator.
They are also lazy, meaning instances are created as you access elements of the collection; the elements are then re-used for the same collection.
@Inject List<MyType> list
@Inject List<Provider<MyType>> providers
@Inject Iterable<BeanEntry<MyQualifier, MyType>> entries // gives access to additional metadata
@Inject Map<String, MyType> stringMap // strings are taken from @Named values @Inject Map<Named, MyType> namedMap @Inject Map<MyQualifier, MyType> qualifiedMap @Inject Map<String, Provider<MyType>> providerMap
Copyright © 2016. All Rights Reserved.