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
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.Class<?>[] |
COMMON_CLASSES |
application, applicationContext, classNameToPluginMap, CONFIG_FILE, failedPlugins, initialised, loadCorePlugins, pluginClasses, pluginList, pluginResources, plugins, shutdownBEAN_NAME| Constructor and Description |
|---|
DefaultGrailsPluginManager(java.lang.Class<?>[] plugins,
GrailsApplication application) |
DefaultGrailsPluginManager(org.springframework.core.io.Resource[] pluginFiles,
GrailsApplication application) |
DefaultGrailsPluginManager(java.lang.String[] pluginResources,
GrailsApplication application) |
DefaultGrailsPluginManager(java.lang.String resourcePath,
GrailsApplication application) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
canRegisterPlugin(GrailsPlugin plugin) |
void |
checkForChanges()
Deprecated.
Replaced by agent-based reloading, will be removed in a future version of Grails
|
protected GrailsPlugin |
createGrailsPlugin(java.lang.Class<?> pluginClass) |
protected GrailsPlugin |
createGrailsPlugin(java.lang.Class<?> pluginClass,
org.springframework.core.io.Resource resource) |
void |
doDynamicMethods()
Called on all plugins so that they can add new methods/properties/constructors etc.
|
void |
doWebDescriptor(java.io.File descriptor,
java.io.Writer target) |
void |
doWebDescriptor(org.springframework.core.io.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
|
protected void |
evictPlugin(GrailsPlugin evictor,
java.lang.String evicteeName) |
java.util.Collection<GrailsPlugin> |
getPluginObservers(GrailsPlugin plugin)
Retrieves a collection of plugins that are observing the specified plugin
|
GrailsPlugin[] |
getUserPlugins()
Gets plugin installed by the user and not provided by the framework
|
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) |
protected java.util.Map<GrailsPlugin,java.util.List<GrailsPlugin>> |
resolveLoadDependencies(java.util.List<GrailsPlugin> plugins) |
void |
setApplication(GrailsApplication application)
Sets the GrailsApplication used be this plugin manager
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setParentApplicationContext(org.springframework.context.ApplicationContext parent) |
protected java.util.List<GrailsPlugin> |
sortPlugins(java.util.List<GrailsPlugin> toSort) |
void |
startPluginChangeScanner()
Deprecated.
Will be removed in a future version of Grails
|
void |
stopPluginChangeScanner()
Deprecated.
Will be removed in a future version of Grails
|
checkInitialised, 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, isShutdown, registerProvidedArtefacts, setLoadCorePlugins, shutdown, supportsCurrentBuildScopepublic 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(org.springframework.core.io.Resource[] pluginFiles,
GrailsApplication application)
public GrailsPlugin[] getUserPlugins()
GrailsPluginManager@Deprecated public void startPluginChangeScanner()
@Deprecated public void stopPluginChangeScanner()
public void refreshPlugin(java.lang.String name)
GrailsPluginManagername - The name of the plugin to refreshpublic java.util.Collection<GrailsPlugin> getPluginObservers(GrailsPlugin plugin)
GrailsPluginManagerplugin - The plugin to retrieve observers forpublic void informObservers(java.lang.String pluginName,
java.util.Map event)
GrailsPluginManagerpluginName - The name of the pluginevent - The eventpublic void loadPlugins()
throws org.codehaus.groovy.grails.plugins.exceptions.PluginException
GrailsPluginManagerorg.codehaus.groovy.grails.plugins.exceptions.PluginException - Thrown when an error occurs loading the pluginsprotected java.util.List<GrailsPlugin> sortPlugins(java.util.List<GrailsPlugin> toSort)
protected java.util.Map<GrailsPlugin,java.util.List<GrailsPlugin>> resolveLoadDependencies(java.util.List<GrailsPlugin> plugins)
protected GrailsPlugin createGrailsPlugin(java.lang.Class<?> pluginClass)
protected GrailsPlugin createGrailsPlugin(java.lang.Class<?> pluginClass, org.springframework.core.io.Resource resource)
protected boolean canRegisterPlugin(GrailsPlugin plugin)
protected void evictPlugin(GrailsPlugin evictor, java.lang.String evicteeName)
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwaresetApplicationContext in class AbstractGrailsPluginManagerorg.springframework.beans.BeansExceptionpublic void setParentApplicationContext(org.springframework.context.ApplicationContext parent)
@Deprecated public void checkForChanges()
GrailsPluginManagerpublic void reloadPlugin(GrailsPlugin plugin)
public void doWebDescriptor(org.springframework.core.io.Resource descriptor,
java.io.Writer target)
GrailsPluginManagerdescriptor - The Resource of the descriptortarget - The Writer to write the result topublic void doWebDescriptor(java.io.File descriptor,
java.io.Writer target)
descriptor - The File of the descriptortarget - The target to write the changes toGrailsPluginManager.doWebDescriptor(Resource, Writer)public void setApplication(GrailsApplication application)
GrailsPluginManagersetApplication in interface GrailsPluginManagersetApplication in class AbstractGrailsPluginManagerapplication - The GrailsApplication instancepublic void doDynamicMethods()
GrailsPluginManagerdoDynamicMethods in interface GrailsPluginManagerdoDynamicMethods in class AbstractGrailsPluginManager