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 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)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.
-
-
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.
-
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
-
-