Groovy Documentation

org.codehaus.groovy.grails.plugins
[Java] Interface GrailsPluginManager

org.codehaus.groovy.grails.plugins.GrailsPluginManager
  org.springframework.beans.factory.Aware
All Superinterfaces:
org.springframework.beans.factory.Aware

public interface GrailsPluginManager
extends org.springframework.context.ApplicationContextAware, org.springframework.web.context.ServletContextAware

Handles the loading and management of plug-ins in the Grails system. A plugin a 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 (

Authors:
Graeme Rocher
See Also:
BeanBuilder
Since:
0.4


Field Summary
java.lang.String BEAN_NAME

 
Method Summary
void checkForChanges()

Checks all the plugins to see whether they have any changes

void doArtefactConfiguration()

Called prior to the initialisation of the GrailsApplication object to allow registration of additional ArtefactHandler objects

void doDynamicMethods()

Called on all plugins so that they can add new methods/properties/constructors etc.

void doPostProcessing(org.springframework.context.ApplicationContext applicationContext)

Performs post initialization configuration for each plug-in, passing the built application context

void doRuntimeConfiguration(RuntimeSpringConfiguration springConfig)

Executes the runtime configuration phase of plug-ins

void doRuntimeConfiguration(java.lang.String pluginName, RuntimeSpringConfiguration springConfig)

Executes the runtime configuration for a specific plugin AND all its dependencies

void doWebDescriptor(org.springframework.core.io.Resource descriptor, java.io.Writer target)

Takes the specified web descriptor reference and configures it with all the plugins outputting the result to the target Writer instance

void doWebDescriptor(java.io.File descriptor, java.io.Writer target)

@see #doWebDescriptor(Resource, Writer)

GrailsPlugin[] getAllPlugins()

Returns an array of all the loaded plug-ins

GrailsPlugin[] getFailedLoadPlugins()

@return An array of plugins that failed to load due to dependency resolution errors

GrailsPlugin getFailedPlugin(java.lang.String name)

Retrieves a plug-in that failed to load, or null if it doesn't exist

GrailsPlugin getGrailsPlugin(java.lang.String name)

Retrieves a name Grails plugin instance

GrailsPlugin getGrailsPlugin(java.lang.String name, java.lang.Object version)

Retrieves a plug-in for its name and version

GrailsPlugin getGrailsPluginForClassName(java.lang.String name)

Obtains a GrailsPlugin for the given classname

GrailsPlugin getPluginForClass(java.lang.Class theClass)

Obtains the GrailsPlugin for the given class

GrailsPlugin getPluginForInstance(java.lang.Object instance)

Looks up the plugin that defined the given instance.

java.util.Collection getPluginObservers(GrailsPlugin plugin)

Retrieves a collection of plugins that are observing the specified plugin

java.lang.String getPluginPath(java.lang.String name)

Returns the pluginContextPath for the given plugin

java.lang.String getPluginPathForClass(java.lang.Class theClass)

Returns the plugin path for the given class

java.lang.String getPluginPathForInstance(java.lang.Object instance)

Returns the pluginContextPath for the given instance

java.lang.String getPluginViewsPathForClass(java.lang.Class theClass)

Returns the plugin views directory path for the given class

java.lang.String getPluginViewsPathForInstance(java.lang.Object instance)

Returns the plugin views directory for the given instance

java.util.List getTypeFilters()

Get all of the TypeFilter definitions defined by the plugins

GrailsPlugin[] getUserPlugins()

Gets plugin installed by the user and not provided by the framework

boolean hasGrailsPlugin(java.lang.String name)

@param name The name of the plugin

void informObservers(java.lang.String pluginName, java.util.Map event)

inform the specified plugins observers of the event specified by the passed Map instance

void informOfClassChange(java.lang.Class aClass)

Method for handling changes to a class and triggering on change events etc.

void informOfClassChange(java.io.File file, java.lang.Class cls)

void informOfFileChange(java.io.File file)

Fire to inform the PluginManager that a particular file changes

boolean isInitialised()

@return the initialised

void loadPlugins()

Performs the initial load of plug-ins throwing an exception if any dependencies don't resolve

void refreshPlugin(java.lang.String name)

Refreshes the specified plugin.

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 setLoadCorePlugins(boolean shouldLoadCorePlugins)

Set whether the core plugins should be loaded

void shutdown()

Shuts down the PluginManager

boolean supportsCurrentBuildScope(java.lang.String pluginName)

Returns true if the given plugin supports the current BuildScope

 
Methods inherited from interface org.springframework.web.context.ServletContextAware
org.springframework.web.context.ServletContextAware#setServletContext(javax.servlet.ServletContext)
 
Methods inherited from interface org.springframework.context.ApplicationContextAware
org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
 

Field Detail

BEAN_NAME

public java.lang.String BEAN_NAME


 
Method Detail

checkForChanges

public void checkForChanges()
Checks all the plugins to see whether they have any changes


doArtefactConfiguration

public void doArtefactConfiguration()
Called prior to the initialisation of the GrailsApplication object to allow registration of additional ArtefactHandler objects
See Also:
ArtefactHandler


doDynamicMethods

public void doDynamicMethods()
Called on all plugins so that they can add new methods/properties/constructors etc.


doPostProcessing

public void doPostProcessing(org.springframework.context.ApplicationContext applicationContext)
Performs post initialization configuration for each plug-in, passing the built application context
Parameters:
applicationContext - The ApplicationContext instance


doRuntimeConfiguration

public void doRuntimeConfiguration(RuntimeSpringConfiguration springConfig)
Executes the runtime configuration phase of plug-ins
Parameters:
springConfig - The RuntimeSpringConfiguration instance


doRuntimeConfiguration

public void doRuntimeConfiguration(java.lang.String pluginName, RuntimeSpringConfiguration springConfig)
Executes the runtime configuration for a specific plugin AND all its dependencies
Parameters:
pluginName - The name of he plugin
springConfig - The runtime spring config instance


doWebDescriptor

public void doWebDescriptor(org.springframework.core.io.Resource descriptor, java.io.Writer target)
Takes the specified web descriptor reference and configures it with all the plugins outputting the result to the target Writer instance
Parameters:
descriptor - The Resource of the descriptor
target - The Writer to write the result to


doWebDescriptor

public void doWebDescriptor(java.io.File descriptor, java.io.Writer target)
Parameters:
descriptor - The File of the descriptor
target - The target to write the changes to
See Also:
doWebDescriptor(Resource, Writer)


getAllPlugins

public GrailsPlugin[] getAllPlugins()
Returns an array of all the loaded plug-ins
Returns:
An array of plug-ins


getFailedLoadPlugins

public GrailsPlugin[] getFailedLoadPlugins()
Returns:
An array of plugins that failed to load due to dependency resolution errors


getFailedPlugin

public GrailsPlugin getFailedPlugin(java.lang.String name)
Retrieves a plug-in that failed to load, or null if it doesn't exist
Parameters:
name - The name of the plugin
Returns:
A GrailsPlugin or null


getGrailsPlugin

public GrailsPlugin getGrailsPlugin(java.lang.String name)
Retrieves a name Grails plugin instance
Parameters:
name - The name of the plugin
Returns:
The GrailsPlugin instance or null if it doesn't exist


getGrailsPlugin

public GrailsPlugin getGrailsPlugin(java.lang.String name, java.lang.Object version)
Retrieves a plug-in for its name and version
Parameters:
name - The name of the plugin
version - The version of the plugin
Returns:
The GrailsPlugin instance or null if it doesn't exist


getGrailsPluginForClassName

public GrailsPlugin getGrailsPluginForClassName(java.lang.String name)
Obtains a GrailsPlugin for the given classname
Parameters:
name - The name of the plugin
Returns:
The instance


getPluginForClass

public GrailsPlugin getPluginForClass(java.lang.Class theClass)
Obtains the GrailsPlugin for the given class
Parameters:
theClass - The class
Returns:
The GrailsPlugin for the given class or null if not related to any plugin


getPluginForInstance

public GrailsPlugin getPluginForInstance(java.lang.Object instance)
Looks up the plugin that defined the given instance. If no plugin defined the instance then null is returned.
Parameters:
instance - The instance
Returns:
The plugin that defined the instance or null


getPluginObservers

@SuppressWarnings("rawtypes")
public java.util.Collection getPluginObservers(GrailsPlugin plugin)
Retrieves a collection of plugins that are observing the specified plugin
Parameters:
plugin - The plugin to retrieve observers for
Returns:
A collection of observers


getPluginPath

public java.lang.String getPluginPath(java.lang.String name)
Returns the pluginContextPath for the given plugin
Parameters:
name - The plugin name
Returns:
the context path


getPluginPathForClass

public java.lang.String getPluginPathForClass(java.lang.Class theClass)
Returns the plugin path for the given class
Parameters:
theClass - The class
Returns:
The pluginContextPath


getPluginPathForInstance

public java.lang.String getPluginPathForInstance(java.lang.Object instance)
Returns the pluginContextPath for the given instance
Parameters:
instance - The instance
Returns:
The pluginContextPath


getPluginViewsPathForClass

public java.lang.String getPluginViewsPathForClass(java.lang.Class theClass)
Returns the plugin views directory path for the given class
Parameters:
theClass - The class
Returns:
The pluginContextPath


getPluginViewsPathForInstance

public java.lang.String getPluginViewsPathForInstance(java.lang.Object instance)
Returns the plugin views directory for the given instance
Parameters:
instance - The instance
Returns:
The pluginContextPath


getTypeFilters

public java.util.List getTypeFilters()
Get all of the TypeFilter definitions defined by the plugins
Returns:
A list of TypeFilter definitions


getUserPlugins

public GrailsPlugin[] getUserPlugins()
Gets plugin installed by the user and not provided by the framework
Returns:
A list of user plugins


hasGrailsPlugin

public boolean hasGrailsPlugin(java.lang.String name)
Parameters:
name - The name of the plugin
Returns:
True if the the manager has a loaded plugin with the given name


informObservers

@SuppressWarnings("rawtypes")
public void informObservers(java.lang.String pluginName, java.util.Map event)
inform the specified plugins observers of the event specified by the passed Map instance
Parameters:
pluginName - The name of the plugin
event - The event


informOfClassChange

public void informOfClassChange(java.lang.Class aClass)
Method for handling changes to a class and triggering on change events etc.
Parameters:
aClass - The class


informOfClassChange

public void informOfClassChange(java.io.File file, @SuppressWarnings("rawtypes") java.lang.Class cls)


informOfFileChange

public void informOfFileChange(java.io.File file)
Fire to inform the PluginManager that a particular file changes
Parameters:
file - The file that changed
Since:
2.0


isInitialised

public boolean isInitialised()
Returns:
the initialised


loadPlugins

public void loadPlugins()
Performs the initial load of plug-ins throwing an exception if any dependencies don't resolve
throws:
PluginException Thrown when an error occurs loading the plugins


refreshPlugin

public void refreshPlugin(java.lang.String name)
Refreshes the specified plugin. A refresh will force to plugin to "touch" each of its watched resources and fire modified events for each
Parameters:
name - The name of the plugin to refresh


registerProvidedArtefacts

public 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.
Parameters:
application - The GrailsApplication object


setApplication

public void setApplication(GrailsApplication application)
Sets the GrailsApplication used be this plugin manager
Parameters:
application - The GrailsApplication instance


setLoadCorePlugins

public void setLoadCorePlugins(boolean shouldLoadCorePlugins)
Set whether the core plugins should be loaded
Parameters:
shouldLoadCorePlugins - True if they should


shutdown

public void shutdown()
Shuts down the PluginManager


supportsCurrentBuildScope

public boolean supportsCurrentBuildScope(java.lang.String pluginName)
Returns true if the given plugin supports the current BuildScope
Parameters:
pluginName - The name of the plugin
Returns:
True if the plugin supports the current build scope
See Also:
BuildScope.getCurrent


 

Groovy Documentation