org.codehaus.groovy.grails.plugins
Class AbstractGrailsPlugin

java.lang.Object
  extended by groovy.lang.GroovyObjectSupport
      extended by org.codehaus.groovy.grails.plugins.AbstractGrailsPlugin
All Implemented Interfaces:
groovy.lang.GroovyObject, GrailsPlugin, ApplicationContextAware
Direct Known Subclasses:
AwarePlugin, DefaultGrailsPlugin

public abstract class AbstractGrailsPlugin
extends groovy.lang.GroovyObjectSupport
implements GrailsPlugin

Abstract implementation that provides some default behaviours

Author:
Graeme Rocher

Nested Class Summary
(package private)  class AbstractGrailsPlugin.GrailsPluginClass
          Wrapper Grails class for plugins
 
Field Summary
protected  GrailsApplication application
           
protected  ApplicationContext applicationContext
           
protected  Map dependencies
           
protected  String[] dependencyNames
           
protected  String[] evictionList
           
protected  GrailsPluginManager manager
           
protected  Class pluginClass
           
protected  String version
           
 
Fields inherited from interface org.codehaus.groovy.grails.plugins.GrailsPlugin
ARTEFACTS, DEPENDS_ON, DO_WITH_APPLICATION_CONTEXT, DO_WITH_DYNAMIC_METHODS, DO_WITH_SPRING, DO_WITH_WEB_DESCRIPTOR, EVENT_ON_CHANGE, EVENT_ON_CONFIG_CHANGE, EVICT, INFLUENCES, ON_CHANGE, ON_CONFIG_CHANGE, PROVIDED_ARTEFACTS, STATUS, STATUS_DISABLED, STATUS_ENABLED, TRAILING_NAME, VERSION, WATCHED_RESOURCES
 
Constructor Summary
AbstractGrailsPlugin(Class pluginClass, GrailsApplication application)
           
 
Method Summary
 boolean checkForChanges()
          When called this method checks for any changes to the plug-ins watched resources and reloads appropriately
abstract  void doArtefactConfiguration()
          Called prior to the initialisation of the GrailsApplication instance to allow the registration of additonal ArtefactHandlers
abstract  void doWithApplicationContext(ApplicationContext applicationContext)
          This method is called to allow the plugin to add BeanDefinitions to the BeanDefinitionRegistry.
abstract  void doWithRuntimeConfiguration(RuntimeSpringConfiguration springConfig)
          Executes the plugin code that performs runtime configuration as defined in the doWithSpring closure
 void doWithWebDescriptor(groovy.util.slurpersupport.GPathResult webXml)
          Handles processing of web.xml.
 String[] getDependencyNames()
           
 String getDependentVersion(String name)
          The version of the specified dependency
 String[] getEvictionNames()
           
 String[] getLoadAfterNames()
          Retrieves the names of plugins that this plugin should be loaded after.
 GrailsPluginManager getManager()
          Retrieves the plugin manager if known, otherwise returns null
 String getName()
           
 String getVersion()
           
 void refresh()
          Refreshes this Grails plugin reloading any watched resources as necessary
 void setApplication(GrailsApplication application)
           
 void setApplicationContext(ApplicationContext applicationContext)
           
 void setManager(GrailsPluginManager manager)
          Sets the plugin manager for this plugin
 
Methods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, getProperty, invokeMethod, setMetaClass, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.codehaus.groovy.grails.plugins.GrailsPlugin
doWithDynamicMethods, getInstance, getObservedPluginNames, getProvidedArtefacts, isEnabled, notifyOfEvent, notifyOfEvent
 

Field Detail

application

protected GrailsApplication application

version

protected String version

dependencies

protected Map dependencies

dependencyNames

protected String[] dependencyNames

pluginClass

protected Class pluginClass

applicationContext

protected ApplicationContext applicationContext

manager

protected GrailsPluginManager manager

evictionList

protected String[] evictionList
Constructor Detail

AbstractGrailsPlugin

public AbstractGrailsPlugin(Class pluginClass,
                            GrailsApplication application)
Method Detail

refresh

public void refresh()
Description copied from interface: GrailsPlugin
Refreshes this Grails plugin reloading any watched resources as necessary

Specified by:
refresh in interface GrailsPlugin

doWithApplicationContext

public abstract void doWithApplicationContext(ApplicationContext applicationContext)
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:
applicationContext - The Spring ApplicationContext instance

doWithRuntimeConfiguration

public abstract void doWithRuntimeConfiguration(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

doArtefactConfiguration

public abstract 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

checkForChanges

public boolean checkForChanges()
Description copied from interface: GrailsPlugin
When called this method checks for any changes to the plug-ins watched resources and reloads appropriately

Specified by:
checkForChanges in interface GrailsPlugin
Returns:
Returns true when the plug-in itself changes in some way, as oppose to plug-in resources

doWithWebDescriptor

public void doWithWebDescriptor(groovy.util.slurpersupport.GPathResult webXml)
Description copied from interface: GrailsPlugin
Handles processing of web.xml. The method is passed a GPathResult which is parsed by groovy.util.XmlSlurper. A plug-in can then manipulate the in-memory XML however it chooses Once all plug-ins have been processed the web.xml is then written to disk based on its in-memory form

Specified by:
doWithWebDescriptor in interface GrailsPlugin
Parameters:
webXml - The GPathResult representing web.xml

getDependencyNames

public String[] getDependencyNames()
Specified by:
getDependencyNames in interface GrailsPlugin
Returns:
The names of the plugins this plugin is dependant on

getDependentVersion

public String getDependentVersion(String name)
Description copied from interface: GrailsPlugin
The version of the specified dependency

Specified by:
getDependentVersion in interface GrailsPlugin
Parameters:
name - the name of the dependency
Returns:
The version

getName

public String getName()
Specified by:
getName in interface GrailsPlugin
Returns:
The name of the plug-in

getVersion

public String getVersion()
Specified by:
getVersion in interface GrailsPlugin
Returns:
The version of the plug-in

getManager

public GrailsPluginManager getManager()
Description copied from interface: GrailsPlugin
Retrieves the plugin manager if known, otherwise returns null

Specified by:
getManager in interface GrailsPlugin
Returns:
The PluginManager or null

getLoadAfterNames

public 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
Returns:
The names of the plugins that this plugin should be loaded after

setApplicationContext

public void setApplicationContext(ApplicationContext applicationContext)
                           throws BeansException
Specified by:
setApplicationContext in interface ApplicationContextAware
Throws:
BeansException

setManager

public void setManager(GrailsPluginManager manager)
Description copied from interface: GrailsPlugin
Sets the plugin manager for this plugin

Specified by:
setManager in interface GrailsPlugin
Parameters:
manager - A GrailsPluginManager instance

setApplication

public void setApplication(GrailsApplication application)
Specified by:
setApplication in interface GrailsPlugin

getEvictionNames

public String[] getEvictionNames()
Specified by:
getEvictionNames in interface GrailsPlugin
Returns:
The names of the plugins this plugin should evict onload


Copyright (c) 2005-2006 The Grails project