Package: grails.plugins

## [Groovy] Class Plugin

- grails.plugins.Plugin

- All Implemented Interfaces and Traits:
    GrailsApplicationAware, GrailsApplicationLifeCycle, org.springframework.context.ApplicationContextAware, PluginManagerAware

      @groovy.transform.CompileStatic
      abstract class Plugin
      extends java.lang.Object
      implements GrailsApplicationAware, GrailsApplicationLifeCycle, org.springframework.context.ApplicationContextAware, PluginManagerAware

  Super class for plugins to implement. Plugin implementations should define the various plugin hooks (doWithSpring, doWithApplicationContext, doWithDynamicMethods etc.)

  Authors:
    Graeme Rocher
  Since:
    3.0

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `private org.springframework.context.ApplicationContext` | `applicationContext` | The org.springframework.context.ApplicationContext instance
    `private java.util.List<ArtefactHandler>` | `artefacts` | List of ArtefactHandler instances provided by this plugin
    `private boolean` | `enabled` | Whether the plugin is enabled
    `private Environment` | `environment` | The current Grails Environment
    `private GrailsApplication` | `grailsApplication` | The GrailsApplication instance
    `private GrailsPlugin` | `plugin` | The GrailsPlugin definition for this plugin
    `private GrailsPluginManager` | `pluginManager` | The GrailsPluginManager instance

  - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `org.springframework.context.ConfigurableApplicationContext` | `applicationContext`
    `java.util.List<ArtefactHandler>` | `artefacts` List of ArtefactHandler instances provided by this plugin
    `boolean` | `enabled` Whether the plugin is enabled
    `Environment` | `environment` The current Grails Environment
    `GrailsApplication` | `grailsApplication` The GrailsApplication instance
    `GrailsPlugin` | `plugin` The GrailsPlugin definition for this plugin
    `GrailsPluginManager` | `pluginManager` The GrailsPluginManager instance

  - ### Constructor Summary

    Constructors
    Constructor and description
    `Plugin ()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `void` | `beans(groovy.lang.Closure beanDefinitions)` Allows a plugin to define beans at runtime.
    `` | `void` | `doWithApplicationContext()` Invokes once the org.springframework.context.ApplicationContext has been refreshed and after {#doWithDynamicMethods()} is invoked.
    `` | `void` | `doWithDynamicMethods()` Invoked in a phase where plugins can add dynamic methods.
    `` | `groovy.lang.Closure` | `doWithSpring()` Sub classes should override to provide implementations
    `` | `org.springframework.context.ConfigurableApplicationContext` | `getApplicationContext()` Returns: The ApplicationContext
    `` | `Config` | `getConfig()` Returns: The Config instance for this plugin
    `` | `GrailsPluginManager` | `getManager()` The GrailsPluginManager instance
    `` | `void` | `onChange(java.util.Map<java.lang.String, java.lang.Object> event)` Invoked when a object this plugin is watching changes
    `` | `void` | `onConfigChange(java.util.Map<java.lang.String, java.lang.Object> event)` Invoked when the application configuration changes
    `` | `void` | `onShutdown(java.util.Map<java.lang.String, java.lang.Object> event)` Invoked when the org.springframework.context.ApplicationContext is closed
    `` | `void` | `onStartup(java.util.Map<java.lang.String, java.lang.Object> event)`
    `` | `void` | `setApplicationContext(org.springframework.context.ApplicationContext applicationContext)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Field Detail

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

      The org.springframework.context.ApplicationContext instance

    - #### private final java.util.List<ArtefactHandler> artefacts

      List of ArtefactHandler instances provided by this plugin

    - #### private boolean enabled

      Whether the plugin is enabled

    - #### private Environment environment

      The current Grails Environment

    - #### private GrailsApplication grailsApplication

      The GrailsApplication instance

    - #### private GrailsPlugin plugin

      The GrailsPlugin definition for this plugin

    - #### private GrailsPluginManager pluginManager

      The GrailsPluginManager instance

  - ### Property Detail

    - #### org.springframework.context.ConfigurableApplicationContext applicationContext

    - #### final java.util.List<ArtefactHandler> artefacts

      List of ArtefactHandler instances provided by this plugin

    - #### boolean enabled

      Whether the plugin is enabled

    - #### Environment environment

      The current Grails Environment

    - #### GrailsApplication grailsApplication

      The GrailsApplication instance

    - #### GrailsPlugin plugin

      The GrailsPlugin definition for this plugin

    - #### GrailsPluginManager pluginManager

      The GrailsPluginManager instance

  - ### Constructor Detail

    - #### Plugin()

  - ### Method Detail

    - #### void beans(groovy.lang.Closure beanDefinitions)

      Allows a plugin to define beans at runtime. Used primarily for reloading in development mode

      Parameters:
        `beanDefinitions` - The bean definitions
      Returns:
        The BeanBuilder instance

    - #### @java.lang.Override void doWithApplicationContext()

      Invokes once the org.springframework.context.ApplicationContext has been refreshed and after {#doWithDynamicMethods()} is invoked. Subclasses should override

    - #### @java.lang.Override void doWithDynamicMethods()

      Invoked in a phase where plugins can add dynamic methods. Subclasses should override

    - #### @java.lang.Override groovy.lang.Closure doWithSpring()

      Sub classes should override to provide implementations

      Returns:
        A closure that defines beans to be executed by Spring

    - #### org.springframework.context.ConfigurableApplicationContext getApplicationContext()

      Returns:
        The ApplicationContext

    - #### Config getConfig()

      Returns:
        The Config instance for this plugin

    - #### GrailsPluginManager getManager()

      The GrailsPluginManager instance

    - #### void onChange(java.util.Map<java.lang.String, java.lang.Object> event)

      Invoked when a object this plugin is watching changes

      Parameters:
        `event` - The event

    - #### @java.lang.Override void onConfigChange(java.util.Map<java.lang.String, java.lang.Object> event)

      Invoked when the application configuration changes

      Parameters:
        `event` - The event

    - #### @java.lang.Override void onShutdown(java.util.Map<java.lang.String, java.lang.Object> event)

      Invoked when the org.springframework.context.ApplicationContext is closed

      Parameters:
        `event` - The event

    - #### @java.lang.Override void onStartup(java.util.Map<java.lang.String, java.lang.Object> event)

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