Class DefaultGrailsPluginManager

  • All Implemented Interfaces:
    GrailsPluginManager, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
    Direct Known Subclasses:
    ProfilingGrailsPluginManager

    public class DefaultGrailsPluginManager
    extends AbstractGrailsPluginManager

    Handles the loading and management of plug-ins in the Grails system. A plugin is just like a normal Grails application except that it contains a file ending in *Plugin.groovy in the root of the directory.

    A Plugin class is a Groovy class that has a version and optionally closures called doWithSpring, doWithContext and doWithWebDescriptor

    The doWithSpring closure uses the BeanBuilder syntax (@see grails.spring.BeanBuilder) to provide runtime configuration of Grails via Spring

    The doWithContext closure is called after the Spring ApplicationContext is built and accepts a single argument (the ApplicationContext)

    The doWithWebDescriptor uses mark-up building to provide additional functionality to the web.xml file

    Example:

     class ClassEditorGrailsPlugin {
          def version = '1.1'
          def doWithSpring = { application ->
              classEditor(org.springframework.beans.propertyeditors.ClassEditor, application.classLoader)
          }
     }
     

    A plugin can also define "dependsOn" and "evict" properties that specify what plugins the plugin depends on and which ones it is incompatible with and should evict

    Since:
    0.4
    • Field Detail

      • COMMON_CLASSES

        protected static final java.lang.Class<?>[] COMMON_CLASSES
    • Constructor Detail

      • DefaultGrailsPluginManager

        public DefaultGrailsPluginManager​(java.lang.String resourcePath,
                                          GrailsApplication application)
      • DefaultGrailsPluginManager

        public DefaultGrailsPluginManager​(java.lang.String[] pluginResources,
                                          GrailsApplication application)
      • DefaultGrailsPluginManager

        public DefaultGrailsPluginManager​(java.lang.Class<?>[] plugins,
                                          GrailsApplication application)
      • DefaultGrailsPluginManager

        public DefaultGrailsPluginManager​(org.springframework.core.io.Resource[] pluginFiles,
                                          GrailsApplication application)
      • DefaultGrailsPluginManager

        public DefaultGrailsPluginManager​(GrailsApplication application)
    • Method Detail

      • getUserPlugins

        public GrailsPlugin[] getUserPlugins()
        Description copied from interface: GrailsPluginManager
        Gets plugin installed by the user and not provided by the framework
        Returns:
        A list of user plugins
      • refreshPlugin

        public void refreshPlugin​(java.lang.String name)
        Description copied from interface: GrailsPluginManager
        Refreshes the specified plugin. A refresh will force to plugin to "touch" each of its watched resources and fire modified events for each
        Parameters:
        name - The name of the plugin to refresh
      • getPluginObservers

        public java.util.Collection<GrailsPlugin> getPluginObservers​(GrailsPlugin plugin)
        Description copied from interface: GrailsPluginManager
        Retrieves a collection of plugins that are observing the specified plugin
        Parameters:
        plugin - The plugin to retrieve observers for
        Returns:
        A collection of observers
      • informObservers

        public void informObservers​(java.lang.String pluginName,
                                    java.util.Map event)
        Description copied from interface: GrailsPluginManager
        inform the specified plugins observers of the event specified by the passed Map instance
        Parameters:
        pluginName - The name of the plugin
        event - The event
      • loadPlugins

        public void loadPlugins()
                         throws grails.plugins.exceptions.PluginException
        Description copied from interface: GrailsPluginManager
        Performs the initial load of plug-ins throwing an exception if any dependencies don't resolve
        Throws:
        grails.plugins.exceptions.PluginException - Thrown when an error occurs loading the plugins
      • createGrailsPlugin

        protected GrailsPlugin createGrailsPlugin​(java.lang.Class<?> pluginClass)
      • createGrailsPlugin

        protected GrailsPlugin createGrailsPlugin​(java.lang.Class<?> pluginClass,
                                                  org.springframework.core.io.Resource resource)
      • canRegisterPlugin

        protected boolean canRegisterPlugin​(GrailsPlugin plugin)
      • evictPlugin

        protected void evictPlugin​(GrailsPlugin evictor,
                                   java.lang.String evicteeName)
      • 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 AbstractGrailsPluginManager
        Throws:
        org.springframework.beans.BeansException
      • setParentApplicationContext

        public void setParentApplicationContext​(org.springframework.context.ApplicationContext parent)
      • checkForChanges

        @Deprecated
        public void checkForChanges()
        Deprecated.
        Replaced by agent-based reloading, will be removed in a future version of Grails
        Description copied from interface: GrailsPluginManager
        Checks all the plugins to see whether they have any changes
      • reloadPlugin

        public void reloadPlugin​(GrailsPlugin plugin)