public interface ExtensionManager
Extensions available in the current context and their state.
Going beyond the introspection model defined by Extension, Configuration
and Operation class, at runtime there will be instances implementing the extension
components modeled by them. Those instances need to be registered with this manager in order to be used.
The workflow for this manager would be to first discover the currently available extensions
through discoverExtensions(ClassLoader). Additionally, Extension instances
can also be added in runtime through registerExtension(Extension).
Instances serving as realization of a Configuration model need to be registered
with the registerConfigurationInstanceProvider(String, ConfigurationInstanceProvider)
method in orderfor this manager to provision the underlying infrastructure to host and execute such configuration.
Oncea configuration is registered, then operations can be executed with it by requesting a OperationExecutor
to the getOperationExecutor(String, OperationContext) or getOperationExecutor(OperationContext)
methods| Modifier and Type | Method and Description |
|---|---|
List<Extension> |
discoverExtensions(ClassLoader classLoader)
Scans the classpath visible to the given
ClassLoader and registers them. |
Set<Extension> |
getExtensions()
|
<C> Set<Extension> |
getExtensionsCapableOf(Class<C> capability)
|
OperationExecutor |
getOperationExecutor(OperationContext operationContext)
|
OperationExecutor |
getOperationExecutor(String configurationInstanceProviderName,
OperationContext operationContext)
|
<C> void |
registerConfigurationInstanceProvider(String providerName,
ConfigurationInstanceProvider<C> configurationInstanceProvider)
Registers the
configurationInstanceProvider. |
boolean |
registerExtension(Extension extension)
|
List<Extension> discoverExtensions(ClassLoader classLoader)
ClassLoader and registers them.
The discovery process works as follows:
Describer interfaceExtensionFactory and transformed in Extension instancesregisterExtension(Extension) methodList will be returned with the Extensions
that were registered or modified. For instance, the first time this method is invoked, all the discovered extensions
will be returned. If it's then called again, the extensions that are already registered will not be present
in the newly returned list, only those that were not there the first time or that were modified. If no extensions
are found, or nothing has changed since the last discovery, then an empty list is returnedclassLoader - a not null ClassLoader in which to search for extensionsList with the registered or updated Extensions or
an empty list if none is found or updatedboolean registerExtension(Extension extension)
Extension
If a matching Extension is already registered,
then this manager will apply whatever policy finds more convenient to decide if the existing
registration is kept or replaced. That is up to the implementation. The only thing this contract
guarantees is that each extension type will be registered only once and that the discovery process
will not fail if many discovery runs are triggered over the same classpath.extension - the Extension to be registered. Cannot be nulltrue if the extension was registered. false if the platform decided
to kept an existing declaration<C> void registerConfigurationInstanceProvider(String providerName, ConfigurationInstanceProvider<C> configurationInstanceProvider)
configurationInstanceProvider.
The provider can later be referenced by the given
providerNameC - the type of the configurations instances that configurationInstanceProvider providesproviderName - the name under which the configurationInstanceProvider will be referencedconfigurationInstanceProvider - a ConfigurationInstanceProviderOperationExecutor getOperationExecutor(String configurationInstanceProviderName, OperationContext operationContext)
OperationExecutor to execute the
Operation that is referenced by operationContext.
This method also requires referencing the ConfigurationInstanceProvider
that will be used to obtain a configuration instance. That reference
is done through the configurationInstanceProviderName parameter
which must point to a ConfigurationInstanceProvider previously
registered through registerConfigurationInstanceProvider(String, ConfigurationInstanceProvider)configurationInstanceProviderName - the name of the ConfigurationInstanceProvider used to obtain a configuration instanceoperationContext - a OperationContextOperationExecutorOperationExecutor getOperationExecutor(OperationContext operationContext)
OperationExecutor to execute the Operation
that is referenced by operationContext.
Because this method makes no reference to a particular
ConfigurationInstanceProvider, the platform will choose
one by following criteria:
ConfigurationInstanceProvider was registered
through registerConfigurationInstanceProvider(String, ConfigurationInstanceProvider)
for the Extension that owns the Operation, then that provider will be usedIllegalStateException will be thrownConfigurationInstanceProvider was registered, then the platform
will evaluate all the Configurations on the Extension looking for those
which can be created implicitly. If any are found, then the first one is selected and a
ConfigurationInstanceProvider will be created and registered for it.
Configuration can be created implicitly
if for all its Parameters it can be said that they're optional
or/and have a default value. In such case, the platform will create an
instance which respects those defaults and has null values for
the rest of the parameters.operationContext - a OperationContextOperationExecutorCopyright © 2015 MuleSoft, Inc.. All rights reserved.