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 classPluginsManager.InactivityCauseCause of the deactivation of a featurestatic classPluginsManager.StatusPluginsManager status after initialization.
-
Field Summary
Fields Modifier and Type Field Description private static PluginsManager__instanceprivate Map<String,Plugin>_allPluginsprivate Map<String,ComponentDefinition>_componentsprivate Collection<PluginIssue>_errorsprivate Map<String,ExtensionPointDefinition>_extensionPointsprivate Map<String,Map<String,ExtensionDefinition>>_extensionsprivate FeatureActivator_featureActivatorprivate Map<String,Feature>_featuresprivate Map<String,PluginsManager.InactivityCause>_inactiveFeaturesprivate Map<String,File>_locationsprivate org.slf4j.Logger_loggerprivate Map<String,Plugin>_pluginsprivate Map<String,String>_resourceURIsprivate boolean_safeModeprivate PluginsManager.Status_statusstatic StringFEATURE_ID_SEPARATORSeparator between pluginName and featureNamestatic StringINCLUDED_FEATURES_CONTEXT_ATTRIBUTEContext attribute containing the features to include.static StringPLUGIN_FILENAMEPlugin filenamestatic StringPLUGIN_NAME_REGEXPThe regexp to determine if a plugin name is correct (add ^ and $ as delimiters if this is your only test)static StringPLUGIN_NAMES_IGNOREDThe regexp to determine if a plugin name is ignored (CVS or .* or *.bak or *.old)
-
Constructor Summary
Constructors Modifier Constructor Description privatePluginsManager()
-
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 PluginsManagergetInstance()Returns the shared instance of thePluginManagerFilegetPluginLocation(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.StringgetResourceURI(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.StatusgetStatus()Returns the status after initialization.PluginsComponentManagerinit(ComponentManager parentCM, Context context, String contextPath, boolean forceSafeMode)Initialization of the plugin managerbooleanisSafeMode()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 presentPluginsManagerwill init withIncludePolicyFeatureActivatorand the provided collection of features (as strings).
If not present,PluginsManagerwill init withExcludePolicyFeatureActivatorwhich 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
PluginsComponentManagercontaining 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
-
-