Class AbstractGrailsPluginManager

java.lang.Object
org.grails.plugins.AbstractGrailsPluginManager
All Implemented Interfaces:
GrailsPluginManager, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
DefaultGrailsPluginManager, MockGrailsPluginManager

public abstract class AbstractGrailsPluginManager extends Object implements GrailsPluginManager
Abstract implementation of the GrailsPluginManager interface
Since:
0.4
  • Field Details

    • CONFIG_FILE

      public static final String CONFIG_FILE
      See Also:
    • pluginList

      protected List<GrailsPlugin> pluginList
    • application

      protected GrailsApplication application
    • pluginResources

      protected org.springframework.core.io.Resource[] pluginResources
    • plugins

      protected Map<String,GrailsPlugin> plugins
    • classNameToPluginMap

      protected Map<String,GrailsPlugin> classNameToPluginMap
    • pluginClasses

      protected Class<?>[] pluginClasses
    • initialised

      protected boolean initialised
    • shutdown

      protected boolean shutdown
    • applicationContext

      protected org.springframework.context.ApplicationContext applicationContext
    • failedPlugins

      protected Map<String,GrailsPlugin> failedPlugins
    • loadCorePlugins

      protected boolean loadCorePlugins
  • Constructor Details

    • AbstractGrailsPluginManager

      public AbstractGrailsPluginManager(GrailsApplication application)
  • Method Details

    • getTypeFilters

      public List<org.springframework.core.type.filter.TypeFilter> getTypeFilters()
      Description copied from interface: GrailsPluginManager
      Get all of the TypeFilter definitions defined by the plugins
      Specified by:
      getTypeFilters in interface GrailsPluginManager
      Returns:
      A list of TypeFilter definitions
    • getAllPlugins

      public GrailsPlugin[] getAllPlugins()
      Description copied from interface: GrailsPluginManager
      Returns an array of all the loaded plug-ins
      Specified by:
      getAllPlugins in interface GrailsPluginManager
      Returns:
      An array of plug-ins
    • getFailedLoadPlugins

      public GrailsPlugin[] getFailedLoadPlugins()
      Specified by:
      getFailedLoadPlugins in interface GrailsPluginManager
      Returns:
      An array of plugins that failed to load due to dependency resolution errors
    • isInitialised

      public boolean isInitialised()
      Specified by:
      isInitialised in interface GrailsPluginManager
      Returns:
      the initialised
    • checkInitialised

      protected void checkInitialised()
    • getFailedPlugin

      public GrailsPlugin getFailedPlugin(String name)
      Description copied from interface: GrailsPluginManager
      Retrieves a plug-in that failed to load, or null if it doesn't exist
      Specified by:
      getFailedPlugin in interface GrailsPluginManager
      Parameters:
      name - The name of the plugin
      Returns:
      A GrailsPlugin or null
    • doRuntimeConfiguration

      public void doRuntimeConfiguration(org.grails.spring.RuntimeSpringConfiguration springConfig)
      Base implementation that simply goes through the list of plugins and calls doWithRuntimeConfiguration on each
      Specified by:
      doRuntimeConfiguration in interface GrailsPluginManager
      Parameters:
      springConfig - The RuntimeSpringConfiguration instance
    • doRuntimeConfiguration

      public void doRuntimeConfiguration(String pluginName, org.grails.spring.RuntimeSpringConfiguration springConfig)
      Base implementation that will perform runtime configuration for the specified plugin name.
      Specified by:
      doRuntimeConfiguration in interface GrailsPluginManager
      Parameters:
      pluginName - The name of he plugin
      springConfig - The runtime spring config instance
    • doPostProcessing

      public void doPostProcessing(org.springframework.context.ApplicationContext ctx)
      Base implementation that will simply go through each plugin and call doWithApplicationContext on each.
      Specified by:
      doPostProcessing in interface GrailsPluginManager
      Parameters:
      ctx - The ApplicationContext instance
    • getPluginResources

      public org.springframework.core.io.Resource[] getPluginResources()
    • getGrailsPlugin

      public GrailsPlugin getGrailsPlugin(String name)
      Description copied from interface: GrailsPluginManager
      Retrieves a name Grails plugin instance
      Specified by:
      getGrailsPlugin in interface GrailsPluginManager
      Parameters:
      name - The name of the plugin
      Returns:
      The GrailsPlugin instance or null if it doesn't exist
    • getGrailsPluginForClassName

      public GrailsPlugin getGrailsPluginForClassName(String name)
      Description copied from interface: GrailsPluginManager
      Obtains a GrailsPlugin for the given classname
      Specified by:
      getGrailsPluginForClassName in interface GrailsPluginManager
      Parameters:
      name - The name of the plugin
      Returns:
      The instance
    • getGrailsPlugin

      public GrailsPlugin getGrailsPlugin(String name, Object version)
      Description copied from interface: GrailsPluginManager
      Retrieves a plug-in for its name and version
      Specified by:
      getGrailsPlugin in interface GrailsPluginManager
      Parameters:
      name - The name of the plugin
      version - The version of the plugin
      Returns:
      The GrailsPlugin instance or null if it doesn't exist
    • hasGrailsPlugin

      public boolean hasGrailsPlugin(String name)
      Specified by:
      hasGrailsPlugin in interface GrailsPluginManager
      Parameters:
      name - The name of the plugin
      Returns:
      true if the the manager has a loaded plugin with the given name
    • doDynamicMethods

      public void doDynamicMethods()
      Description copied from interface: GrailsPluginManager
      Called on all plugins so that they can add new methods/properties/constructors etc.
      Specified by:
      doDynamicMethods in interface GrailsPluginManager
    • 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
    • setApplication

      public void setApplication(GrailsApplication application)
      Description copied from interface: GrailsPluginManager
      Sets the GrailsApplication used be this plugin manager
      Specified by:
      setApplication in interface GrailsPluginManager
      Parameters:
      application - The GrailsApplication instance
    • registerProvidedArtefacts

      public void registerProvidedArtefacts(GrailsApplication app)
      Description copied from interface: GrailsPluginManager
      Registers pre-compiled artefacts with the GrailsApplication instance, only overriding if the application doesn't already provide an artefact of the same name.
      Specified by:
      registerProvidedArtefacts in interface GrailsPluginManager
      Parameters:
      app - The GrailsApplication object
    • doArtefactConfiguration

      public void doArtefactConfiguration()
      Description copied from interface: GrailsPluginManager
      Called prior to the initialisation of the GrailsApplication object to allow registration of additional ArtefactHandler objects
      Specified by:
      doArtefactConfiguration in interface GrailsPluginManager
      See Also:
    • isPluginDisabledForProfile

      protected boolean isPluginDisabledForProfile(GrailsPlugin plugin)
    • onStartup

      public void onStartup(Map<String,Object> event)
      Description copied from interface: GrailsPluginManager
      Executes the Plugin.onStartup(Map) hook for all plugins
      Specified by:
      onStartup in interface GrailsPluginManager
      Parameters:
      event - the Event
    • shutdown

      public void shutdown()
      Description copied from interface: GrailsPluginManager
      Shuts down the PluginManager
      Specified by:
      shutdown in interface GrailsPluginManager
    • isShutdown

      public boolean isShutdown()
      Description copied from interface: GrailsPluginManager
      Indicates whether the manager has been shutdown or not
      Specified by:
      isShutdown in interface GrailsPluginManager
      Returns:
      True if it was shutdown
    • setPluginFilter

      public void setPluginFilter(PluginFilter pluginFilter)
      Description copied from interface: GrailsPluginManager
      Sets the filter to use to filter for plugins
      Specified by:
      setPluginFilter in interface GrailsPluginManager
      Parameters:
      pluginFilter - The plugin filter
    • setLoadCorePlugins

      public void setLoadCorePlugins(boolean shouldLoadCorePlugins)
      Description copied from interface: GrailsPluginManager
      Set whether the core plugins should be loaded
      Specified by:
      setLoadCorePlugins in interface GrailsPluginManager
      Parameters:
      shouldLoadCorePlugins - True if they should
    • informOfClassChange

      public void informOfClassChange(Class<?> aClass)
      Description copied from interface: GrailsPluginManager
      Method for handling changes to a class and triggering on change events etc.
      Specified by:
      informOfClassChange in interface GrailsPluginManager
      Parameters:
      aClass - The class
    • getPluginPath

      public String getPluginPath(String name)
      Description copied from interface: GrailsPluginManager
      Returns the pluginContextPath for the given plugin
      Specified by:
      getPluginPath in interface GrailsPluginManager
      Parameters:
      name - The plugin name
      Returns:
      the context path
    • getPluginPath

      public String getPluginPath(String name, boolean forceCamelCase)
      Description copied from interface: GrailsPluginManager
      Returns the pluginContextPath for the given plugin and will force name to camel case instead of '-' lower case my-plug-web would resolve to myPlugWeb if forceCamelCase is true.
      Specified by:
      getPluginPath in interface GrailsPluginManager
      Parameters:
      name - The plugin name
      forceCamelCase - Force camel case for name
      Returns:
      the context path
    • getPluginPathForInstance

      public String getPluginPathForInstance(Object instance)
      Description copied from interface: GrailsPluginManager
      Returns the pluginContextPath for the given instance
      Specified by:
      getPluginPathForInstance in interface GrailsPluginManager
      Parameters:
      instance - The instance
      Returns:
      The pluginContextPath
    • getPluginForInstance

      public GrailsPlugin getPluginForInstance(Object instance)
      Description copied from interface: GrailsPluginManager
      Looks up the plugin that defined the given instance. If no plugin defined the instance then null is returned.
      Specified by:
      getPluginForInstance in interface GrailsPluginManager
      Parameters:
      instance - The instance
      Returns:
      The plugin that defined the instance or null
    • getPluginForClass

      public GrailsPlugin getPluginForClass(Class<?> theClass)
      Description copied from interface: GrailsPluginManager
      Obtains the GrailsPlugin for the given class
      Specified by:
      getPluginForClass in interface GrailsPluginManager
      Parameters:
      theClass - The class
      Returns:
      The GrailsPlugin for the given class or null if not related to any plugin
    • informPluginsOfConfigChange

      public void informPluginsOfConfigChange()
      Description copied from interface: GrailsPluginManager
      Inform of a change in configuration
      Specified by:
      informPluginsOfConfigChange in interface GrailsPluginManager
    • informOfFileChange

      public void informOfFileChange(File file)
      Description copied from interface: GrailsPluginManager
      Fire to inform the PluginManager that a particular file changes
      Specified by:
      informOfFileChange in interface GrailsPluginManager
      Parameters:
      file - The file that changed
    • informOfClassChange

      public void informOfClassChange(File file, Class cls)
      Specified by:
      informOfClassChange in interface GrailsPluginManager
    • getPluginPathForClass

      public String getPluginPathForClass(Class<?> theClass)
      Description copied from interface: GrailsPluginManager
      Returns the plugin path for the given class
      Specified by:
      getPluginPathForClass in interface GrailsPluginManager
      Parameters:
      theClass - The class
      Returns:
      The pluginContextPath
    • getPluginViewsPathForInstance

      public String getPluginViewsPathForInstance(Object instance)
      Description copied from interface: GrailsPluginManager
      Returns the plugin views directory for the given instance
      Specified by:
      getPluginViewsPathForInstance in interface GrailsPluginManager
      Parameters:
      instance - The instance
      Returns:
      The pluginContextPath
    • getPluginViewsPathForClass

      public String getPluginViewsPathForClass(Class<?> theClass)
      Description copied from interface: GrailsPluginManager
      Returns the plugin views directory path for the given class
      Specified by:
      getPluginViewsPathForClass in interface GrailsPluginManager
      Parameters:
      theClass - The class
      Returns:
      The pluginContextPath