public class DefaultGrailsPluginManager extends AbstractGrailsPluginManager
Handles the loading and management of plug-ins in the Grails system. A plugin is just like a normal Grails application except that it contains a file ending in *Plugin.groovy in the root of the directory.
A Plugin class is a Groovy class that has a version and optionally closures called doWithSpring, doWithContext and doWithWebDescriptor
The doWithSpring closure uses the BeanBuilder syntax (@see grails.spring.BeanBuilder) to provide runtime configuration of Grails via Spring
The doWithContext closure is called after the Spring ApplicationContext is built and accepts a single argument (the ApplicationContext)
The doWithWebDescriptor uses mark-up building to provide additional functionality to the web.xml file
Example:
class ClassEditorGrailsPlugin { def version = '1.1' def doWithSpring = { application -> classEditor(org.springframework.beans.propertyeditors.ClassEditor, application.classLoader) } }
A plugin can also define "dependsOn" and "evict" properties that specify what plugins the plugin depends on and which ones it is incompatible with and should evict
CONFIG_FILE
BEAN_NAME
Constructor and Description |
---|
DefaultGrailsPluginManager(java.lang.Class<?>[] plugins,
GrailsApplication application) |
DefaultGrailsPluginManager(Resource[] pluginFiles,
GrailsApplication application) |
DefaultGrailsPluginManager(java.lang.String[] pluginResources,
GrailsApplication application) |
DefaultGrailsPluginManager(java.lang.String resourcePath,
GrailsApplication application) |
Modifier and Type | Method and Description |
---|---|
void |
checkForChanges()
Deprecated.
Replaced by agent-based reloading, will be removed in a future version of Grails
|
void |
doDynamicMethods()
Called on all plugins so that they can add new methods/properties/constructors etc.
|
void |
doWebDescriptor(Resource descriptor,
java.io.Writer target)
Takes the specified web descriptor reference and configures it with all the plugins outputting
the result to the target Writer instance
|
java.util.Collection<GrailsPlugin> |
getPluginObservers(GrailsPlugin plugin)
Retrieves a collection of plugins that are observing the specified plugin
|
ServletContext |
getServletContext() |
GrailsPlugin[] |
getUserPlugins()
Gets plugin installed by the user and not provided by the framework
|
static java.lang.String |
getWeb23DTD() |
void |
informObservers(java.lang.String pluginName,
java.util.Map event)
inform the specified plugins observers of the event specified by the passed Map instance
|
void |
loadPlugins()
Performs the initial load of plug-ins throwing an exception if any dependencies
don't resolve
|
void |
refreshPlugin(java.lang.String name)
Refreshes the specified plugin.
|
void |
reloadPlugin(GrailsPlugin plugin) |
void |
setApplication(GrailsApplication application)
Sets the GrailsApplication used be this plugin manager
|
void |
setApplicationContext(ApplicationContext applicationContext) |
void |
setParentApplicationContext(ApplicationContext parent) |
void |
setServletContext(ServletContext servletContext) |
void |
startPluginChangeScanner()
Deprecated.
Will be removed in a future version of Grails
|
void |
stopPluginChangeScanner()
Deprecated.
Will be removed in a future version of Grails
|
doArtefactConfiguration, doPostProcessing, doRuntimeConfiguration, doRuntimeConfiguration, getAllPlugins, getFailedLoadPlugins, getFailedPlugin, getGrailsPlugin, getGrailsPlugin, getGrailsPluginForClassName, getPluginForClass, getPluginForInstance, getPluginPath, getPluginPathForClass, getPluginPathForInstance, getPluginResources, getPluginViewsPathForClass, getPluginViewsPathForInstance, getTypeFilters, hasGrailsPlugin, informOfClassChange, informOfClassChange, informOfFileChange, informPluginsOfConfigChange, isInitialised, registerProvidedArtefacts, setLoadCorePlugins, shutdown, supportsCurrentBuildScope
public DefaultGrailsPluginManager(java.lang.String resourcePath, GrailsApplication application)
public DefaultGrailsPluginManager(java.lang.String[] pluginResources, GrailsApplication application)
public DefaultGrailsPluginManager(java.lang.Class<?>[] plugins, GrailsApplication application)
public DefaultGrailsPluginManager(Resource[] pluginFiles, GrailsApplication application)
public GrailsPlugin[] getUserPlugins()
GrailsPluginManager
@Deprecated public void startPluginChangeScanner()
@Deprecated public void stopPluginChangeScanner()
public void refreshPlugin(java.lang.String name)
GrailsPluginManager
name
- The name of the plugin to refreshpublic java.util.Collection<GrailsPlugin> getPluginObservers(GrailsPlugin plugin)
GrailsPluginManager
plugin
- The plugin to retrieve observers forpublic void informObservers(java.lang.String pluginName, java.util.Map event)
GrailsPluginManager
pluginName
- The name of the pluginevent
- The eventpublic void loadPlugins() throws PluginException
GrailsPluginManager
PluginException
- Thrown when an error occurs loading the pluginspublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException
setApplicationContext
in class AbstractGrailsPluginManager
BeansException
public void setParentApplicationContext(ApplicationContext parent)
@Deprecated public void checkForChanges()
GrailsPluginManager
public void reloadPlugin(GrailsPlugin plugin)
public void doWebDescriptor(Resource descriptor, java.io.Writer target)
GrailsPluginManager
descriptor
- The Resource of the descriptortarget
- The Writer to write the result topublic void setApplication(GrailsApplication application)
GrailsPluginManager
setApplication
in interface GrailsPluginManager
setApplication
in class AbstractGrailsPluginManager
application
- The GrailsApplication instancepublic void doDynamicMethods()
GrailsPluginManager
doDynamicMethods
in interface GrailsPluginManager
doDynamicMethods
in class AbstractGrailsPluginManager
public void setServletContext(ServletContext servletContext)
public ServletContext getServletContext()
public static java.lang.String getWeb23DTD()