Class 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 Detail

      • 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
      • 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
      • 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 interface GrailsPlugin
      • refresh

        public void refresh()
        Description copied from interface: GrailsPlugin
        Refreshes this Grails plugin reloading any watched resources as necessary
        Specified by:
        refresh in interface GrailsPlugin
      • 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 interface GrailsPlugin
        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 interface GrailsPlugin
        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 interface GrailsPlugin
        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 interface GrailsPlugin
        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 interface GrailsPlugin
        Returns:
        true if it is the base plugin
      • 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 interface GrailsPlugin
        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 interface GrailsPlugin
        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 interface GrailsPlugin
        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 interface GrailsPlugin
        Parameters:
        name - the name of the dependency
        Returns:
        The version
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface grails.plugins.GrailsPluginInfo
      • getVersion

        public java.lang.String getVersion()
        Specified by:
        getVersion in interface grails.plugins.GrailsPluginInfo
      • getPluginPath

        public java.lang.String getPluginPath()
        Description copied from interface: GrailsPlugin
        Returns the path of the plug-in
        Specified by:
        getPluginPath in interface GrailsPlugin
        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 interface GrailsPlugin
        Returns:
        A String that makes up the path to the plug-in in the format /plugins/pluginName-PLUGIN_VERSION
      • 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 interface GrailsPlugin
        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 interface GrailsPlugin
        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 interface org.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 interface GrailsPlugin
        Parameters:
        manager - A GrailsPluginManager instance
      • getEvictionNames

        public java.lang.String[] getEvictionNames()
        Specified by:
        getEvictionNames in interface GrailsPlugin
        Returns:
        The names of the plugins this plugin should evict onload
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • compareTo

        public int compareTo​(java.lang.Object o)
        Specified by:
        compareTo in interface java.lang.Comparable