Package org.eclipse.sisu.wire
Customizable wiring of unresolved dependencies. Use this to share components across injectors, apply configuration, and form on-demand collections.
The default wiring strategy is to use
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 ) );
The default wiring strategy is to use
LocatorWiring which can supply the following bindings via the BeanLocator:
Instances
@Inject MyType bean
@Inject @Named("hint") MyType namedBean
@Inject @MyQualifier MyType qualifiedBean
@Inject Provider<MyType> beanProvider
Configuration
@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
Collections
The following collections are both dynamic and thread-safe, elements may come and go as injectors are added or removed from theBeanLocator.
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
-
Interface Summary Interface Description ParameterKeys UsefulKeys for bindingParameters.WireModule.Strategy Wiring strategy.Wiring Something that can supply bindings for unresolved dependencyKeys. -
Class Summary Class Description AbstractTypeConverter<T> AbstractTypeConverterModulethat automatically registers the converter based on the type argument.BeanProviders Supplies various beanProviders backed by dynamic bean lookups.ChildWireModule ChildWireModulethat avoids wiring dependencies that already exist in a parentInjector.DependencyAnalyzer BindingTargetVisitorthat collects theKeys of any injected dependencies.DependencyVerifier BindingTargetVisitorthat verifies any injected dependencies.DynamicGlue Utility methods for generating dynamicProvider-based proxies.ElementAnalyzer ElementVisitorthat analyzesBindings for unresolved injection dependencies.ElementMerger ElementVisitorthat verifiesBindings and merges any duplicates.EntryListAdapter<V> Listbacked by anIterablesequence of map entries.EntryListAdapter.ValueIterator<V> ValueIteratorbacked by a Key:ValueIterator.EntryListAdapter.ValueListIterator<V> ValueListIteratorbacked by a cached Key:ValueIterator.EntryMapAdapter<K,V> Mapbacked by anIterablesequence of map entries.EntryMapAdapter.EntrySet<K,V> EntrySetbacked by anIterablesequence of map entries.EntrySetAdapter<V> Setbacked by anIterablesequence of map entries.EntrySetAdapter.ValueIterator<V> ValueIteratorbacked by a Key:ValueIterator.FileTypeConverter TypeConverterModulethat converts constants toFiles.GlueLoader Weak cache ofClassLoaders that can generate proxy classes on-demand.LocatorWiring AddsBeanLocator-backed bindings for unresolved bean dependencies.MergedModule GuiceModulethat discards any duplicate or broken bindings.MergedProperties DelegatingMapthat merges a series ofMaps into one consistent view.NamedIterableAdapter<V> String mappingIterablebacked by aNamedmappingIterable.NamedIterableAdapter.NamedEntry<V> String mappingMap.Entrybacked by aNamedmappingMap.Entry.NamedIterableAdapter.NamedIterator<V> String mappingIteratorbacked by aNamedmappingIterator.PlaceholderBeanProvider<V> Provides a single bean; the name used to lookup/convert the bean is selected at runtime.ProviderIterableAdapter<K extends java.lang.annotation.Annotation,V> ProviderIterableAdapter.ProviderEntry<K extends java.lang.annotation.Annotation,V> ProviderIterableAdapter.ProviderIterator<K extends java.lang.annotation.Annotation,V> StringProperties DelegatingMapthat ignores any non-String properties.TypeConverterCache Lazy cache of knownTypeConverters.URLTypeConverter TypeConverterModulethat converts constants toURLs.WireModule GuiceModulethat automatically addsBeanLocator-backed bindings for unresolved dependencies.