public interface GrailsPluginManager extends ApplicationContextAware
Handles the loading and management of plugins in the Grails framework.
A plugin is just like a normal Grails application, except it contains
a Groovy "plugin descriptor class" which extends Plugin and has a name
ending with GrailsPlugin.
This plugin descriptor class has a version property and optionally Closure properties that are event handlers used to react to Grails lifecycle events, like doWithSpring and doWithApplicationContext.
The doWithSpring Closure uses the BeanBuilder DSL to provide runtime configuration of Grails via Spring.
The doWithApplicationContext Closure is called after the Spring ApplicationContext is built and accepts a single argument - the application context.
Example:
class ClassEditorGrailsPlugin {
def version = '1.1'
def doWithSpring = { application ->
classEditor(org.springframework.beans.propertyeditors.ClassEditor, application.classLoader)
}
}
The plugin descriptor class can also optionally define dependsOn and evict properties that
specify any other plugins that the plugin depends on and any plugins it is incompatible with and should evict.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
doArtefactConfiguration()Called prior to the initialisation of the GrailsApplication object to allow registration of additional ArtefactHandler objects. |
|
public void |
doDynamicMethods()Called on all plugins so that they can add new methods/properties/constructors etc. |
|
public void |
doPostProcessing(ApplicationContext applicationContext)Performs post-initialization configuration for each plugin, passing the built application context (e.g., doWithApplicationContext). |
|
public void |
doRuntimeConfiguration(RuntimeSpringConfiguration springConfig)Executes the runtime configuration phase of the loaded plugins (e.g., doWithSpring). |
|
public void |
doRuntimeConfiguration(java.lang.String pluginName, RuntimeSpringConfiguration springConfig)Executes the runtime configuration for a specific plugin AND all its dependencies. |
|
public GrailsPlugin[] |
getAllPlugins()Returns all loaded plugins. |
|
public GrailsPlugin[] |
getFailedLoadPlugins()Returns any plugins that failed to load due to dependency resolution errors. |
|
public GrailsPlugin |
getFailedPlugin(java.lang.String name)Retrieves a plugin that failed to load, or null if it doesn't exist. |
|
public GrailsPlugin |
getGrailsPlugin(java.lang.String name)Retrieves the Grails plugin instance with the given name. |
|
public GrailsPlugin |
getGrailsPlugin(java.lang.String name, java.lang.Object version)Retrieves a plugin with the given name and version. |
|
public GrailsPlugin |
getGrailsPluginForClassName(java.lang.String name)Retrieves the Grails plugin for the given class name. |
|
public GrailsPlugin |
getPluginForClass(java.lang.Class<?> theClass)Returns the plugin for the given class. |
|
public GrailsPlugin |
getPluginForInstance(java.lang.Object instance)Looks up the plugin that defined the given instance. |
|
public java.util.Collection |
getPluginObservers(GrailsPlugin plugin)Retrieves a collection of plugins that are observing the specified plugin. |
|
public java.lang.String |
getPluginPath(java.lang.String name)Returns the plugin path for the plugin with the given name. |
|
public java.lang.String |
getPluginPath(java.lang.String name, boolean forceCamelCase)Returns the plugin path for the plugin with the given name. |
|
public java.lang.String |
getPluginPathForClass(java.lang.Class<?> theClass)Returns the plugin path for the given plugin class. |
|
public java.lang.String |
getPluginPathForInstance(java.lang.Object instance)Returns the plugin path for the given plugin instance. |
|
public java.lang.String |
getPluginViewsPathForClass(java.lang.Class<? extends java.lang.Object> theClass)Returns the views directory path for the given plugin class. |
|
public java.lang.String |
getPluginViewsPathForInstance(java.lang.Object instance)Returns the views directory path for the given plugin instance. |
|
public java.util.List<TypeFilter> |
getTypeFilters()Get all the TypeFilter definitions defined by the plugins. |
|
public GrailsPlugin[] |
getUserPlugins()Returns plugins installed by the user (e.g., not provided by the core framework). |
|
public boolean |
hasGrailsPlugin(java.lang.String name)Checks whether the manager has a loaded plugin with the given name |
|
public void |
informObservers(java.lang.String pluginName, java.util.Map event)Notify observers of the plugin with the given name of the event described by the given java.util.Map. |
|
public void |
informOfClassChange(java.lang.Class<?> aClass)Method for handling changes to a class and triggering onChange events etc. |
|
public void |
informOfClassChange(java.io.File file, java.lang.Class cls)Inform the plugins that a particular java.io.File and it's resulting compiled class has changed. |
|
public void |
informOfFileChange(java.io.File file)Inform the plugins that a particular java.io.File has changed. |
|
public void |
informPluginsOfConfigChange()Informs the plugins of a configuration change event. |
|
public boolean |
isInitialised()Returns whether the manager has been initialised or not. |
|
public boolean |
isShutdown()Indicates whether this plugin manager has been shutdown or not. |
|
public void |
loadPlugins()Performs the initial load of plugins. |
|
public void |
onStartup(java.util.Map<java.lang.String, java.lang.Object> event)Executes the Plugin.onStartup hook for all plugins. |
|
public void |
refreshPlugin(java.lang.String name)Refreshes the plugin with the given name. |
|
public void |
registerProvidedArtefacts(GrailsApplication application)Registers pre-compiled artefacts with the GrailsApplication instance, only overriding if the application doesn't already provide an artefact of the same name. |
|
public void |
setApplication(GrailsApplication application)Assigns the GrailsApplication instance to be used by this plugin manager. |
|
public void |
shutdown()Shuts down this plugin manager. |
Called prior to the initialisation of the GrailsApplication object to allow registration of additional ArtefactHandler objects.
Called on all plugins so that they can add new methods/properties/constructors etc.
Performs post-initialization configuration for each plugin,
passing the built application context (e.g., doWithApplicationContext).
applicationContext - The ApplicationContext Executes the runtime configuration phase of the loaded plugins (e.g., doWithSpring).
springConfig - The RuntimeSpringConfiguration instanceExecutes the runtime configuration for a specific plugin AND all its dependencies.
pluginName - The name of the pluginspringConfig - The runtime spring config instanceReturns all loaded plugins.
Returns any plugins that failed to load due to dependency resolution errors.
Retrieves a plugin that failed to load, or null if it doesn't exist.
name - The name of the pluginRetrieves the Grails plugin instance with the given name.
name - The name of the pluginRetrieves a plugin with the given name and version.
name - The name of the pluginversion - The version of the pluginRetrieves the Grails plugin for the given class name.
name - The class name of the pluginReturns the plugin for the given class.
theClass - The class to find the plugin forLooks up the plugin that defined the given instance. If the passed in instance is not an instance of a class annotated with GrailsPlugin, null is returned.
instance - The instanceRetrieves a collection of plugins that are observing the specified plugin.
plugin - The plugin to retrieve observers forReturns the plugin path for the plugin with the given name.
name - The plugin nameReturns the plugin path for the plugin with the given name.
Will optionally convert the plugin name in the returned path to camelCase instead
of kebab-case. For example, my-plug-web would resolve to myPlugWeb
if forceCamelCase is true.
name - The plugin nameforceCamelCase - Convert the name in the retured path to camelCaseReturns the plugin path for the given plugin class.
theClass - The plugin classnull if the class is not annotated with
GrailsPluginReturns the plugin path for the given plugin instance.
instance - The plugin instancenull if the instance is not an instance of a class
annotated with GrailsPluginReturns the views directory path for the given plugin class.
theClass - The plugin classnull if the class is not annotated with
GrailsPluginReturns the views directory path for the given plugin instance.
instance - The plugin instancenull if the instance is not
an instance of a class annotated with GrailsPluginGet all the TypeFilter definitions defined by the plugins.
Returns plugins installed by the user (e.g., not provided by the core framework).
Checks whether the manager has a loaded plugin with the given name
name - The name of the pluginNotify observers of the plugin with the given name of the event described by the given java.util.Map.
pluginName - The name of the pluginevent - The eventMethod for handling changes to a class and triggering onChange events etc.
aClass - The class that has changedInform the plugins that a particular java.io.File and it's resulting compiled class has changed.
file - The java.io.File that changedcls - The class that changedInform the plugins that a particular java.io.File has changed.
file - The java.io.File that changedInforms the plugins of a configuration change event.
Returns whether the manager has been initialised or not.
Indicates whether this plugin manager has been shutdown or not.
Performs the initial load of plugins.
Executes the Plugin.onStartup hook for all plugins.
event - the EventRefreshes the plugin with the given name.
A refresh will force the plugin to "touch" each of its watched resources and fire modified events for each of them.
name - The name of the plugin to refreshRegisters pre-compiled artefacts with the GrailsApplication instance, only overriding if the application doesn't already provide an artefact of the same name.
application - The GrailsApplication instanceAssigns the GrailsApplication instance to be used by this plugin manager.
application - The GrailsApplication instance to useShuts down this plugin manager.