Class DynamicMap<T>
java.lang.Object
com.google.gerrit.extensions.registration.DynamicMap<T>
- Direct Known Subclasses:
PrivateInternals_DynamicMapImpl
A map of members that can be modified as plugins reload.
Maps index their members by plugin name and export name.
DynamicMaps are always mapped as singletons in Guice. Maps store Providers internally, and resolve the provider to an instance on demand. This enables registrations to decide between singleton and non-singleton members.
-
Method Summary
Modifier and TypeMethodDescriptionNavigableMap<String,
com.google.inject.Provider<T>> Get the items exported by a single plugin.static <T> DynamicMap<T>
emptyMap()
Returns an empty DynamicMap instance *Lookup an implementation by name.iterator()
Iterate through all entries in an undefined order.static <T> void
mapOf
(com.google.inject.Binder binder, com.google.inject.TypeLiteral<T> member) Declare a singletonDynamicMap<T>
with a binder.static <T> void
Declare a singletonDynamicMap<T>
with a binder.plugins()
Get the names of all running plugins supplying this type.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
mapOf
Declare a singletonDynamicMap<T>
with a binder.Maps must be defined in a Guice module before they can be bound:
DynamicMap.mapOf(binder(), Interface.class); bind(Interface.class) .annotatedWith(Exports.named("foo")) .to(Impl.class);
- Parameters:
binder
- a new binder created in the module.member
- type of value in the map.
-
mapOf
public static <T> void mapOf(com.google.inject.Binder binder, com.google.inject.TypeLiteral<T> member) Declare a singletonDynamicMap<T>
with a binder.Maps must be defined in a Guice module before they can be bound:
DynamicMap.mapOf(binder(), new TypeLiteral<Thing<Bar>>(){}); bind(new TypeLiteral<Thing<Bar>>() {}) .annotatedWith(Exports.named("foo")) .to(Impl.class);
- Parameters:
binder
- a new binder created in the module.member
- type of value in the map.
-
emptyMap
Returns an empty DynamicMap instance * -
get
Lookup an implementation by name.- Parameters:
pluginName
- local name of the plugin providing the item.exportName
- name the plugin exports the item as.- Returns:
- the implementation. Null if the plugin is not running, or if the plugin does not export this name.
- Throws:
com.google.inject.ProvisionException
- if the registered provider is unable to obtain an instance of the requested implementation.
-
plugins
Get the names of all running plugins supplying this type.- Returns:
- navigatable set of active plugins that supply at least one item.
-
byPlugin
Get the items exported by a single plugin.- Parameters:
pluginName
- name of the plugin.- Returns:
- items exported by a plugin, keyed by the export name.
-
iterator
Iterate through all entries in an undefined order.
-