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

      • LOG

        protected static final org.apache.commons.logging.Log LOG
      • pluginBean

        protected org.springframework.beans.BeanWrapper pluginBean
    • 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: GrailsPlugin
        Check whether the plugin is enabled for the given profile
        Specified by:
        isEnabled in interface GrailsPlugin
        Overrides:
        isEnabled in class AbstractGrailsPlugin
        Returns:
        True if it is
      • setApplicationContext

        public void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext)
                                   throws org.springframework.beans.BeansException
        Specified by:
        setApplicationContext in interface org.springframework.context.ApplicationContextAware
        Overrides:
        setApplicationContext in class AbstractGrailsPlugin
        Throws:
        org.springframework.beans.BeansException
      • 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
        Overrides:
        getLoadAfterNames in class AbstractGrailsPlugin
        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
        Overrides:
        getLoadBeforeNames in class AbstractGrailsPlugin
        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: GrailsPlugin

        This method is called to allow the plugin to add BeanDefinitions to the BeanDefinitionRegistry.

        Specified by:
        doWithApplicationContext in interface GrailsPlugin
        Parameters:
        ctx - The Spring ApplicationContext instance
      • doWithRuntimeConfiguration

        public void doWithRuntimeConfiguration​(org.grails.spring.RuntimeSpringConfiguration springConfig)
        Description copied from interface: GrailsPlugin
        Executes the plugin code that performs runtime configuration as defined in the doWithSpring closure
        Specified by:
        doWithRuntimeConfiguration in interface GrailsPlugin
        Parameters:
        springConfig - The RuntimeSpringConfiguration instance
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface grails.plugins.GrailsPluginInfo
        Overrides:
        getName in class AbstractGrailsPlugin
      • addExclude

        public void addExclude​(grails.util.Environment env)
        Description copied from interface: GrailsPlugin
        Makes the plugin excluded for a particular Environment
        Specified by:
        addExclude in interface GrailsPlugin
        Parameters:
        env - The Environment
      • supportsEnvironment

        public boolean supportsEnvironment​(grails.util.Environment environment)
        Description copied from interface: GrailsPlugin
        Returns whether this plugin supports the given environment name
        Specified by:
        supportsEnvironment in interface GrailsPlugin
        Parameters:
        environment - The environment name
        Returns:
        true if it does
      • supportsCurrentScopeAndEnvironment

        public boolean supportsCurrentScopeAndEnvironment()
        Specified by:
        supportsCurrentScopeAndEnvironment in interface GrailsPlugin
        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 supported
        Description copied from interface: GrailsPlugin
        Write some documentation to the DocumentationContext
        Specified by:
        doc in interface GrailsPlugin
        Parameters:
        text -
      • getWatchedResources

        public org.springframework.core.io.Resource[] getWatchedResources()
        Returns:
        the watchedResources
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.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()
      • getInstance

        public groovy.lang.GroovyObject getInstance()
        Description copied from interface: GrailsPlugin
        Retrieves the wrapped plugin instance for this plugin
        Specified by:
        getInstance in interface GrailsPlugin
        Returns:
        The plugin instance
      • doWithDynamicMethods

        public void doWithDynamicMethods​(org.springframework.context.ApplicationContext ctx)
        Description copied from interface: GrailsPlugin
        Calls a "doWithDynamicMethods" closure that allows a plugin to register dynamic methods at runtime
        Specified by:
        doWithDynamicMethods in interface GrailsPlugin
        Parameters:
        ctx - The Spring ApplicationContext instance
      • isEnabled

        public boolean isEnabled()
        Specified by:
        isEnabled in interface GrailsPlugin
        Returns:
        Whether the plugin is enabled or not
      • getObservedPluginNames

        public java.lang.String[] getObservedPluginNames()
        Description copied from interface: GrailsPlugin
        Retrieve the plugin names that this plugin is observing for changes
        Specified by:
        getObservedPluginNames in interface GrailsPlugin
        Returns:
        The names of the observed plugins
      • notifyOfEvent

        public void notifyOfEvent​(java.util.Map event)
        Description copied from interface: GrailsPlugin
        Notifies this plugin of the specified Event calling the onChange listener
        Specified by:
        notifyOfEvent in interface GrailsPlugin
        Parameters:
        event - The event to listen for
      • notifyOfEvent

        public java.util.Map notifyOfEvent​(int eventKind,
                                           java.lang.Object source)
        Description copied from interface: GrailsPlugin
        Notifies the plugin of a specific event for the given event id, which is one of ON_CHANGE, ON_CONFIG_CHANGE
        Specified by:
        notifyOfEvent in interface GrailsPlugin
        Parameters:
        eventKind - The event kind
        source - The source of the event
        Returns:
        a Map that represents the event
      • doArtefactConfiguration

        public void doArtefactConfiguration()
        Description copied from interface: GrailsPlugin
        Called prior to the initialisation of the GrailsApplication instance to allow the registration of additonal ArtefactHandlers
        Specified by:
        doArtefactConfiguration in interface GrailsPlugin
        See Also:
        ArtefactHandler
      • getProvidedArtefacts

        public java.lang.Class<?>[] getProvidedArtefacts()
        Description copied from interface: GrailsPlugin
        Retrieves an array of provided Artefacts that are pre-compiled additions to the GrailsApplication object but are overridable by the end-user
        Specified by:
        getProvidedArtefacts in interface GrailsPlugin
        Returns:
        A list of provided artefacts
      • getPluginExcludes

        public java.util.List<java.lang.String> getPluginExcludes()
        Description copied from interface: GrailsPlugin
        A list of resources that the plugin should exclude from the packaged distribution
        Specified by:
        getPluginExcludes in interface GrailsPlugin
        Returns:
        a List of resources
      • getTypeFilters

        public java.util.Collection<? extends org.springframework.core.type.filter.TypeFilter> getTypeFilters()
        Description copied from interface: GrailsPlugin
        Plugin can provide a list of Spring TypeFilters so that annotated components can be scanned into the ApplicationContext
        Specified by:
        getTypeFilters in interface GrailsPlugin
        Returns:
        A collection of TypeFilter instance
      • getFullName

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

        public org.grails.io.support.Resource getDescriptor()
        Specified by:
        getDescriptor in interface grails.plugins.GrailsPluginInfo
      • setDescriptor

        public void setDescriptor​(org.springframework.core.io.Resource descriptor)
        Description copied from interface: GrailsPlugin
        Sets the plugin descriptor for this plugin
        Specified by:
        setDescriptor in interface GrailsPlugin
        Parameters:
        descriptor - The descriptor
      • getPluginDir

        public org.grails.io.support.Resource getPluginDir()
        Specified by:
        getPluginDir in interface grails.plugins.GrailsPluginInfo
      • getProperties

        public java.util.Map getProperties()
        Specified by:
        getProperties in interface grails.plugins.GrailsPluginInfo