Package: grails.plugins

## [Java] Class DefaultGrailsPluginManager

- grails.plugins.DefaultGrailsPluginManager

-     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 Also:
    BeanBuilder<p<p<p<p<p<p>>>>>>
  Authors:
    Graeme Rocher
  Since:
    0.4

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected static java.lang.Class<?>[]` | `COMMON_CLASSES` |
    `private static java.lang.String` | `GRAILS_PLUGIN_SUFFIX` |
    `private static java.lang.String` | `GRAILS_VERSION` |
    `private static org.apache.commons.logging.Log` | `LOG` |
    `private java.util.Map<GrailsPlugin, java.lang.String>` | `delayedEvictions` |
    `private java.util.List<GrailsPlugin>` | `delayedLoadPlugins` |
    `private org.springframework.context.ApplicationContext` | `parentCtx` |
    `private PluginFilter` | `pluginFilter` |
    `private java.util.Map<java.lang.String, java.util.Set<GrailsPlugin>>` | `pluginToObserverMap` |
    `private org.springframework.core.io.support.PathMatchingResourcePatternResolver` | `resolver` |
    `private java.util.List<GrailsPlugin>` | `userPlugins` |

  - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class AbstractGrailsPluginManager` | `BLANK, CONFIG_BINDING_APP_NAME, CONFIG_BINDING_APP_VERSION, CONFIG_BINDING_GRAILS_HOME, CONFIG_BINDING_USER_HOME, CONFIG_FILE, LOG, application, applicationContext, classNameToPluginMap, failedPlugins, initialised, loadCorePlugins, pluginClasses, pluginList, pluginResources, plugins, shutdown`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `DefaultGrailsPluginManager (java.lang.String resourcePath, GrailsApplication application)`
    `DefaultGrailsPluginManager (java.lang.String[] pluginResources, GrailsApplication application)`
    `DefaultGrailsPluginManager (java.lang.Class<?>[] plugins, GrailsApplication application)`
    `DefaultGrailsPluginManager (org.springframework.core.io.Resource[] pluginFiles, GrailsApplication application)`
    `DefaultGrailsPluginManager (GrailsApplication application)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `private boolean` | `areDependenciesResolved(GrailsPlugin plugin)`
    `` | `private boolean` | `areNoneToLoadBefore(GrailsPlugin plugin)` Returns true if there are no plugins left that should, if possible, be loaded before this plugin.
    `` | `private void` | `attemptLoadPlugins(java.lang.ClassLoader gcl)`
    `` | `private void` | `attemptPluginLoad(GrailsPlugin plugin)` Attempts to load a plugin based on its dependencies.
    `` | `protected boolean` | `canRegisterPlugin(GrailsPlugin plugin)`
    `` | `public void` | `checkForChanges()` deprecated: Replaced by agent-based reloading, will be removed in a future version of Grails
    `` | `private GrailsPlugin` | `createBinaryGrailsPlugin(java.lang.Class<?> pluginClass, BinaryGrailsPluginDescriptor binaryDescriptor)`
    `` | `protected GrailsPlugin` | `createGrailsPlugin(java.lang.Class<?> pluginClass)`
    `` | `protected GrailsPlugin` | `createGrailsPlugin(java.lang.Class<?> pluginClass, org.springframework.core.io.Resource resource)`
    `` | `public void` | `doDynamicMethods()`
    `` | `protected void` | `evictPlugin(GrailsPlugin evictor, java.lang.String evicteeName)`
    `` | `private java.util.List<GrailsPlugin>` | `findCorePlugins()`
    `` | `private java.util.List<GrailsPlugin>` | `findUserPlugins(java.lang.ClassLoader gcl)`
    `` | `private PluginFilter` | `getPluginFilter()`
    `` | `private java.lang.String` | `getPluginGrailsVersion(GrailsPlugin plugin)`
    `` | `java.util.List<GrailsPlugin>` | `getPluginList()`
    `` | `public java.util.Collection<GrailsPlugin>` | `getPluginObservers(GrailsPlugin plugin)`
    `` | `public GrailsPlugin[]` | `getUserPlugins()`
    `` | `private boolean` | `hasDelayedDependencies(GrailsPlugin other)`
    `` | `private boolean` | `hasGrailsPlugin(java.lang.String name, java.lang.String version)`
    `` | `private boolean` | `hasValidPluginsToLoadBefore(GrailsPlugin plugin)`
    `` | `public void` | `informObservers(java.lang.String pluginName, java.util.Map event)`
    `` | `private void` | `initializePlugins()`
    `` | `private boolean` | `isCompatiblePlugin(GrailsPlugin plugin)` Checks plugin compatibility against used Grails version
    `` | `private boolean` | `isDependentOn(GrailsPlugin plugin, GrailsPlugin dependency)` Checks whether the first plugin is dependant on the second plugin.
    `` | `private boolean` | `isGrailsPlugin(java.lang.Class<?> pluginClass)`
    `` | `private void` | `loadDelayedPlugins()` This method will attempt to load that plug-ins not loaded in the first pass
    `` | `private java.lang.Class<?>` | `loadPluginClass(java.lang.ClassLoader cl, org.springframework.core.io.Resource r)`
    `` | `public void` | `loadPlugins()`
    `` | `private void` | `processDelayedEvictions()`
    `` | `public void` | `refreshPlugin(java.lang.String name)`
    `` | `private void` | `registerPlugin(GrailsPlugin plugin)`
    `` | `public void` | `reloadPlugin(GrailsPlugin plugin)`
    `` | `protected java.util.Map<GrailsPlugin, java.util.List<GrailsPlugin>>` | `resolveLoadDependencies(java.util.List<GrailsPlugin> plugins)`
    `` | `public void` | `setApplication(GrailsApplication application)`
    `` | `public void` | `setApplicationContext(org.springframework.context.ApplicationContext applicationContext)`
    `` | `public void` | `setParentApplicationContext(org.springframework.context.ApplicationContext parent)`
    `` | `private void` | `setPluginFilter()`
    `` | `public void` | `setPluginFilter(PluginFilter pluginFilter)`
    `` | `protected java.util.List<GrailsPlugin>` | `sortPlugins(java.util.List<GrailsPlugin> toSort)`
    `` | `private void` | `visitTopologicalSort(GrailsPlugin plugin, java.util.List<GrailsPlugin> sortedPlugins, java.util.Set<GrailsPlugin> visitedPlugins, java.util.Map<GrailsPlugin, java.util.List<GrailsPlugin>> loadOrderDependencies)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class AbstractGrailsPluginManager` | `checkInitialised, convert, doArtefactConfiguration, doDynamicMethods, doPostProcessing, doRuntimeConfiguration, doRuntimeConfiguration, doRuntimeConfigurationForDependencies, getAllPlugins, getConfigSlurper, getFailedLoadPlugins, getFailedPlugin, getGrailsPlugin, getGrailsPlugin, getGrailsPluginForClassName, getPluginForClass, getPluginForInstance, getPluginPath, getPluginPath, getPluginPathForClass, getPluginPathForInstance, getPluginResources, getPluginViewsPathForClass, getPluginViewsPathForInstance, getTypeFilters, hasGrailsPlugin, informOfClassChange, informOfClassChange, informOfFileChange, informPluginsOfConfigChange, isAlreadyRegistered, isInitialised, isPluginDisabledForProfile, isShutdown, loadApplicationClass, onStartup, registerProvidedArtefacts, setApplication, setApplicationContext, setLoadCorePlugins, setPluginFilter, shutdown`

- - ### Field Detail

    - #### protected static final java.lang.Class<?>[] COMMON_CLASSES

    - #### private static final java.lang.String GRAILS_PLUGIN_SUFFIX

    - #### private static final java.lang.String GRAILS_VERSION

    - #### private static final org.apache.commons.logging.Log LOG

    - #### private java.util.Map<GrailsPlugin, java.lang.String> delayedEvictions

    - #### private java.util.List<GrailsPlugin> delayedLoadPlugins

    - #### private org.springframework.context.ApplicationContext parentCtx

    - #### private PluginFilter pluginFilter

    - #### private java.util.Map<java.lang.String, java.util.Set<GrailsPlugin>> pluginToObserverMap

    - #### private org.springframework.core.io.support.PathMatchingResourcePatternResolver resolver

    - #### private java.util.List<GrailsPlugin> userPlugins

  - ### Constructor Detail

    - #### public DefaultGrailsPluginManager(java.lang.String resourcePath, GrailsApplication application)

    - #### public DefaultGrailsPluginManager(java.lang.String[] pluginResources, GrailsApplication application)

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

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

    - #### public DefaultGrailsPluginManager(GrailsApplication application)

  - ### Method Detail

    - #### private boolean areDependenciesResolved(GrailsPlugin plugin)

    - #### private boolean areNoneToLoadBefore(GrailsPlugin plugin)

      Returns true if there are no plugins left that should, if possible, be loaded before this plugin.

      Parameters:
        `plugin` - The plugin
      Returns:
        true if there are

    - #### private void attemptLoadPlugins(java.lang.ClassLoader gcl)

    - #### private void attemptPluginLoad(GrailsPlugin plugin)

      Attempts to load a plugin based on its dependencies. If a plugin's dependencies cannot be resolved it will add it to the list of dependencies to be resolved later.

      Parameters:
        `plugin` - The plugin

    - #### protected boolean canRegisterPlugin(GrailsPlugin plugin)

    - #### @java.lang.Deprecated public void checkForChanges()

      deprecated:
        Replaced by agent-based reloading, will be removed in a future version of Grails

    - #### private GrailsPlugin createBinaryGrailsPlugin(java.lang.Class<?> pluginClass, BinaryGrailsPluginDescriptor binaryDescriptor)

    - #### protected GrailsPlugin createGrailsPlugin(java.lang.Class<?> pluginClass)

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

    - #### @java.lang.Override public void doDynamicMethods()

    - #### protected void evictPlugin(GrailsPlugin evictor, java.lang.String evicteeName)

    - #### private java.util.List<GrailsPlugin> findCorePlugins()

    - #### private java.util.List<GrailsPlugin> findUserPlugins(java.lang.ClassLoader gcl)

    - #### private PluginFilter getPluginFilter()

    - #### private java.lang.String getPluginGrailsVersion(GrailsPlugin plugin)

    - #### java.util.List<GrailsPlugin> getPluginList()

    - #### public java.util.Collection<GrailsPlugin> getPluginObservers(GrailsPlugin plugin)

    - #### public GrailsPlugin[] getUserPlugins()

    - #### private boolean hasDelayedDependencies(GrailsPlugin other)

    - #### private boolean hasGrailsPlugin(java.lang.String name, java.lang.String version)

    - #### private boolean hasValidPluginsToLoadBefore(GrailsPlugin plugin)

    - #### @java.lang.SuppressWarnings("rawtypes") public void informObservers(java.lang.String pluginName, java.util.Map event)

    - #### private void initializePlugins()

    - #### private boolean isCompatiblePlugin(GrailsPlugin plugin)

      Checks plugin compatibility against used Grails version

      Parameters:
        `plugin` - the plugin to check
      Returns:
        true only in case plugin is compatible or impossible to determine, false otherwise

    - #### private boolean isDependentOn(GrailsPlugin plugin, GrailsPlugin dependency)

      Checks whether the first plugin is dependant on the second plugin.

      Parameters:
        `plugin` - The plugin to check
        `dependency` - The plugin which the first argument may be dependant on
      Returns:
        true if it is

    - #### private boolean isGrailsPlugin(java.lang.Class<?> pluginClass)

    - #### private void loadDelayedPlugins()

      This method will attempt to load that plug-ins not loaded in the first pass

    - #### private java.lang.Class<?> loadPluginClass(java.lang.ClassLoader cl, org.springframework.core.io.Resource r)

    - #### public void loadPlugins()

    - #### private void processDelayedEvictions()

    - #### public void refreshPlugin(java.lang.String name)

    - #### private void registerPlugin(GrailsPlugin plugin)

    - #### public void reloadPlugin(GrailsPlugin plugin)

    - #### protected java.util.Map<GrailsPlugin, java.util.List<GrailsPlugin>> resolveLoadDependencies(java.util.List<GrailsPlugin> plugins)

    - #### @java.lang.Override public void setApplication(GrailsApplication application)

    - #### @java.lang.Override public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)

    - #### public void setParentApplicationContext(org.springframework.context.ApplicationContext parent)

    - #### private void setPluginFilter()

    - #### public void setPluginFilter(PluginFilter pluginFilter)

    - #### protected java.util.List<GrailsPlugin> sortPlugins(java.util.List<GrailsPlugin> toSort)

    - #### private void visitTopologicalSort(GrailsPlugin plugin, java.util.List<GrailsPlugin> sortedPlugins, java.util.Set<GrailsPlugin> visitedPlugins, java.util.Map<GrailsPlugin, java.util.List<GrailsPlugin>> loadOrderDependencies)