Package org.grails.plugins
Class DefaultGrailsPlugin
- java.lang.Object
-
- groovy.lang.GroovyObjectSupport
-
- org.grails.plugins.AbstractGrailsPlugin
-
- org.grails.plugins.DefaultGrailsPlugin
-
- All Implemented Interfaces:
ParentApplicationContextAware,GrailsPlugin,grails.plugins.GrailsPluginInfo,groovy.lang.GroovyObject,java.lang.Comparable,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
BinaryGrailsPlugin
public class DefaultGrailsPlugin extends AbstractGrailsPlugin implements ParentApplicationContextAware
Implementation of the GrailsPlugin interface that wraps a Groovy plugin class and provides the magic to invoke its various methods from Java.- Since:
- 0.4
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.commons.logging.LogLOGprotected org.springframework.beans.BeanWrapperpluginBean-
Fields inherited from class org.grails.plugins.AbstractGrailsPlugin
applicationContext, config, dependencies, dependencyNames, evictionList, grailsApplication, isBase, manager, PLUGIN_GROOVY, PLUGIN_GROOVY_PATH, PLUGIN_YML, PLUGIN_YML_PATH, pluginClass, propertySource, version
-
Fields inherited from interface grails.plugins.GrailsPlugin
ARTEFACTS, DEPENDS_ON, DO_WITH_APPLICATION_CONTEXT, DO_WITH_DYNAMIC_METHODS, DO_WITH_SPRING, DO_WITH_WEB_DESCRIPTOR, ENVIRONMENTS, EVENT_ON_CHANGE, EVENT_ON_CONFIG_CHANGE, EVENT_ON_SHUTDOWN, EVICT, OBSERVE, ON_CHANGE, ON_CONFIG_CHANGE, ON_SHUTDOWN, PLUGIN_EXCLUDES, PLUGIN_LOAD_AFTER_NAMES, PLUGIN_LOAD_BEFORE_NAMES, PLUGINS_PATH, PROFILES, PROVIDED_ARTEFACTS, SCOPES, STATUS, STATUS_DISABLED, STATUS_ENABLED, TYPE_FILTERS, WATCHED_RESOURCES
-
-
Constructor Summary
Constructors Constructor Description DefaultGrailsPlugin(java.lang.Class<?> pluginClass, GrailsApplication application)DefaultGrailsPlugin(java.lang.Class<?> pluginClass, org.springframework.core.io.Resource resource, GrailsApplication application)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddExclude(grails.util.Environment env)Makes the plugin excluded for a particular Environmentgrails.spring.BeanBuilderbeans(groovy.lang.Closure closure)voiddoArtefactConfiguration()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 ctx)This method is called to allow the plugin to addBeanDefinitions to theBeanDefinitionRegistry.voiddoWithDynamicMethods(org.springframework.context.ApplicationContext ctx)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 dependencyorg.grails.io.support.ResourcegetDescriptor()java.lang.StringgetFullName()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.org.apache.commons.logging.LoggetLog()java.lang.StringgetName()java.lang.String[]getObservedPluginNames()Retrieve the plugin names that this plugin is observing for changesorg.springframework.context.ApplicationContextgetParentCtx()GrailsPlugingetPlugin()org.grails.io.support.ResourcegetPluginDir()java.util.List<java.lang.String>getPluginExcludes()A list of resources that the plugin should exclude from the packaged distributionjava.util.MapgetProperties()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-userorg.springframework.core.io.support.PathMatchingResourcePatternResolvergetResolver()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 ApplicationContextjava.util.List<org.grails.plugins.support.WatchPattern>getWatchedResourcePatterns()Resources that this plugin watchesorg.springframework.core.io.Resource[]getWatchedResources()booleanhasInterestInChange(java.lang.String path)Whether the plugin is interested in a particular changebooleanisEnabled()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 necessaryvoidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)voidsetDescriptor(org.springframework.core.io.Resource descriptor)Sets the plugin descriptor for this pluginvoidsetManager(GrailsPluginManager manager)Sets the plugin manager for this pluginvoidsetParentApplicationContext(org.springframework.context.ApplicationContext parent)voidsetWatchedResources(org.springframework.core.io.Resource[] watchedResources)booleansupportsCurrentScopeAndEnvironment()booleansupportsEnvironment(grails.util.Environment environment)Returns whether this plugin supports the given environment namejava.lang.StringtoString()-
Methods inherited from class org.grails.plugins.AbstractGrailsPlugin
checkForChanges, compareTo, equals, getConfigurationResource, getEvictionNames, getFileSystemName, getFileSystemShortName, getManager, getPluginClass, getPluginPath, getPluginPathCamelCase, getPropertySource, getVersion, hashCode, isBasePlugin, readPluginConfiguration, setApplication, setBasePlugin
-
-
-
-
Constructor Detail
-
DefaultGrailsPlugin
public DefaultGrailsPlugin(java.lang.Class<?> pluginClass, org.springframework.core.io.Resource resource, GrailsApplication application)
-
DefaultGrailsPlugin
public DefaultGrailsPlugin(java.lang.Class<?> pluginClass, GrailsApplication application)
-
-
Method Detail
-
isEnabled
public boolean isEnabled(java.lang.String[] activeProfiles)
Description copied from interface:GrailsPluginCheck whether the plugin is enabled for the given profile- Specified by:
isEnabledin interfaceGrailsPlugin- Overrides:
isEnabledin classAbstractGrailsPlugin- Returns:
- True if it is
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Overrides:
setApplicationContextin classAbstractGrailsPlugin- Throws:
org.springframework.beans.BeansException
-
getWatchedResourcePatterns
public java.util.List<org.grails.plugins.support.WatchPattern> getWatchedResourcePatterns()
Description copied from interface:GrailsPluginResources that this plugin watches- Specified by:
getWatchedResourcePatternsin interfaceGrailsPlugin- Overrides:
getWatchedResourcePatternsin classAbstractGrailsPlugin- Returns:
- The watch resource patterns
-
hasInterestInChange
public boolean hasInterestInChange(java.lang.String path)
Description copied from interface:GrailsPluginWhether the plugin is interested in a particular change- Specified by:
hasInterestInChangein interfaceGrailsPlugin- Overrides:
hasInterestInChangein classAbstractGrailsPlugin- Parameters:
path- The path to the resource that changed- Returns:
- true if it is
-
setManager
public void setManager(GrailsPluginManager manager)
Description copied from interface:GrailsPluginSets the plugin manager for this plugin- Specified by:
setManagerin interfaceGrailsPlugin- Overrides:
setManagerin classAbstractGrailsPlugin- Parameters:
manager- A GrailsPluginManager instance
-
getLoadAfterNames
public java.lang.String[] getLoadAfterNames()
Description copied from interface:GrailsPluginRetrieves 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- Specified by:
getLoadAfterNamesin interfaceGrailsPlugin- Overrides:
getLoadAfterNamesin classAbstractGrailsPlugin- Returns:
- The names of the plugins that this plugin should be loaded after
-
getLoadBeforeNames
public java.lang.String[] getLoadBeforeNames()
Description copied from interface:GrailsPluginRetrieves the names of plugins that this plugin should be loaded before. As with getLoadAfterNames() it is not a requirement that the specified plugins exist- Specified by:
getLoadBeforeNamesin interfaceGrailsPlugin- Overrides:
getLoadBeforeNamesin classAbstractGrailsPlugin- Returns:
- The names of the plugins that this plugin should load before
-
getResolver
public org.springframework.core.io.support.PathMatchingResourcePatternResolver getResolver()
- Returns:
- the resolver
-
getParentCtx
public org.springframework.context.ApplicationContext getParentCtx()
-
beans
public grails.spring.BeanBuilder beans(groovy.lang.Closure closure)
-
doWithApplicationContext
public void doWithApplicationContext(org.springframework.context.ApplicationContext ctx)
Description copied from interface:GrailsPluginThis method is called to allow the plugin to add
BeanDefinitions to theBeanDefinitionRegistry.- Specified by:
doWithApplicationContextin interfaceGrailsPlugin- Parameters:
ctx- The Spring ApplicationContext instance
-
doWithRuntimeConfiguration
public void doWithRuntimeConfiguration(org.grails.spring.RuntimeSpringConfiguration springConfig)
Description copied from interface:GrailsPluginExecutes the plugin code that performs runtime configuration as defined in the doWithSpring closure- Specified by:
doWithRuntimeConfigurationin interfaceGrailsPlugin- Parameters:
springConfig- The RuntimeSpringConfiguration instance
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfacegrails.plugins.GrailsPluginInfo- Overrides:
getNamein classAbstractGrailsPlugin
-
addExclude
public void addExclude(grails.util.Environment env)
Description copied from interface:GrailsPluginMakes the plugin excluded for a particular Environment- Specified by:
addExcludein interfaceGrailsPlugin- Parameters:
env- The Environment
-
supportsEnvironment
public boolean supportsEnvironment(grails.util.Environment environment)
Description copied from interface:GrailsPluginReturns whether this plugin supports the given environment name- Specified by:
supportsEnvironmentin interfaceGrailsPlugin- Parameters:
environment- The environment name- Returns:
- true if it does
-
supportsCurrentScopeAndEnvironment
public boolean supportsCurrentScopeAndEnvironment()
- Specified by:
supportsCurrentScopeAndEnvironmentin interfaceGrailsPlugin- Returns:
- true if the current plugin supports the current BuildScope and Environment
-
doc
@Deprecated public void doc(java.lang.String text)
Deprecated.Dynamic document generation no longer supportedDescription copied from interface:GrailsPluginWrite some documentation to the DocumentationContext- Specified by:
docin interfaceGrailsPlugin- Parameters:
text-
-
getDependencyNames
public java.lang.String[] getDependencyNames()
- Specified by:
getDependencyNamesin interfaceGrailsPlugin- Overrides:
getDependencyNamesin classAbstractGrailsPlugin- Returns:
- The names of the plugins this plugin is dependant on
-
getWatchedResources
public org.springframework.core.io.Resource[] getWatchedResources()
- Returns:
- the watchedResources
-
getDependentVersion
public java.lang.String getDependentVersion(java.lang.String name)
Description copied from interface:GrailsPluginThe version of the specified dependency- Specified by:
getDependentVersionin interfaceGrailsPlugin- Overrides:
getDependentVersionin classAbstractGrailsPlugin- Parameters:
name- the name of the dependency- Returns:
- The version
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setWatchedResources
public void setWatchedResources(org.springframework.core.io.Resource[] watchedResources) throws java.io.IOException- Throws:
java.io.IOException
-
getLog
public org.apache.commons.logging.Log getLog()
-
getPlugin
public GrailsPlugin getPlugin()
-
setParentApplicationContext
public void setParentApplicationContext(org.springframework.context.ApplicationContext parent)
- Specified by:
setParentApplicationContextin interfaceParentApplicationContextAware
-
refresh
public void refresh()
Description copied from interface:GrailsPluginRefreshes this Grails plugin reloading any watched resources as necessary- Specified by:
refreshin interfaceGrailsPlugin- Overrides:
refreshin classAbstractGrailsPlugin
-
getInstance
public groovy.lang.GroovyObject getInstance()
Description copied from interface:GrailsPluginRetrieves the wrapped plugin instance for this plugin- Specified by:
getInstancein interfaceGrailsPlugin- Returns:
- The plugin instance
-
doWithDynamicMethods
public void doWithDynamicMethods(org.springframework.context.ApplicationContext ctx)
Description copied from interface:GrailsPluginCalls a "doWithDynamicMethods" closure that allows a plugin to register dynamic methods at runtime- Specified by:
doWithDynamicMethodsin interfaceGrailsPlugin- Parameters:
ctx- The Spring ApplicationContext instance
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabledin interfaceGrailsPlugin- Returns:
- Whether the plugin is enabled or not
-
getObservedPluginNames
public java.lang.String[] getObservedPluginNames()
Description copied from interface:GrailsPluginRetrieve the plugin names that this plugin is observing for changes- Specified by:
getObservedPluginNamesin interfaceGrailsPlugin- Returns:
- The names of the observed plugins
-
notifyOfEvent
public void notifyOfEvent(java.util.Map event)
Description copied from interface:GrailsPluginNotifies this plugin of the specified Event calling the onChange listener- Specified by:
notifyOfEventin interfaceGrailsPlugin- Parameters:
event- The event to listen for
-
notifyOfEvent
public java.util.Map notifyOfEvent(int eventKind, java.lang.Object source)Description copied from interface:GrailsPluginNotifies the plugin of a specific event for the given event id, which is one of ON_CHANGE, ON_CONFIG_CHANGE- Specified by:
notifyOfEventin interfaceGrailsPlugin- Parameters:
eventKind- The event kindsource- The source of the event- Returns:
- a Map that represents the event
-
doArtefactConfiguration
public void doArtefactConfiguration()
Description copied from interface:GrailsPluginCalled prior to the initialisation of the GrailsApplication instance to allow the registration of additonal ArtefactHandlers- Specified by:
doArtefactConfigurationin interfaceGrailsPlugin- See Also:
ArtefactHandler
-
getProvidedArtefacts
public java.lang.Class<?>[] getProvidedArtefacts()
Description copied from interface:GrailsPluginRetrieves an array of provided Artefacts that are pre-compiled additions to the GrailsApplication object but are overridable by the end-user- Specified by:
getProvidedArtefactsin interfaceGrailsPlugin- Returns:
- A list of provided artefacts
-
getPluginExcludes
public java.util.List<java.lang.String> getPluginExcludes()
Description copied from interface:GrailsPluginA list of resources that the plugin should exclude from the packaged distribution- Specified by:
getPluginExcludesin interfaceGrailsPlugin- Returns:
- a List of resources
-
getTypeFilters
public java.util.Collection<? extends org.springframework.core.type.filter.TypeFilter> getTypeFilters()
Description copied from interface:GrailsPluginPlugin can provide a list of Spring TypeFilters so that annotated components can be scanned into the ApplicationContext- Specified by:
getTypeFiltersin interfaceGrailsPlugin- Returns:
- A collection of TypeFilter instance
-
getFullName
public java.lang.String getFullName()
- Specified by:
getFullNamein interfacegrails.plugins.GrailsPluginInfo
-
getDescriptor
public org.grails.io.support.Resource getDescriptor()
- Specified by:
getDescriptorin interfacegrails.plugins.GrailsPluginInfo
-
setDescriptor
public void setDescriptor(org.springframework.core.io.Resource descriptor)
Description copied from interface:GrailsPluginSets the plugin descriptor for this plugin- Specified by:
setDescriptorin interfaceGrailsPlugin- Parameters:
descriptor- The descriptor
-
getPluginDir
public org.grails.io.support.Resource getPluginDir()
- Specified by:
getPluginDirin interfacegrails.plugins.GrailsPluginInfo
-
getProperties
public java.util.Map getProperties()
- Specified by:
getPropertiesin interfacegrails.plugins.GrailsPluginInfo
-
-