|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface GrailsPluginManager
A class that 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 (@see grails.spring.BeanBuilder) to provide runtime configuration of Grails via Spring
The doWithContext closure is called after the Spring ApplicationContext is built and accepts a single argument (the ApplicationContext)
The doWithWebDescriptor uses mark-up building to provide additional functionality to the web.xml file
Example:
class ClassEditorGrailsPlugin { def version = 1.1 def doWithSpring = { application -> classEditor(org.springframework.beans.propertyeditors.ClassEditor, application.classLoader) } }
A plugin can also define "dependsOn" and "evict" properties that specify what plugins the plugin depends on and which ones it is incompatable with and should evict
Field Summary | |
---|---|
static 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()
This is called on all plugins so that they can add new methods/properties/constructors etc. |
void |
doPostProcessing(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(String pluginName,
RuntimeSpringConfiguration springConfig)
Executes the runtime configuration for a specific plugin AND all its dependencies |
void |
doWebDescriptor(File descriptor,
Writer target)
|
void |
doWebDescriptor(Resource descriptor,
Writer target)
Takes the specified web descriptor reference and configures it with all the plugins outputting the result to the target Writer instance |
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 |
Collection |
getPluginObservers(GrailsPlugin plugin)
Retrieves a collection of plugins that are observing the specified plugin |
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 |
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 |
GrailsPlugin[] |
getUserPlugins()
Gets plugin installed by the user and not provided by the framework |
boolean |
hasGrailsPlugin(String name)
|
void |
informObservers(String pluginName,
Map event)
inform the specified plugins observers of the event specified by the passed Map instance |
void |
informOfClassChange(Class aClass)
Method for handling changes to a class and triggering on change events etc. |
boolean |
isInitialised()
|
void |
loadPlugins()
Performs the initial load of plug-ins throwing an exception if any dependencies don't resolve |
void |
refreshPlugin(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(String pluginName)
Returns true if the given plugin supports the current BuildScope |
Methods inherited from interface org.springframework.context.ApplicationContextAware |
---|
setApplicationContext |
Methods inherited from interface org.springframework.web.context.ServletContextAware |
---|
setServletContext |
Field Detail |
---|
static final String BEAN_NAME
Method Detail |
---|
GrailsPlugin[] getAllPlugins()
GrailsPlugin[] getUserPlugins()
GrailsPlugin[] getFailedLoadPlugins()
void loadPlugins() throws PluginException
PluginException
- Thrown when an error occurs loading the pluginsvoid doRuntimeConfiguration(RuntimeSpringConfiguration springConfig)
springConfig
- The RuntimeSpringConfiguration instancevoid doPostProcessing(ApplicationContext applicationContext)
applicationContext
- The ApplicationContext instancevoid doWebDescriptor(Resource descriptor, Writer target)
descriptor
- The Resource of the descriptortarget
- The Writer to write the result tovoid doWebDescriptor(File descriptor, Writer target)
descriptor
- The File of the descriptortarget
- The target to write the changes todoWebDescriptor(Resource, Writer)
void doDynamicMethods()
GrailsPlugin getGrailsPlugin(String name)
name
- The name of the plugin
GrailsPlugin getGrailsPluginForClassName(String name)
name
- The name of the plugin
boolean hasGrailsPlugin(String name)
name
- The name of the plugin
GrailsPlugin getFailedPlugin(String name)
name
- The name of the plugin
GrailsPlugin getGrailsPlugin(String name, Object version)
name
- The name of the pluginversion
- The version of the plugin
void doRuntimeConfiguration(String pluginName, RuntimeSpringConfiguration springConfig)
pluginName
- The name of he pluginspringConfig
- The runtime spring config instancevoid checkForChanges()
void setApplication(GrailsApplication application)
application
- The GrailsApplication instanceboolean isInitialised()
void refreshPlugin(String name)
name
- The name of the plugin to refreshCollection getPluginObservers(GrailsPlugin plugin)
plugin
- The plugin to retrieve observers for
void informObservers(String pluginName, Map event)
pluginName
- The name of the pluginevent
- The eventvoid doArtefactConfiguration()
ArtefactHandler
void registerProvidedArtefacts(GrailsApplication application)
application
- The GrailsApplication objectvoid shutdown()
boolean supportsCurrentBuildScope(String pluginName)
pluginName
- The name of the plugin
BuildScope.getCurrent()
void setLoadCorePlugins(boolean shouldLoadCorePlugins)
shouldLoadCorePlugins
- True if they shouldvoid informOfClassChange(Class aClass)
aClass
- The classList<TypeFilter> getTypeFilters()
String getPluginPath(String name)
name
- The plugin name
String getPluginPathForInstance(Object instance)
instance
- The instance
String getPluginPathForClass(Class<? extends Object> theClass)
theClass
- The class
String getPluginViewsPathForInstance(Object instance)
instance
- The instance
String getPluginViewsPathForClass(Class<? extends Object> theClass)
theClass
- The class
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |