Package grails.plugins
Interface GrailsPlugin
-
- All Superinterfaces:
org.springframework.context.ApplicationContextAware,org.springframework.beans.factory.Aware,java.lang.Comparable,grails.plugins.GrailsPluginInfo
- All Known Implementing Classes:
AbstractGrailsPlugin,BinaryGrailsPlugin,DefaultGrailsPlugin
public interface GrailsPlugin extends org.springframework.context.ApplicationContextAware, java.lang.Comparable, grails.plugins.GrailsPluginInfoPlugin interface that adds Spring
BeanDefinitions to a registry based on aGrailsApplicationobject. After allGrailsPluginclasses have been processed theBeanDefinitions in the registry are loaded in a SpringApplicationContextthat's the singular configuration unit of Grails applications.It's up to implementation classes to determine where
GrailsPlugininstances are loaded from.- Since:
- 0.2
- See Also:
BeanDefinitionRegistry
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringARTEFACTSDefine the list of ArtefactHandlers supporting by the pluginstatic java.lang.StringDEPENDS_ONDefines the name of the property that specifies which plugins this plugin depends onstatic java.lang.StringDO_WITH_APPLICATION_CONTEXTDefines the name of the property that defines a closure that will be invoked after intialisation and when the application context has been builtstatic java.lang.StringDO_WITH_DYNAMIC_METHODSstatic java.lang.StringDO_WITH_SPRINGDefines the name of the property that defines the closure that will be invoked during runtime spring configurationstatic java.lang.StringDO_WITH_WEB_DESCRIPTORDefines the name of the property that defines the closure that will be invoked when the web.xml is being generatedstatic java.lang.StringENVIRONMENTSThe environments to which this plugin appliesstatic intEVENT_ON_CHANGEstatic intEVENT_ON_CONFIG_CHANGEstatic intEVENT_ON_SHUTDOWNstatic java.lang.StringEVICTDefines the name of the property that specifies a List or plugins that this plugin evicts Eviction occurs when the PluginManager loadsstatic java.lang.StringOBSERVEThe field that represents the plugin names that this plugin is observing for changes.static java.lang.StringON_CHANGEDefines the name of the property that defines the closure that will be invoked when a watched resource changesstatic java.lang.StringON_CONFIG_CHANGEDefines the name of the property that defines the closure that will be invoked when a the Grails configuration object changesstatic java.lang.StringON_SHUTDOWNDefines the name of the property that holds a closure to be invoked when shutdown is calledstatic java.lang.StringPLUGIN_EXCLUDESThe field that represents the list of resources to exclude from plugin packagingstatic java.lang.StringPLUGIN_LOAD_AFTER_NAMESThe name of the property that provides a list of plugins this plugin should after beforestatic java.lang.StringPLUGIN_LOAD_BEFORE_NAMESThe name of the property that provides a list of plugins this plugin should load beforestatic java.lang.StringPLUGINS_PATHThe prefix used in plug-ins pathsstatic java.lang.StringPROFILESThe profiles for which this plugin is activestatic java.lang.StringPROVIDED_ARTEFACTSThe name of the property that provides a list of shipped, but overridable artefactsstatic java.lang.StringSCOPESThe scopes to which this plugin appliesstatic java.lang.StringSTATUSThe status of the plugin.static java.lang.StringSTATUS_DISABLEDWhen a plugin is "disabled" it will not be loadedstatic java.lang.StringSTATUS_ENABLEDWhen a plugin is "enabled" it will be loaded as usual.static java.lang.StringTYPE_FILTERSThe field that represents the list of type filters a plugin providesstatic java.lang.StringWATCHED_RESOURCESDefines the name of the property that specifies resources which this plugin monitors for changes in the format a Ant-style path
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidaddExclude(grails.util.Environment env)Makes the plugin excluded for a particular EnvironmentvoiddoArtefactConfiguration()Called prior to the initialisation of the GrailsApplication instance to allow the registration of additonal ArtefactHandlersvoiddoc(java.lang.String text)Deprecated.Dynamic document generation no longer supportedvoiddoWithApplicationContext(org.springframework.context.ApplicationContext applicationContext)This method is called to allow the plugin to addBeanDefinitions to theBeanDefinitionRegistry.voiddoWithDynamicMethods(org.springframework.context.ApplicationContext applicationContext)Calls a "doWithDynamicMethods" closure that allows a plugin to register dynamic methods at runtimevoiddoWithRuntimeConfiguration(org.grails.spring.RuntimeSpringConfiguration springConfig)Executes the plugin code that performs runtime configuration as defined in the doWithSpring closurejava.lang.String[]getDependencyNames()java.lang.StringgetDependentVersion(java.lang.String name)The version of the specified dependencyjava.lang.String[]getEvictionNames()java.lang.StringgetFileSystemName()Returns the name of the plugin as represented in the file system including the version.java.lang.StringgetFileSystemShortName()Returns the name of the plugin as represented on the file system without the version.groovy.lang.GroovyObjectgetInstance()Retrieves the wrapped plugin instance for this pluginjava.lang.String[]getLoadAfterNames()Retrieves the names of plugins that this plugin should be loaded after.java.lang.String[]getLoadBeforeNames()Retrieves the names of plugins that this plugin should be loaded before.GrailsPluginManagergetManager()Retrieves the plugin manager if known, otherwise returns nulljava.lang.String[]getObservedPluginNames()Retrieve the plugin names that this plugin is observing for changesjava.lang.Class<?>getPluginClass()Returns the underlying class that represents this pluginjava.util.List<java.lang.String>getPluginExcludes()A list of resources that the plugin should exclude from the packaged distributionjava.lang.StringgetPluginPath()Returns the path of the plug-injava.lang.StringgetPluginPathCamelCase()Returns the path of the plug-in using camel caseorg.springframework.core.env.PropertySource<?>getPropertySource()java.lang.Class<?>[]getProvidedArtefacts()Retrieves an array of provided Artefacts that are pre-compiled additions to the GrailsApplication object but are overridable by the end-userjava.util.Collection<? extends org.springframework.core.type.filter.TypeFilter>getTypeFilters()Plugin can provide a list of Spring TypeFilters so that annotated components can be scanned into the ApplicationContextjava.util.List<org.grails.plugins.support.WatchPattern>getWatchedResourcePatterns()Resources that this plugin watchesbooleanhasInterestInChange(java.lang.String path)Whether the plugin is interested in a particular changebooleanisBasePlugin()Returns whether this plugin is loaded from the current plugin.booleanisEnabled()booleanisEnabled(java.lang.String[] activeProfiles)Check whether the plugin is enabled for the given profilejava.util.MapnotifyOfEvent(int eventKind, java.lang.Object source)Notifies the plugin of a specific event for the given event id, which is one of ON_CHANGE, ON_CONFIG_CHANGEvoidnotifyOfEvent(java.util.Map event)Notifies this plugin of the specified Event calling the onChange listenervoidrefresh()Refreshes this Grails plugin reloading any watched resources as necessaryvoidsetApplication(GrailsApplication application)voidsetBasePlugin(boolean isBase)Sets whether this plugin is the base pluginvoidsetDescriptor(org.springframework.core.io.Resource descriptor)Sets the plugin descriptor for this pluginvoidsetManager(GrailsPluginManager manager)Sets the plugin manager for this pluginbooleansupportsCurrentScopeAndEnvironment()booleansupportsEnvironment(grails.util.Environment environment)Returns whether this plugin supports the given environment name
-
-
-
Field Detail
-
EVENT_ON_CHANGE
static final int EVENT_ON_CHANGE
- See Also:
- Constant Field Values
-
EVENT_ON_CONFIG_CHANGE
static final int EVENT_ON_CONFIG_CHANGE
- See Also:
- Constant Field Values
-
EVENT_ON_SHUTDOWN
static final int EVENT_ON_SHUTDOWN
- See Also:
- Constant Field Values
-
DO_WITH_DYNAMIC_METHODS
static final java.lang.String DO_WITH_DYNAMIC_METHODS
- See Also:
- Constant Field Values
-
SCOPES
static final java.lang.String SCOPES
The scopes to which this plugin applies- See Also:
- Constant Field Values
-
ENVIRONMENTS
static final java.lang.String ENVIRONMENTS
The environments to which this plugin applies- See Also:
- Constant Field Values
-
PLUGINS_PATH
static final java.lang.String PLUGINS_PATH
The prefix used in plug-ins paths- See Also:
- Constant Field Values
-
WATCHED_RESOURCES
static final java.lang.String WATCHED_RESOURCES
Defines the name of the property that specifies resources which this plugin monitors for changes in the format a Ant-style path- See Also:
- Constant Field Values
-
EVICT
static final java.lang.String EVICT
Defines the name of the property that specifies a List or plugins that this plugin evicts Eviction occurs when the PluginManager loads- See Also:
- Constant Field Values
-
STATUS
static final java.lang.String STATUS
The status of the plugin.- See Also:
- Constant Field Values
-
STATUS_ENABLED
static final java.lang.String STATUS_ENABLED
When a plugin is "enabled" it will be loaded as usual.- See Also:
- Constant Field Values
-
STATUS_DISABLED
static final java.lang.String STATUS_DISABLED
When a plugin is "disabled" it will not be loaded- See Also:
- Constant Field Values
-
ON_CHANGE
static final java.lang.String ON_CHANGE
Defines the name of the property that defines the closure that will be invoked when a watched resource changes- See Also:
- Constant Field Values
-
ON_SHUTDOWN
static final java.lang.String ON_SHUTDOWN
Defines the name of the property that holds a closure to be invoked when shutdown is called- See Also:
- Constant Field Values
-
ON_CONFIG_CHANGE
static final java.lang.String ON_CONFIG_CHANGE
Defines the name of the property that defines the closure that will be invoked when a the Grails configuration object changes- See Also:
- Constant Field Values
-
DO_WITH_WEB_DESCRIPTOR
static final java.lang.String DO_WITH_WEB_DESCRIPTOR
Defines the name of the property that defines the closure that will be invoked when the web.xml is being generated- See Also:
- Constant Field Values
-
DO_WITH_SPRING
static final java.lang.String DO_WITH_SPRING
Defines the name of the property that defines the closure that will be invoked during runtime spring configuration- See Also:
- Constant Field Values
-
DO_WITH_APPLICATION_CONTEXT
static final java.lang.String DO_WITH_APPLICATION_CONTEXT
Defines the name of the property that defines a closure that will be invoked after intialisation and when the application context has been built- See Also:
- Constant Field Values
-
DEPENDS_ON
static final java.lang.String DEPENDS_ON
Defines the name of the property that specifies which plugins this plugin depends on- See Also:
- Constant Field Values
-
ARTEFACTS
static final java.lang.String ARTEFACTS
Define the list of ArtefactHandlers supporting by the plugin- See Also:
- Constant Field Values
-
PROVIDED_ARTEFACTS
static final java.lang.String PROVIDED_ARTEFACTS
The name of the property that provides a list of shipped, but overridable artefacts- See Also:
- Constant Field Values
-
PROFILES
static final java.lang.String PROFILES
The profiles for which this plugin is active- See Also:
- Constant Field Values
-
PLUGIN_LOAD_BEFORE_NAMES
static final java.lang.String PLUGIN_LOAD_BEFORE_NAMES
The name of the property that provides a list of plugins this plugin should load before- See Also:
- Constant Field Values
-
PLUGIN_LOAD_AFTER_NAMES
static final java.lang.String PLUGIN_LOAD_AFTER_NAMES
The name of the property that provides a list of plugins this plugin should after before- See Also:
- Constant Field Values
-
PLUGIN_EXCLUDES
static final java.lang.String PLUGIN_EXCLUDES
The field that represents the list of resources to exclude from plugin packaging- See Also:
- Constant Field Values
-
TYPE_FILTERS
static final java.lang.String TYPE_FILTERS
The field that represents the list of type filters a plugin provides- See Also:
- Constant Field Values
-
OBSERVE
static final java.lang.String OBSERVE
The field that represents the plugin names that this plugin is observing for changes.- See Also:
- Constant Field Values
-
-
Method Detail
-
doWithApplicationContext
void doWithApplicationContext(org.springframework.context.ApplicationContext applicationContext)
This method is called to allow the plugin to add
BeanDefinitions to theBeanDefinitionRegistry.- Parameters:
applicationContext- The Spring ApplicationContext instance
-
doWithRuntimeConfiguration
void doWithRuntimeConfiguration(org.grails.spring.RuntimeSpringConfiguration springConfig)
Executes the plugin code that performs runtime configuration as defined in the doWithSpring closure- Parameters:
springConfig- The RuntimeSpringConfiguration instance
-
addExclude
void addExclude(grails.util.Environment env)
Makes the plugin excluded for a particular Environment- Parameters:
env- The Environment
-
supportsEnvironment
boolean supportsEnvironment(grails.util.Environment environment)
Returns whether this plugin supports the given environment name- Parameters:
environment- The environment name- Returns:
- true if it does
-
supportsCurrentScopeAndEnvironment
boolean supportsCurrentScopeAndEnvironment()
- Returns:
- true if the current plugin supports the current BuildScope and Environment
-
doc
@Deprecated void doc(java.lang.String text)
Deprecated.Dynamic document generation no longer supportedWrite some documentation to the DocumentationContext- Parameters:
text-
-
getPluginPath
java.lang.String getPluginPath()
Returns the path of the plug-in- Returns:
- A String that makes up the path to the plug-in in the format /plugins/plugin-name-PLUGIN_VERSION
-
getPluginPathCamelCase
java.lang.String getPluginPathCamelCase()
Returns the path of the plug-in using camel case- Returns:
- A String that makes up the path to the plug-in in the format /plugins/pluginName-PLUGIN_VERSION
-
getDependencyNames
java.lang.String[] getDependencyNames()
- Returns:
- The names of the plugins this plugin is dependant on
-
getEvictionNames
java.lang.String[] getEvictionNames()
- Returns:
- The names of the plugins this plugin should evict onload
-
getLoadAfterNames
java.lang.String[] getLoadAfterNames()
Retrieves the names of plugins that this plugin should be loaded after. This differs from dependencies in that if that plugin doesn't exist this plugin will still be loaded. It is a way of enforcing plugins are loaded before, but not necessarily needed- Returns:
- The names of the plugins that this plugin should be loaded after
-
getLoadBeforeNames
java.lang.String[] getLoadBeforeNames()
Retrieves the names of plugins that this plugin should be loaded before. As with getLoadAfterNames() it is not a requirement that the specified plugins exist- Returns:
- The names of the plugins that this plugin should load before
-
getDependentVersion
java.lang.String getDependentVersion(java.lang.String name)
The version of the specified dependency- Parameters:
name- the name of the dependency- Returns:
- The version
-
getPropertySource
org.springframework.core.env.PropertySource<?> getPropertySource()
-
refresh
void refresh()
Refreshes this Grails plugin reloading any watched resources as necessary
-
getManager
GrailsPluginManager getManager()
Retrieves the plugin manager if known, otherwise returns null- Returns:
- The PluginManager or null
-
getInstance
groovy.lang.GroovyObject getInstance()
Retrieves the wrapped plugin instance for this plugin- Returns:
- The plugin instance
-
setManager
void setManager(GrailsPluginManager manager)
Sets the plugin manager for this plugin- Parameters:
manager- A GrailsPluginManager instance
-
setApplication
void setApplication(GrailsApplication application)
-
doWithDynamicMethods
void doWithDynamicMethods(org.springframework.context.ApplicationContext applicationContext)
Calls a "doWithDynamicMethods" closure that allows a plugin to register dynamic methods at runtime- Parameters:
applicationContext- The Spring ApplicationContext instance
-
isEnabled
boolean isEnabled()
- Returns:
- Whether the plugin is enabled or not
-
isEnabled
boolean isEnabled(java.lang.String[] activeProfiles)
Check whether the plugin is enabled for the given profile- Parameters:
activeProfiles-- Returns:
- True if it is
-
getObservedPluginNames
java.lang.String[] getObservedPluginNames()
Retrieve the plugin names that this plugin is observing for changes- Returns:
- The names of the observed plugins
-
notifyOfEvent
void notifyOfEvent(java.util.Map event)
Notifies this plugin of the specified Event calling the onChange listener- Parameters:
event- The event to listen for
-
notifyOfEvent
java.util.Map notifyOfEvent(int eventKind, java.lang.Object source)Notifies the plugin of a specific event for the given event id, which is one of ON_CHANGE, ON_CONFIG_CHANGE- Parameters:
eventKind- The event kindsource- The source of the event- Returns:
- a Map that represents the event
-
doArtefactConfiguration
void doArtefactConfiguration()
Called prior to the initialisation of the GrailsApplication instance to allow the registration of additonal ArtefactHandlers- See Also:
ArtefactHandler
-
getProvidedArtefacts
java.lang.Class<?>[] getProvidedArtefacts()
Retrieves an array of provided Artefacts that are pre-compiled additions to the GrailsApplication object but are overridable by the end-user- Returns:
- A list of provided artefacts
-
getFileSystemName
java.lang.String getFileSystemName()
Returns the name of the plugin as represented in the file system including the version. For example TagLibGrailsPlugin would result in "tag-lib-0.1"- Returns:
- The file system representation of the plugin name
-
getFileSystemShortName
java.lang.String getFileSystemShortName()
Returns the name of the plugin as represented on the file system without the version. For example TagLibGrailsPlugin would result in "tag-lib"- Returns:
- The file system name
-
getPluginClass
java.lang.Class<?> getPluginClass()
Returns the underlying class that represents this plugin- Returns:
- The plugin class
-
getPluginExcludes
java.util.List<java.lang.String> getPluginExcludes()
A list of resources that the plugin should exclude from the packaged distribution- Returns:
- a List of resources
-
isBasePlugin
boolean isBasePlugin()
Returns whether this plugin is loaded from the current plugin. In other words when you execute grails run-app from a plugin project the plugin project's *GrailsPlugin.groovy file represents the base plugin and this method will return true for this plugin- Returns:
- true if it is the base plugin
-
setBasePlugin
void setBasePlugin(boolean isBase)
Sets whether this plugin is the base plugin- Parameters:
isBase- True if is- See Also:
isBasePlugin()
-
getTypeFilters
java.util.Collection<? extends org.springframework.core.type.filter.TypeFilter> getTypeFilters()
Plugin can provide a list of Spring TypeFilters so that annotated components can be scanned into the ApplicationContext- Returns:
- A collection of TypeFilter instance
-
getWatchedResourcePatterns
java.util.List<org.grails.plugins.support.WatchPattern> getWatchedResourcePatterns()
Resources that this plugin watches- Returns:
- The watch resource patterns
-
hasInterestInChange
boolean hasInterestInChange(java.lang.String path)
Whether the plugin is interested in a particular change- Parameters:
path- The path to the resource that changed- Returns:
- true if it is
-
setDescriptor
void setDescriptor(org.springframework.core.io.Resource descriptor)
Sets the plugin descriptor for this plugin- Parameters:
descriptor- The descriptor
-
-