Package org.ametys.runtime.plugin
Class PluginsManager
- java.lang.Object
-
- org.ametys.runtime.plugin.PluginsManager
-
public final class PluginsManager extends Object
The PluginManager is in charge to load and initialize plugins.
It gives access to the extension points.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PluginsManager.InactivityCause
Cause of the deactivation of a featurestatic class
PluginsManager.Status
PluginsManager status after initialization.
-
Field Summary
Fields Modifier and Type Field Description private static PluginsManager
__instance
private Map<String,Plugin>
_allPlugins
private Map<String,ComponentDefinition>
_components
private Collection<PluginIssue>
_errors
private Map<String,ExtensionPointDefinition>
_extensionPoints
private Map<String,Map<String,ExtensionDefinition>>
_extensions
private FeatureActivator
_featureActivator
private Map<String,Feature>
_features
private Map<String,PluginsManager.InactivityCause>
_inactiveFeatures
private Map<String,File>
_locations
private org.slf4j.Logger
_logger
private Map<String,Plugin>
_plugins
private Map<String,String>
_resourceURIs
private boolean
_safeMode
private PluginsManager.Status
_status
static String
FEATURE_ID_SEPARATOR
Separator between pluginName and featureNamestatic String
INCLUDED_FEATURES_CONTEXT_ATTRIBUTE
Context attribute containing the features to include.static String
PLUGIN_FILENAME
Plugin filenamestatic String
PLUGIN_NAME_REGEXP
The regexp to determine if a plugin name is correct (add ^ and $ as delimiters if this is your only test)static String
PLUGIN_NAMES_IGNORED
The regexp to determine if a plugin name is ignored (CVS or .* or *.bak or *.old)
-
Constructor Summary
Constructors Modifier Constructor Description private
PluginsManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
_addPlugin(Map<String,Plugin> plugins, String pluginName, File pluginDir, Collection<String> excludedPlugins)
private PluginsComponentManager
_enterSafeMode(ComponentManager parentCM, Context context, String contextPath)
private Configuration
_getComponentConfiguration(Configuration initialConfiguration, String contextPath, String pluginName, Collection<PluginIssue> errors)
private Configuration
_getConfigurationFromStream(String pluginName, InputStream is, String path, Collection<String> excludedPlugins)
private void
_initializeConfigurationComponentManager(String contextPath, FeatureActivator.PluginsInformation pluginsInfo, PluginsComponentManager configCM)
private void
_initResourceURIs()
private void
_loadComponents(PluginsComponentManager manager, Map<String,ComponentDefinition> components, String contextPath, Collection<PluginIssue> errors)
private void
_loadExtensionsPoint(PluginsComponentManager manager, String point, Map<String,ExtensionPointDefinition> extensionPoints, Map<String,Map<String,ExtensionDefinition>> extensionsDefinitions, String contextPath, Collection<PluginIssue> errors)
private void
_loadExtensionsPoints(PluginsComponentManager manager, Map<String,ExtensionPointDefinition> extensionPoints, Map<String,Map<String,ExtensionDefinition>> extensionsDefinitions, String contextPath, Collection<PluginIssue> errors)
private void
_loadRuntimeInit(PluginsComponentManager manager, Collection<PluginIssue> errors)
private void
_parseConfiguration(ConfigManager configManager, Map<String,Plugin> plugins, Map<String,Feature> features)
private Map<String,Plugin>
_parsePlugins(String contextPath, Collection<String> locations, Map<String,File> externalPlugins, Collection<String> excludedPlugins)
private void
_pluginError(String pluginName, String message, PluginIssue.PluginIssueCode code, Collection<String> excludedPlugins, Exception e)
private void
_setActivator(Context context)
Map<String,Plugin>
getAllPlugins()
Returns all existing plugins definitions.Set<String>
getBundledPluginsNames()
Returns a String array containing the names of the plugins bundled in jarsCollection<String>
getComponents()
Returns the components roles.Collection<PluginIssue>
getErrors()
Returns errors gathered during plugins loading.Map<String,Collection<String>>
getExtensionPoints()
Returns the extensions points and their extensionsMap<String,Feature>
getFeatures()
Returns loaded features declarations.Map<String,PluginsManager.InactivityCause>
getInactiveFeatures()
Returns inactive features id and cause of deactivation.static PluginsManager
getInstance()
Returns the shared instance of thePluginManager
File
getPluginLocation(String pluginName)
Returns the plugin filesystem location for the given plugin or null if the plugin is loaded from the classpath.Set<String>
getPluginNames()
Returns the names of the pluginsMap<String,Plugin>
getPlugins()
Returns active plugins declarations.String
getResourceURI(String pluginName)
Returns the base URI for the given plugin resources, or null if the plugin does not exist or is located in the file system.PluginsManager.Status
getStatus()
Returns the status after initialization.PluginsComponentManager
init(ComponentManager parentCM, Context context, String contextPath, boolean forceSafeMode)
Initialization of the plugin managerboolean
isSafeMode()
Returns true if the safe mode is activated.
-
-
-
Field Detail
-
PLUGIN_NAMES_IGNORED
public static final String PLUGIN_NAMES_IGNORED
The regexp to determine if a plugin name is ignored (CVS or .* or *.bak or *.old)- See Also:
- Constant Field Values
-
PLUGIN_NAME_REGEXP
public static final String PLUGIN_NAME_REGEXP
The regexp to determine if a plugin name is correct (add ^ and $ as delimiters if this is your only test)- See Also:
- Constant Field Values
-
FEATURE_ID_SEPARATOR
public static final String FEATURE_ID_SEPARATOR
Separator between pluginName and featureName- See Also:
- Constant Field Values
-
PLUGIN_FILENAME
public static final String PLUGIN_FILENAME
Plugin filename- See Also:
- Constant Field Values
-
INCLUDED_FEATURES_CONTEXT_ATTRIBUTE
public static final String INCLUDED_FEATURES_CONTEXT_ATTRIBUTE
Context attribute containing the features to include.
If presentPluginsManager
will init withIncludePolicyFeatureActivator
and the provided collection of features (as strings).
If not present,PluginsManager
will init withExcludePolicyFeatureActivator
which is the default one.
Use with care.
-
__instance
private static PluginsManager __instance
-
_safeMode
private boolean _safeMode
-
_resourceURIs
private Map<String,String> _resourceURIs
-
_locations
private Map<String,File> _locations
-
_allPlugins
private Map<String,Plugin> _allPlugins
-
_inactiveFeatures
private Map<String,PluginsManager.InactivityCause> _inactiveFeatures
-
_extensionPoints
private Map<String,ExtensionPointDefinition> _extensionPoints
-
_components
private Map<String,ComponentDefinition> _components
-
_extensions
private Map<String,Map<String,ExtensionDefinition>> _extensions
-
_status
private PluginsManager.Status _status
-
_logger
private org.slf4j.Logger _logger
-
_errors
private Collection<PluginIssue> _errors
-
_featureActivator
private FeatureActivator _featureActivator
-
-
Constructor Detail
-
PluginsManager
private PluginsManager()
-
-
Method Detail
-
getInstance
public static PluginsManager getInstance()
Returns the shared instance of thePluginManager
- Returns:
- the shared instance of the PluginManager
-
isSafeMode
public boolean isSafeMode()
Returns true if the safe mode is activated.- Returns:
- true if the safe mode is activated.
-
getErrors
public Collection<PluginIssue> getErrors()
Returns errors gathered during plugins loading.- Returns:
- errors gathered during plugins loading.
-
getPluginNames
public Set<String> getPluginNames()
Returns the names of the plugins- Returns:
- the names of the plugins
-
getBundledPluginsNames
public Set<String> getBundledPluginsNames()
Returns a String array containing the names of the plugins bundled in jars- Returns:
- a String array containing the names of the plugins bundled in jars
-
getPlugins
public Map<String,Plugin> getPlugins()
Returns active plugins declarations.- Returns:
- active plugins declarations.
-
getAllPlugins
public Map<String,Plugin> getAllPlugins()
Returns all existing plugins definitions.- Returns:
- all existing plugins definitions.
-
getFeatures
public Map<String,Feature> getFeatures()
Returns loaded features declarations.
They may be different than active feature in case of safe mode.- Returns:
- loaded features declarations.
-
getInactiveFeatures
public Map<String,PluginsManager.InactivityCause> getInactiveFeatures()
Returns inactive features id and cause of deactivation.- Returns:
- inactive features id and cause of deactivation.
-
getExtensionPoints
public Map<String,Collection<String>> getExtensionPoints()
Returns the extensions points and their extensions- Returns:
- the extensions points and their extensions
-
getComponents
public Collection<String> getComponents()
Returns the components roles.- Returns:
- the components roles.
-
getResourceURI
public String getResourceURI(String pluginName)
Returns the base URI for the given plugin resources, or null if the plugin does not exist or is located in the file system.- Parameters:
pluginName
- the name of the plugin- Returns:
- the base URI for the given plugin resources, or null if the plugin does not exist or is located in the file system.
-
getPluginLocation
public File getPluginLocation(String pluginName)
Returns the plugin filesystem location for the given plugin or null if the plugin is loaded from the classpath.- Parameters:
pluginName
- the plugin name- Returns:
- the plugin location for the given plugin
-
getStatus
public PluginsManager.Status getStatus()
Returns the status after initialization.- Returns:
- the status after initialization.
-
_setActivator
private void _setActivator(Context context)
-
init
public PluginsComponentManager init(ComponentManager parentCM, Context context, String contextPath, boolean forceSafeMode) throws Exception
Initialization of the plugin manager- Parameters:
parentCM
- the parentComponentManager
.context
- the Avalon contextcontextPath
- the Web context path on the server filesystemforceSafeMode
- true to force the application to enter the safe mode- Returns:
- the
PluginsComponentManager
containing loaded components. - Throws:
Exception
- if something wrong occurs during plugins loading
-
_initializeConfigurationComponentManager
private void _initializeConfigurationComponentManager(String contextPath, FeatureActivator.PluginsInformation pluginsInfo, PluginsComponentManager configCM)
-
_parseConfiguration
private void _parseConfiguration(ConfigManager configManager, Map<String,Plugin> plugins, Map<String,Feature> features)
-
_initResourceURIs
private void _initResourceURIs() throws IOException
- Throws:
IOException
-
_parsePlugins
private Map<String,Plugin> _parsePlugins(String contextPath, Collection<String> locations, Map<String,File> externalPlugins, Collection<String> excludedPlugins) throws IOException
- Throws:
IOException
-
_addPlugin
private void _addPlugin(Map<String,Plugin> plugins, String pluginName, File pluginDir, Collection<String> excludedPlugins) throws IOException
- Throws:
IOException
-
_getConfigurationFromStream
private Configuration _getConfigurationFromStream(String pluginName, InputStream is, String path, Collection<String> excludedPlugins)
-
_pluginError
private void _pluginError(String pluginName, String message, PluginIssue.PluginIssueCode code, Collection<String> excludedPlugins, Exception e)
-
_loadExtensionsPoint
private void _loadExtensionsPoint(PluginsComponentManager manager, String point, Map<String,ExtensionPointDefinition> extensionPoints, Map<String,Map<String,ExtensionDefinition>> extensionsDefinitions, String contextPath, Collection<PluginIssue> errors)
-
_loadExtensionsPoints
private void _loadExtensionsPoints(PluginsComponentManager manager, Map<String,ExtensionPointDefinition> extensionPoints, Map<String,Map<String,ExtensionDefinition>> extensionsDefinitions, String contextPath, Collection<PluginIssue> errors)
-
_loadComponents
private void _loadComponents(PluginsComponentManager manager, Map<String,ComponentDefinition> components, String contextPath, Collection<PluginIssue> errors)
-
_getComponentConfiguration
private Configuration _getComponentConfiguration(Configuration initialConfiguration, String contextPath, String pluginName, Collection<PluginIssue> errors)
-
_loadRuntimeInit
private void _loadRuntimeInit(PluginsComponentManager manager, Collection<PluginIssue> errors)
-
_enterSafeMode
private PluginsComponentManager _enterSafeMode(ComponentManager parentCM, Context context, String contextPath) throws Exception
- Throws:
Exception
-
-