org.codehaus.groovy.grails.plugins
Class AbstractGrailsPluginManager

java.lang.Object
  extended by org.codehaus.groovy.grails.plugins.AbstractGrailsPluginManager
All Implemented Interfaces:
GrailsPluginManager, ApplicationContextAware, ServletContextAware
Direct Known Subclasses:
DefaultGrailsPluginManager

public abstract class AbstractGrailsPluginManager
extends Object
implements GrailsPluginManager

Abstract implementation of the GrailsPluginManager interface

Since:
0.4
Author:
Graeme Rocher

Field Summary
protected  GrailsApplication application
           
protected  ApplicationContext applicationContext
           
protected  Map<String,GrailsPlugin> classNameToPluginMap
           
protected  Map<String,GrailsPlugin> failedPlugins
           
protected  boolean initialised
           
protected  boolean loadCorePlugins
           
protected  Class[] pluginClasses
           
protected  List<GrailsPlugin> pluginList
           
protected  Resource[] pluginResources
           
protected  Map<String,GrailsPlugin> plugins
           
 
Fields inherited from interface org.codehaus.groovy.grails.plugins.GrailsPluginManager
BEAN_NAME
 
Constructor Summary
AbstractGrailsPluginManager(GrailsApplication application)
           
 
Method Summary
protected  void checkInitialised()
           
 void doArtefactConfiguration()
          Called prior to the initialisation of the GrailsApplication object to allow registration of additional ArtefactHandler objects
 void doDynamicMethods()
          This is called on all plugins so that they can add new methods/properties/constructors etc.
 void doPostProcessing(ApplicationContext applicationContext)
          Base implementation that will simply go through each plugin and call doWithApplicationContext on each
 void doRuntimeConfiguration(RuntimeSpringConfiguration springConfig)
          Base implementation that simply goes through the list of plugins and calls doWithRuntimeConfiguration on each
 void doRuntimeConfiguration(String pluginName, RuntimeSpringConfiguration springConfig)
          Base implementation that will perform runtime configuration for the specified plugin name
 GrailsPlugin[] getAllPlugins()
          Returns an array of all the loaded plug-ins
 GrailsPlugin[] getFailedLoadPlugins()
           
 GrailsPlugin getFailedPlugin(String name)
          Retrieves a plug-in that failed to load, or null if it doesn't exist
 GrailsPlugin getGrailsPlugin(String name)
          Retrieves a name Grails plugin instance
 GrailsPlugin getGrailsPlugin(String name, Object version)
          Retrieves a plug-in for its name and version
 GrailsPlugin getGrailsPluginForClassName(String name)
          Obtains a GrailsPlugin for the given classname
 String getPluginPath(String name)
          Returns the pluginContextPath for the given plugin
 String getPluginPathForClass(Class<? extends Object> theClass)
          Returns the plugin path for the given class
 String getPluginPathForInstance(Object instance)
          Returns the pluginContextPath for the given instance
 Resource[] getPluginResources()
           
 String getPluginViewsPathForClass(Class<? extends Object> theClass)
          Returns the plugin views directory path for the given class
 String getPluginViewsPathForInstance(Object instance)
          Returns the plugin views directory for the given instance
 List<TypeFilter> getTypeFilters()
          Get all of the TypeFilter definitions defined by the plugins
 boolean hasGrailsPlugin(String name)
           
 void informOfClassChange(Class aClass)
          Method for handling changes to a class and triggering on change events etc.
 boolean isInitialised()
           
 void registerProvidedArtefacts(GrailsApplication application)
          Registers pre-compiled artefacts with the GrailsApplication instance, only overriding if the application doesn't already provide an artefact of the same name
 void setApplication(GrailsApplication application)
          Sets the GrailsApplication used be this plugin manager
 void setApplicationContext(ApplicationContext applicationContext)
           
 void setLoadCorePlugins(boolean shouldLoadCorePlugins)
          Set whether the core plugins should be loaded
 void shutdown()
          Shuts down the PluginManager
 boolean supportsCurrentBuildScope(String pluginName)
          Returns true if the given plugin supports the current BuildScope
 
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.GrailsPluginManager
checkForChanges, doWebDescriptor, doWebDescriptor, getPluginObservers, getUserPlugins, informObservers, loadPlugins, refreshPlugin
 
Methods inherited from interface org.springframework.web.context.ServletContextAware
setServletContext
 

Field Detail

pluginList

protected List<GrailsPlugin> pluginList

application

protected GrailsApplication application

pluginResources

protected Resource[] pluginResources

plugins

protected Map<String,GrailsPlugin> plugins

classNameToPluginMap

protected Map<String,GrailsPlugin> classNameToPluginMap

pluginClasses

protected Class[] pluginClasses

initialised

protected boolean initialised

applicationContext

protected ApplicationContext applicationContext

failedPlugins

protected Map<String,GrailsPlugin> failedPlugins

loadCorePlugins

protected boolean loadCorePlugins
Constructor Detail

AbstractGrailsPluginManager

public AbstractGrailsPluginManager(GrailsApplication application)
Method Detail

getTypeFilters

public List<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(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,
                                   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(ApplicationContext applicationContext)
Base implementation that will simply go through each plugin and call doWithApplicationContext on each

Specified by:
doPostProcessing in interface GrailsPluginManager
Parameters:
applicationContext - The ApplicationContext instance

getPluginResources

public 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
This is called on all plugins so that they can add new methods/properties/constructors etc.

Specified by:
doDynamicMethods in interface GrailsPluginManager

setApplicationContext

public void setApplicationContext(ApplicationContext applicationContext)
                           throws BeansException
Specified by:
setApplicationContext in interface ApplicationContextAware
Throws:
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 application)
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:
application - 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:
ArtefactHandler

shutdown

public void shutdown()
Description copied from interface: GrailsPluginManager
Shuts down the PluginManager

Specified by:
shutdown in interface GrailsPluginManager

supportsCurrentBuildScope

public boolean supportsCurrentBuildScope(String pluginName)
Description copied from interface: GrailsPluginManager
Returns true if the given plugin supports the current BuildScope

Specified by:
supportsCurrentBuildScope in interface GrailsPluginManager
Parameters:
pluginName - The name of the plugin
Returns:
True if the plugin supports the current build scope
See Also:
BuildScope.getCurrent()

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

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

getPluginPathForClass

public String getPluginPathForClass(Class<? extends Object> 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<? extends Object> 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


Copyright (c) 2005-2009 The Grails project