public interface PluginRegistry
Plugins.
This allows you to require plugins as dependencies and also retrieve registered plugin instances. Note that only one instance of a specific plugin can be registered.
| Modifier and Type | Method and Description |
|---|---|
void |
register(Iterable<? extends Plugin> plugins)
Registers
Plugin instances to this PluginRegistry. |
void |
register(Plugin plugin)
Registers a single
Plugin. |
<T extends Plugin> |
require(Class<T> klass)
Specifies that a particular plugin is required as a dependency.
|
<T extends Plugin> |
require(Class<T> klass,
Supplier<T> supplier)
Same as
require(Class), except this should be used for custom (non-library-provided) plugins. |
<T extends Plugin> |
retrieve(Class<T> klass)
Retrieves the instance of the given
Plugin type. |
void register(Iterable<? extends Plugin> plugins)
Plugin instances to this PluginRegistry.
Only one instance of a specific Plugin can be registered to a single PluginRegistry. This is to
make require(Class) and retrieve(Class) work in a simple way. Plugins should be coded with
this in mind.
plugins - The Plugin(s) to register.void register(Plugin plugin)
Plugin.
Only one instance of a specific Plugin can be registered to a single PluginRegistry. This is to
make require(Class) and retrieve(Class) work in a simple way. Plugins should be coded with
this in mind.
plugin - The plugin to register.<T extends Plugin> T require(Class<T> klass)
If the plugin is already registered then the registered instance will simply be returned. If the plugin is not registered then a new instance will be created, registered, then returned.
This method is only for library-provided plugins. To require a custom plugin, use require(Class, Supplier)
instead.
This method is usually used within the DependentPlugin#dependencies(PluginRegistry) method.
Examples:
registry.require(SyntaxTree.class)registry.require(UrlPlugin.class)
T - Type of the plugin.klass - The plugin class.<T extends Plugin> T require(Class<T> klass, Supplier<T> supplier)
require(Class), except this should be used for custom (non-library-provided) plugins.
The Supplier is used to get an instance if one is not already registered. This method is usually used within the
DependentPlugin#dependencies(PluginRegistry) method.
T - Type of the plugin.klass - The plugin class.supplier - Supplies an instance of the plugin.Copyright (c) 2019, Salesforce.com, Inc. All rights reserved. Licensed under the BSD 3-Clause license. For full license text, see the LICENSE file in the repository.