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.ApplicationContext
applicationContext
protected grails.config.Config
config
protected java.util.Map<java.lang.String,java.lang.Object>
dependencies
protected java.lang.String[]
dependencyNames
protected java.lang.String[]
evictionList
protected GrailsApplication
grailsApplication
protected boolean
isBase
protected GrailsPluginManager
manager
static java.lang.String
PLUGIN_GROOVY
static java.lang.String
PLUGIN_GROOVY_PATH
static java.lang.String
PLUGIN_YML
static java.lang.String
PLUGIN_YML_PATH
protected java.lang.Class<?>
pluginClass
protected org.springframework.core.env.PropertySource<?>
propertySource
protected java.lang.String
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 AbstractGrailsPlugin(java.lang.Class<?> pluginClass, GrailsApplication application)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkForChanges()
int
compareTo(java.lang.Object o)
boolean
equals(java.lang.Object o)
protected org.springframework.core.io.Resource
getConfigurationResource(java.lang.Class<?> pluginClass, java.lang.String path)
java.lang.String[]
getDependencyNames()
java.lang.String
getDependentVersion(java.lang.String name)
The version of the specified dependencyjava.lang.String[]
getEvictionNames()
java.lang.String
getFileSystemName()
Returns the name of the plugin as represented in the file system including the version.java.lang.String
getFileSystemShortName()
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.GrailsPluginManager
getManager()
Retrieves the plugin manager if known, otherwise returns nulljava.lang.String
getName()
java.lang.Class<?>
getPluginClass()
Returns the underlying class that represents this pluginjava.lang.String
getPluginPath()
Returns the path of the plug-injava.lang.String
getPluginPathCamelCase()
Returns the path of the plug-in using camel caseorg.springframework.core.env.PropertySource<?>
getPropertySource()
java.lang.String
getVersion()
java.util.List<org.grails.plugins.support.WatchPattern>
getWatchedResourcePatterns()
Resources that this plugin watchesint
hashCode()
boolean
hasInterestInChange(java.lang.String path)
Whether the plugin is interested in a particular changeboolean
isBasePlugin()
Returns whether this plugin is loaded from the current plugin.boolean
isEnabled(java.lang.String[] profiles)
Check whether the plugin is enabled for the given profileprotected org.springframework.core.io.Resource
readPluginConfiguration(java.lang.Class<?> pluginClass)
void
refresh()
Refreshes this Grails plugin reloading any watched resources as necessaryvoid
setApplication(GrailsApplication application)
void
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
void
setBasePlugin(boolean isBase)
Sets whether this plugin is the base pluginvoid
setManager(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:
getPropertySource
in interfaceGrailsPlugin
-
refresh
public void refresh()
Description copied from interface:GrailsPlugin
Refreshes this Grails plugin reloading any watched resources as necessary- Specified by:
refresh
in interfaceGrailsPlugin
-
isEnabled
public boolean isEnabled(java.lang.String[] profiles)
Description copied from interface:GrailsPlugin
Check whether the plugin is enabled for the given profile- Specified by:
isEnabled
in 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:GrailsPlugin
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"- Specified by:
getFileSystemName
in interfaceGrailsPlugin
- Returns:
- The file system representation of the plugin name
-
getFileSystemShortName
public java.lang.String getFileSystemShortName()
Description copied from interface:GrailsPlugin
Returns the name of the plugin as represented on the file system without the version. For example TagLibGrailsPlugin would result in "tag-lib"- Specified by:
getFileSystemShortName
in interfaceGrailsPlugin
- Returns:
- The file system name
-
getPluginClass
public java.lang.Class<?> getPluginClass()
Description copied from interface:GrailsPlugin
Returns the underlying class that represents this plugin- Specified by:
getPluginClass
in interfaceGrailsPlugin
- Returns:
- The plugin class
-
isBasePlugin
public boolean isBasePlugin()
Description copied from interface:GrailsPlugin
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- Specified by:
isBasePlugin
in interfaceGrailsPlugin
- Returns:
- true if it is the base plugin
-
setBasePlugin
public void setBasePlugin(boolean isBase)
Description copied from interface:GrailsPlugin
Sets whether this plugin is the base plugin- Specified by:
setBasePlugin
in 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:GrailsPlugin
Resources that this plugin watches- Specified by:
getWatchedResourcePatterns
in interfaceGrailsPlugin
- Returns:
- The watch resource patterns
-
hasInterestInChange
public boolean hasInterestInChange(java.lang.String path)
Description copied from interface:GrailsPlugin
Whether the plugin is interested in a particular change- Specified by:
hasInterestInChange
in 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:
getDependencyNames
in 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:GrailsPlugin
The version of the specified dependency- Specified by:
getDependentVersion
in interfaceGrailsPlugin
- Parameters:
name
- the name of the dependency- Returns:
- The version
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfacegrails.plugins.GrailsPluginInfo
-
getVersion
public java.lang.String getVersion()
- Specified by:
getVersion
in interfacegrails.plugins.GrailsPluginInfo
-
getPluginPath
public java.lang.String getPluginPath()
Description copied from interface:GrailsPlugin
Returns the path of the plug-in- Specified by:
getPluginPath
in 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:GrailsPlugin
Returns the path of the plug-in using camel case- Specified by:
getPluginPathCamelCase
in 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:GrailsPlugin
Retrieves the plugin manager if known, otherwise returns null- Specified by:
getManager
in interfaceGrailsPlugin
- Returns:
- The PluginManager or null
-
getLoadAfterNames
public java.lang.String[] getLoadAfterNames()
Description copied from interface:GrailsPlugin
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- Specified by:
getLoadAfterNames
in interfaceGrailsPlugin
- Returns:
- The names of the plugins that this plugin should be loaded after
-
getLoadBeforeNames
public java.lang.String[] getLoadBeforeNames()
Description copied from interface:GrailsPlugin
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- Specified by:
getLoadBeforeNames
in 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:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
setManager
public void setManager(GrailsPluginManager manager)
Description copied from interface:GrailsPlugin
Sets the plugin manager for this plugin- Specified by:
setManager
in interfaceGrailsPlugin
- Parameters:
manager
- A GrailsPluginManager instance
-
setApplication
public void setApplication(GrailsApplication application)
- Specified by:
setApplication
in interfaceGrailsPlugin
-
getEvictionNames
public java.lang.String[] getEvictionNames()
- Specified by:
getEvictionNames
in interfaceGrailsPlugin
- Returns:
- The names of the plugins this plugin should evict onload
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
compareTo
public int compareTo(java.lang.Object o)
- Specified by:
compareTo
in interfacejava.lang.Comparable
-
-