Package org.grails.plugins
Class AbstractGrailsPlugin
- java.lang.Object
-
- groovy.lang.GroovyObjectSupport
-
- org.grails.plugins.AbstractGrailsPlugin
-
- All Implemented Interfaces:
GrailsPlugin,grails.plugins.GrailsPluginInfo,groovy.lang.GroovyObject,java.lang.Comparable,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
DefaultGrailsPlugin
public abstract class AbstractGrailsPlugin extends groovy.lang.GroovyObjectSupport implements GrailsPlugin
Abstract implementation that provides some default behaviours
-
-
Field Summary
Fields Modifier and Type Field Description protected org.springframework.context.ApplicationContextapplicationContextprotected grails.config.Configconfigprotected java.util.Map<java.lang.String,java.lang.Object>dependenciesprotected java.lang.String[]dependencyNamesprotected java.lang.String[]evictionListprotected GrailsApplicationgrailsApplicationprotected booleanisBaseprotected GrailsPluginManagermanagerstatic java.lang.StringPLUGIN_GROOVYstatic java.lang.StringPLUGIN_GROOVY_PATHstatic java.lang.StringPLUGIN_YMLstatic java.lang.StringPLUGIN_YML_PATHprotected java.lang.Class<?>pluginClassprotected org.springframework.core.env.PropertySource<?>propertySourceprotected java.lang.Stringversion-
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 AbstractGrailsPlugin(java.lang.Class<?> pluginClass, GrailsApplication application)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckForChanges()intcompareTo(java.lang.Object o)booleanequals(java.lang.Object o)protected org.springframework.core.io.ResourcegetConfigurationResource(java.lang.Class<?> pluginClass, java.lang.String path)java.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.java.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.StringgetName()java.lang.Class<?>getPluginClass()Returns the underlying class that represents this pluginjava.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.StringgetVersion()java.util.List<org.grails.plugins.support.WatchPattern>getWatchedResourcePatterns()Resources that this plugin watchesinthashCode()booleanhasInterestInChange(java.lang.String path)Whether the plugin is interested in a particular changebooleanisBasePlugin()Returns whether this plugin is loaded from the current plugin.booleanisEnabled(java.lang.String[] profiles)Check whether the plugin is enabled for the given profileprotected org.springframework.core.io.ResourcereadPluginConfiguration(java.lang.Class<?> pluginClass)voidrefresh()Refreshes this Grails plugin reloading any watched resources as necessaryvoidsetApplication(GrailsApplication application)voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)voidsetBasePlugin(boolean isBase)Sets whether this plugin is the base pluginvoidsetManager(GrailsPluginManager manager)Sets the plugin manager for this plugin-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface grails.plugins.GrailsPlugin
addExclude, doArtefactConfiguration, doc, doWithApplicationContext, doWithDynamicMethods, doWithRuntimeConfiguration, getInstance, getObservedPluginNames, getPluginExcludes, getProvidedArtefacts, getTypeFilters, isEnabled, notifyOfEvent, notifyOfEvent, setDescriptor, supportsCurrentScopeAndEnvironment, supportsEnvironment
-
-
-
-
Field Detail
-
PLUGIN_YML
public static final java.lang.String PLUGIN_YML
- See Also:
- Constant Field Values
-
PLUGIN_YML_PATH
public static final java.lang.String PLUGIN_YML_PATH
- See Also:
- Constant Field Values
-
PLUGIN_GROOVY
public static final java.lang.String PLUGIN_GROOVY
- See Also:
- Constant Field Values
-
PLUGIN_GROOVY_PATH
public static final java.lang.String PLUGIN_GROOVY_PATH
- See Also:
- Constant Field Values
-
propertySource
protected org.springframework.core.env.PropertySource<?> propertySource
-
grailsApplication
protected GrailsApplication grailsApplication
-
isBase
protected boolean isBase
-
version
protected java.lang.String version
-
dependencies
protected java.util.Map<java.lang.String,java.lang.Object> dependencies
-
dependencyNames
protected java.lang.String[] dependencyNames
-
pluginClass
protected java.lang.Class<?> pluginClass
-
applicationContext
protected org.springframework.context.ApplicationContext applicationContext
-
manager
protected GrailsPluginManager manager
-
evictionList
protected java.lang.String[] evictionList
-
config
protected grails.config.Config config
-
-
Constructor Detail
-
AbstractGrailsPlugin
public AbstractGrailsPlugin(java.lang.Class<?> pluginClass, GrailsApplication application)
-
-
Method Detail
-
getPropertySource
public org.springframework.core.env.PropertySource<?> getPropertySource()
- Specified by:
getPropertySourcein interfaceGrailsPlugin
-
refresh
public void refresh()
Description copied from interface:GrailsPluginRefreshes this Grails plugin reloading any watched resources as necessary- Specified by:
refreshin interfaceGrailsPlugin
-
isEnabled
public boolean isEnabled(java.lang.String[] profiles)
Description copied from interface:GrailsPluginCheck whether the plugin is enabled for the given profile- Specified by:
isEnabledin interfaceGrailsPlugin- Returns:
- True if it is
-
readPluginConfiguration
protected org.springframework.core.io.Resource readPluginConfiguration(java.lang.Class<?> pluginClass)
-
getConfigurationResource
protected org.springframework.core.io.Resource getConfigurationResource(java.lang.Class<?> pluginClass, java.lang.String path)
-
getFileSystemName
public java.lang.String getFileSystemName()
Description copied from interface:GrailsPluginReturns the name of the plugin as represented in the file system including the version. For example TagLibGrailsPlugin would result in "tag-lib-0.1"- Specified by:
getFileSystemNamein interfaceGrailsPlugin- Returns:
- The file system representation of the plugin name
-
getFileSystemShortName
public java.lang.String getFileSystemShortName()
Description copied from interface:GrailsPluginReturns the name of the plugin as represented on the file system without the version. For example TagLibGrailsPlugin would result in "tag-lib"- Specified by:
getFileSystemShortNamein interfaceGrailsPlugin- Returns:
- The file system name
-
getPluginClass
public java.lang.Class<?> getPluginClass()
Description copied from interface:GrailsPluginReturns the underlying class that represents this plugin- Specified by:
getPluginClassin interfaceGrailsPlugin- Returns:
- The plugin class
-
isBasePlugin
public boolean isBasePlugin()
Description copied from interface:GrailsPluginReturns 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- Specified by:
isBasePluginin interfaceGrailsPlugin- Returns:
- true if it is the base plugin
-
setBasePlugin
public void setBasePlugin(boolean isBase)
Description copied from interface:GrailsPluginSets whether this plugin is the base plugin- Specified by:
setBasePluginin interfaceGrailsPlugin- Parameters:
isBase- True if is- See Also:
GrailsPlugin.isBasePlugin()
-
getWatchedResourcePatterns
public java.util.List<org.grails.plugins.support.WatchPattern> getWatchedResourcePatterns()
Description copied from interface:GrailsPluginResources that this plugin watches- Specified by:
getWatchedResourcePatternsin interfaceGrailsPlugin- 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- Parameters:
path- The path to the resource that changed- Returns:
- true if it is
-
checkForChanges
public boolean checkForChanges()
-
getDependencyNames
public java.lang.String[] getDependencyNames()
- Specified by:
getDependencyNamesin interfaceGrailsPlugin- Returns:
- The names of the plugins this plugin is dependant on
-
getDependentVersion
public java.lang.String getDependentVersion(java.lang.String name)
Description copied from interface:GrailsPluginThe version of the specified dependency- Specified by:
getDependentVersionin interfaceGrailsPlugin- Parameters:
name- the name of the dependency- Returns:
- The version
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfacegrails.plugins.GrailsPluginInfo
-
getVersion
public java.lang.String getVersion()
- Specified by:
getVersionin interfacegrails.plugins.GrailsPluginInfo
-
getPluginPath
public java.lang.String getPluginPath()
Description copied from interface:GrailsPluginReturns the path of the plug-in- Specified by:
getPluginPathin interfaceGrailsPlugin- Returns:
- A String that makes up the path to the plug-in in the format /plugins/plugin-name-PLUGIN_VERSION
-
getPluginPathCamelCase
public java.lang.String getPluginPathCamelCase()
Description copied from interface:GrailsPluginReturns the path of the plug-in using camel case- Specified by:
getPluginPathCamelCasein interfaceGrailsPlugin- Returns:
- A String that makes up the path to the plug-in in the format /plugins/pluginName-PLUGIN_VERSION
-
getManager
public GrailsPluginManager getManager()
Description copied from interface:GrailsPluginRetrieves the plugin manager if known, otherwise returns null- Specified by:
getManagerin interfaceGrailsPlugin- Returns:
- The PluginManager or null
-
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- 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- Returns:
- The names of the plugins that this plugin should load before
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
setManager
public void setManager(GrailsPluginManager manager)
Description copied from interface:GrailsPluginSets the plugin manager for this plugin- Specified by:
setManagerin interfaceGrailsPlugin- Parameters:
manager- A GrailsPluginManager instance
-
setApplication
public void setApplication(GrailsApplication application)
- Specified by:
setApplicationin interfaceGrailsPlugin
-
getEvictionNames
public java.lang.String[] getEvictionNames()
- Specified by:
getEvictionNamesin interfaceGrailsPlugin- Returns:
- The names of the plugins this plugin should evict onload
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
compareTo
public int compareTo(java.lang.Object o)
- Specified by:
compareToin interfacejava.lang.Comparable
-
-