Class DefaultGrailsPluginManager
- java.lang.Object
-
- org.grails.plugins.AbstractGrailsPluginManager
-
- grails.plugins.DefaultGrailsPluginManager
-
- All Implemented Interfaces:
GrailsPluginManager,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
ProfilingGrailsPluginManager
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
- Since:
- 0.4
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.Class<?>[]COMMON_CLASSES-
Fields inherited from class org.grails.plugins.AbstractGrailsPluginManager
application, applicationContext, classNameToPluginMap, CONFIG_FILE, failedPlugins, initialised, loadCorePlugins, pluginClasses, pluginList, pluginResources, plugins, shutdown
-
Fields inherited from interface grails.plugins.GrailsPluginManager
BEAN_NAME
-
-
Constructor Summary
Constructors Constructor Description DefaultGrailsPluginManager(GrailsApplication application)DefaultGrailsPluginManager(java.lang.Class<?>[] plugins, GrailsApplication application)DefaultGrailsPluginManager(java.lang.String[] pluginResources, GrailsApplication application)DefaultGrailsPluginManager(java.lang.String resourcePath, GrailsApplication application)DefaultGrailsPluginManager(org.springframework.core.io.Resource[] pluginFiles, GrailsApplication application)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected booleancanRegisterPlugin(GrailsPlugin plugin)voidcheckForChanges()Deprecated.Replaced by agent-based reloading, will be removed in a future version of Grailsprotected GrailsPlugincreateGrailsPlugin(java.lang.Class<?> pluginClass)protected GrailsPlugincreateGrailsPlugin(java.lang.Class<?> pluginClass, org.springframework.core.io.Resource resource)voiddoDynamicMethods()Called on all plugins so that they can add new methods/properties/constructors etc.protected voidevictPlugin(GrailsPlugin evictor, java.lang.String evicteeName)java.util.Collection<GrailsPlugin>getPluginObservers(GrailsPlugin plugin)Retrieves a collection of plugins that are observing the specified pluginGrailsPlugin[]getUserPlugins()Gets plugin installed by the user and not provided by the frameworkvoidinformObservers(java.lang.String pluginName, java.util.Map event)inform the specified plugins observers of the event specified by the passed Map instancevoidloadPlugins()Performs the initial load of plug-ins throwing an exception if any dependencies don't resolvevoidrefreshPlugin(java.lang.String name)Refreshes the specified plugin.voidreloadPlugin(GrailsPlugin plugin)protected java.util.Map<GrailsPlugin,java.util.List<GrailsPlugin>>resolveLoadDependencies(java.util.List<GrailsPlugin> plugins)voidsetApplication(GrailsApplication application)Sets the GrailsApplication used be this plugin managervoidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)voidsetParentApplicationContext(org.springframework.context.ApplicationContext parent)voidsetPluginFilter(PluginFilter pluginFilter)Sets the filter to use to filter for pluginsprotected java.util.List<GrailsPlugin>sortPlugins(java.util.List<GrailsPlugin> toSort)-
Methods inherited from class org.grails.plugins.AbstractGrailsPluginManager
checkInitialised, doArtefactConfiguration, doPostProcessing, doRuntimeConfiguration, doRuntimeConfiguration, getAllPlugins, getFailedLoadPlugins, getFailedPlugin, getGrailsPlugin, getGrailsPlugin, getGrailsPluginForClassName, getPluginForClass, getPluginForInstance, getPluginPath, getPluginPath, getPluginPathForClass, getPluginPathForInstance, getPluginResources, getPluginViewsPathForClass, getPluginViewsPathForInstance, getTypeFilters, hasGrailsPlugin, informOfClassChange, informOfClassChange, informOfFileChange, informPluginsOfConfigChange, isInitialised, isPluginDisabledForProfile, isShutdown, onStartup, registerProvidedArtefacts, setLoadCorePlugins, shutdown
-
-
-
-
Constructor Detail
-
DefaultGrailsPluginManager
public DefaultGrailsPluginManager(java.lang.String resourcePath, GrailsApplication application)
-
DefaultGrailsPluginManager
public DefaultGrailsPluginManager(java.lang.String[] pluginResources, GrailsApplication application)
-
DefaultGrailsPluginManager
public DefaultGrailsPluginManager(java.lang.Class<?>[] plugins, GrailsApplication application)
-
DefaultGrailsPluginManager
public DefaultGrailsPluginManager(org.springframework.core.io.Resource[] pluginFiles, GrailsApplication application)
-
DefaultGrailsPluginManager
public DefaultGrailsPluginManager(GrailsApplication application)
-
-
Method Detail
-
getUserPlugins
public GrailsPlugin[] getUserPlugins()
Description copied from interface:GrailsPluginManagerGets plugin installed by the user and not provided by the framework- Returns:
- A list of user plugins
-
refreshPlugin
public void refreshPlugin(java.lang.String name)
Description copied from interface:GrailsPluginManagerRefreshes the specified plugin. A refresh will force to plugin to "touch" each of its watched resources and fire modified events for each- Parameters:
name- The name of the plugin to refresh
-
getPluginObservers
public java.util.Collection<GrailsPlugin> getPluginObservers(GrailsPlugin plugin)
Description copied from interface:GrailsPluginManagerRetrieves a collection of plugins that are observing the specified plugin- Parameters:
plugin- The plugin to retrieve observers for- Returns:
- A collection of observers
-
informObservers
public void informObservers(java.lang.String pluginName, java.util.Map event)Description copied from interface:GrailsPluginManagerinform the specified plugins observers of the event specified by the passed Map instance- Parameters:
pluginName- The name of the pluginevent- The event
-
loadPlugins
public void loadPlugins() throws grails.plugins.exceptions.PluginExceptionDescription copied from interface:GrailsPluginManagerPerforms the initial load of plug-ins throwing an exception if any dependencies don't resolve- Throws:
grails.plugins.exceptions.PluginException- Thrown when an error occurs loading the plugins
-
sortPlugins
protected java.util.List<GrailsPlugin> sortPlugins(java.util.List<GrailsPlugin> toSort)
-
resolveLoadDependencies
protected java.util.Map<GrailsPlugin,java.util.List<GrailsPlugin>> resolveLoadDependencies(java.util.List<GrailsPlugin> plugins)
-
createGrailsPlugin
protected GrailsPlugin createGrailsPlugin(java.lang.Class<?> pluginClass)
-
createGrailsPlugin
protected GrailsPlugin createGrailsPlugin(java.lang.Class<?> pluginClass, org.springframework.core.io.Resource resource)
-
canRegisterPlugin
protected boolean canRegisterPlugin(GrailsPlugin plugin)
-
evictPlugin
protected void evictPlugin(GrailsPlugin evictor, java.lang.String evicteeName)
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Overrides:
setApplicationContextin classAbstractGrailsPluginManager- Throws:
org.springframework.beans.BeansException
-
setParentApplicationContext
public void setParentApplicationContext(org.springframework.context.ApplicationContext parent)
-
checkForChanges
@Deprecated public void checkForChanges()
Deprecated.Replaced by agent-based reloading, will be removed in a future version of GrailsDescription copied from interface:GrailsPluginManagerChecks all the plugins to see whether they have any changes
-
reloadPlugin
public void reloadPlugin(GrailsPlugin plugin)
-
setApplication
public void setApplication(GrailsApplication application)
Description copied from interface:GrailsPluginManagerSets the GrailsApplication used be this plugin manager- Specified by:
setApplicationin interfaceGrailsPluginManager- Overrides:
setApplicationin classAbstractGrailsPluginManager- Parameters:
application- The GrailsApplication instance
-
doDynamicMethods
public void doDynamicMethods()
Description copied from interface:GrailsPluginManagerCalled on all plugins so that they can add new methods/properties/constructors etc.- Specified by:
doDynamicMethodsin interfaceGrailsPluginManager- Overrides:
doDynamicMethodsin classAbstractGrailsPluginManager
-
setPluginFilter
public void setPluginFilter(PluginFilter pluginFilter)
Description copied from interface:GrailsPluginManagerSets the filter to use to filter for plugins- Specified by:
setPluginFilterin interfaceGrailsPluginManager- Overrides:
setPluginFilterin classAbstractGrailsPluginManager- Parameters:
pluginFilter- The plugin filter
-
-