Package org.grails.plugins
Class AbstractGrailsPluginManager
- java.lang.Object
-
- org.grails.plugins.AbstractGrailsPluginManager
-
- All Implemented Interfaces:
GrailsPluginManager,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
DefaultGrailsPluginManager,MockGrailsPluginManager
public abstract class AbstractGrailsPluginManager extends java.lang.Object implements GrailsPluginManager
Abstract implementation of the GrailsPluginManager interface- Since:
- 0.4
-
-
Field Summary
Fields Modifier and Type Field Description protected GrailsApplicationapplicationprotected org.springframework.context.ApplicationContextapplicationContextprotected java.util.Map<java.lang.String,GrailsPlugin>classNameToPluginMapstatic java.lang.StringCONFIG_FILEprotected java.util.Map<java.lang.String,GrailsPlugin>failedPluginsprotected booleaninitialisedprotected booleanloadCorePluginsprotected java.lang.Class<?>[]pluginClassesprotected java.util.List<GrailsPlugin>pluginListprotected org.springframework.core.io.Resource[]pluginResourcesprotected java.util.Map<java.lang.String,GrailsPlugin>pluginsprotected booleanshutdown-
Fields inherited from interface grails.plugins.GrailsPluginManager
BEAN_NAME
-
-
Constructor Summary
Constructors Constructor Description AbstractGrailsPluginManager(GrailsApplication application)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckInitialised()voiddoArtefactConfiguration()Called prior to the initialisation of the GrailsApplication object to allow registration of additional ArtefactHandler objectsvoiddoDynamicMethods()Called on all plugins so that they can add new methods/properties/constructors etc.voiddoPostProcessing(org.springframework.context.ApplicationContext ctx)Base implementation that will simply go through each plugin and call doWithApplicationContext on each.voiddoRuntimeConfiguration(java.lang.String pluginName, org.grails.spring.RuntimeSpringConfiguration springConfig)Base implementation that will perform runtime configuration for the specified plugin name.voiddoRuntimeConfiguration(org.grails.spring.RuntimeSpringConfiguration springConfig)Base implementation that simply goes through the list of plugins and calls doWithRuntimeConfiguration on eachGrailsPlugin[]getAllPlugins()Returns an array of all the loaded plug-insGrailsPlugin[]getFailedLoadPlugins()GrailsPlugingetFailedPlugin(java.lang.String name)Retrieves a plug-in that failed to load, or null if it doesn't existGrailsPlugingetGrailsPlugin(java.lang.String name)Retrieves a name Grails plugin instanceGrailsPlugingetGrailsPlugin(java.lang.String name, java.lang.Object version)Retrieves a plug-in for its name and versionGrailsPlugingetGrailsPluginForClassName(java.lang.String name)Obtains a GrailsPlugin for the given classnameGrailsPlugingetPluginForClass(java.lang.Class<?> theClass)Obtains the GrailsPlugin for the given classGrailsPlugingetPluginForInstance(java.lang.Object instance)Looks up the plugin that defined the given instance.java.lang.StringgetPluginPath(java.lang.String name)Returns the pluginContextPath for the given pluginjava.lang.StringgetPluginPath(java.lang.String name, boolean forceCamelCase)Returns the pluginContextPath for the given plugin and will force name to camel case instead of '-' lower case my-plug-web would resolve to myPlugWeb if forceCamelCase is true.java.lang.StringgetPluginPathForClass(java.lang.Class<?> theClass)Returns the plugin path for the given classjava.lang.StringgetPluginPathForInstance(java.lang.Object instance)Returns the pluginContextPath for the given instanceorg.springframework.core.io.Resource[]getPluginResources()java.lang.StringgetPluginViewsPathForClass(java.lang.Class<?> theClass)Returns the plugin views directory path for the given classjava.lang.StringgetPluginViewsPathForInstance(java.lang.Object instance)Returns the plugin views directory for the given instancejava.util.List<org.springframework.core.type.filter.TypeFilter>getTypeFilters()Get all of the TypeFilter definitions defined by the pluginsbooleanhasGrailsPlugin(java.lang.String name)voidinformOfClassChange(java.io.File file, java.lang.Class cls)voidinformOfClassChange(java.lang.Class<?> aClass)Method for handling changes to a class and triggering on change events etc.voidinformOfFileChange(java.io.File file)Fire to inform the PluginManager that a particular file changesvoidinformPluginsOfConfigChange()Inform of a change in configurationbooleanisInitialised()protected booleanisPluginDisabledForProfile(GrailsPlugin plugin)booleanisShutdown()Indicates whether the manager has been shutdown or notvoidonStartup(java.util.Map<java.lang.String,java.lang.Object> event)Executes thePlugin.onStartup(Map)hook for all pluginsvoidregisterProvidedArtefacts(GrailsApplication app)Registers pre-compiled artefacts with the GrailsApplication instance, only overriding if the application doesn't already provide an artefact of the same name.voidsetApplication(GrailsApplication application)Sets the GrailsApplication used be this plugin managervoidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)voidsetLoadCorePlugins(boolean shouldLoadCorePlugins)Set whether the core plugins should be loadedvoidsetPluginFilter(PluginFilter pluginFilter)Sets the filter to use to filter for pluginsvoidshutdown()Shuts down the PluginManager-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface grails.plugins.GrailsPluginManager
checkForChanges, getPluginObservers, getUserPlugins, informObservers, loadPlugins, refreshPlugin
-
-
-
-
Field Detail
-
CONFIG_FILE
public static final java.lang.String CONFIG_FILE
- See Also:
- Constant Field Values
-
pluginList
protected java.util.List<GrailsPlugin> pluginList
-
application
protected GrailsApplication application
-
pluginResources
protected org.springframework.core.io.Resource[] pluginResources
-
plugins
protected java.util.Map<java.lang.String,GrailsPlugin> plugins
-
classNameToPluginMap
protected java.util.Map<java.lang.String,GrailsPlugin> classNameToPluginMap
-
pluginClasses
protected java.lang.Class<?>[] pluginClasses
-
initialised
protected boolean initialised
-
shutdown
protected boolean shutdown
-
applicationContext
protected org.springframework.context.ApplicationContext applicationContext
-
failedPlugins
protected java.util.Map<java.lang.String,GrailsPlugin> failedPlugins
-
loadCorePlugins
protected boolean loadCorePlugins
-
-
Constructor Detail
-
AbstractGrailsPluginManager
public AbstractGrailsPluginManager(GrailsApplication application)
-
-
Method Detail
-
getTypeFilters
public java.util.List<org.springframework.core.type.filter.TypeFilter> getTypeFilters()
Description copied from interface:GrailsPluginManagerGet all of the TypeFilter definitions defined by the plugins- Specified by:
getTypeFiltersin interfaceGrailsPluginManager- Returns:
- A list of TypeFilter definitions
-
getAllPlugins
public GrailsPlugin[] getAllPlugins()
Description copied from interface:GrailsPluginManagerReturns an array of all the loaded plug-ins- Specified by:
getAllPluginsin interfaceGrailsPluginManager- Returns:
- An array of plug-ins
-
getFailedLoadPlugins
public GrailsPlugin[] getFailedLoadPlugins()
- Specified by:
getFailedLoadPluginsin interfaceGrailsPluginManager- Returns:
- An array of plugins that failed to load due to dependency resolution errors
-
isInitialised
public boolean isInitialised()
- Specified by:
isInitialisedin interfaceGrailsPluginManager- Returns:
- the initialised
-
checkInitialised
protected void checkInitialised()
-
getFailedPlugin
public GrailsPlugin getFailedPlugin(java.lang.String name)
Description copied from interface:GrailsPluginManagerRetrieves a plug-in that failed to load, or null if it doesn't exist- Specified by:
getFailedPluginin interfaceGrailsPluginManager- Parameters:
name- The name of the plugin- Returns:
- A GrailsPlugin or null
-
doRuntimeConfiguration
public void doRuntimeConfiguration(org.grails.spring.RuntimeSpringConfiguration springConfig)
Base implementation that simply goes through the list of plugins and calls doWithRuntimeConfiguration on each- Specified by:
doRuntimeConfigurationin interfaceGrailsPluginManager- Parameters:
springConfig- The RuntimeSpringConfiguration instance
-
doRuntimeConfiguration
public void doRuntimeConfiguration(java.lang.String pluginName, org.grails.spring.RuntimeSpringConfiguration springConfig)Base implementation that will perform runtime configuration for the specified plugin name.- Specified by:
doRuntimeConfigurationin interfaceGrailsPluginManager- Parameters:
pluginName- The name of he pluginspringConfig- The runtime spring config instance
-
doPostProcessing
public void doPostProcessing(org.springframework.context.ApplicationContext ctx)
Base implementation that will simply go through each plugin and call doWithApplicationContext on each.- Specified by:
doPostProcessingin interfaceGrailsPluginManager- Parameters:
ctx- The ApplicationContext instance
-
getPluginResources
public org.springframework.core.io.Resource[] getPluginResources()
-
getGrailsPlugin
public GrailsPlugin getGrailsPlugin(java.lang.String name)
Description copied from interface:GrailsPluginManagerRetrieves a name Grails plugin instance- Specified by:
getGrailsPluginin interfaceGrailsPluginManager- Parameters:
name- The name of the plugin- Returns:
- The GrailsPlugin instance or null if it doesn't exist
-
getGrailsPluginForClassName
public GrailsPlugin getGrailsPluginForClassName(java.lang.String name)
Description copied from interface:GrailsPluginManagerObtains a GrailsPlugin for the given classname- Specified by:
getGrailsPluginForClassNamein interfaceGrailsPluginManager- Parameters:
name- The name of the plugin- Returns:
- The instance
-
getGrailsPlugin
public GrailsPlugin getGrailsPlugin(java.lang.String name, java.lang.Object version)
Description copied from interface:GrailsPluginManagerRetrieves a plug-in for its name and version- Specified by:
getGrailsPluginin interfaceGrailsPluginManager- Parameters:
name- The name of the pluginversion- The version of the plugin- Returns:
- The GrailsPlugin instance or null if it doesn't exist
-
hasGrailsPlugin
public boolean hasGrailsPlugin(java.lang.String name)
- Specified by:
hasGrailsPluginin interfaceGrailsPluginManager- 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:GrailsPluginManagerCalled on all plugins so that they can add new methods/properties/constructors etc.- Specified by:
doDynamicMethodsin interfaceGrailsPluginManager
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
setApplication
public void setApplication(GrailsApplication application)
Description copied from interface:GrailsPluginManagerSets the GrailsApplication used be this plugin manager- Specified by:
setApplicationin interfaceGrailsPluginManager- Parameters:
application- The GrailsApplication instance
-
registerProvidedArtefacts
public void registerProvidedArtefacts(GrailsApplication app)
Description copied from interface:GrailsPluginManagerRegisters pre-compiled artefacts with the GrailsApplication instance, only overriding if the application doesn't already provide an artefact of the same name.- Specified by:
registerProvidedArtefactsin interfaceGrailsPluginManager- Parameters:
app- The GrailsApplication object
-
doArtefactConfiguration
public void doArtefactConfiguration()
Description copied from interface:GrailsPluginManagerCalled prior to the initialisation of the GrailsApplication object to allow registration of additional ArtefactHandler objects- Specified by:
doArtefactConfigurationin interfaceGrailsPluginManager- See Also:
ArtefactHandler
-
isPluginDisabledForProfile
protected boolean isPluginDisabledForProfile(GrailsPlugin plugin)
-
onStartup
public void onStartup(java.util.Map<java.lang.String,java.lang.Object> event)
Description copied from interface:GrailsPluginManagerExecutes thePlugin.onStartup(Map)hook for all plugins- Specified by:
onStartupin interfaceGrailsPluginManager- Parameters:
event- the Event
-
shutdown
public void shutdown()
Description copied from interface:GrailsPluginManagerShuts down the PluginManager- Specified by:
shutdownin interfaceGrailsPluginManager
-
isShutdown
public boolean isShutdown()
Description copied from interface:GrailsPluginManagerIndicates whether the manager has been shutdown or not- Specified by:
isShutdownin interfaceGrailsPluginManager- Returns:
- True if it was shutdown
-
setPluginFilter
public void setPluginFilter(PluginFilter pluginFilter)
Description copied from interface:GrailsPluginManagerSets the filter to use to filter for plugins- Specified by:
setPluginFilterin interfaceGrailsPluginManager- Parameters:
pluginFilter- The plugin filter
-
setLoadCorePlugins
public void setLoadCorePlugins(boolean shouldLoadCorePlugins)
Description copied from interface:GrailsPluginManagerSet whether the core plugins should be loaded- Specified by:
setLoadCorePluginsin interfaceGrailsPluginManager- Parameters:
shouldLoadCorePlugins- True if they should
-
informOfClassChange
public void informOfClassChange(java.lang.Class<?> aClass)
Description copied from interface:GrailsPluginManagerMethod for handling changes to a class and triggering on change events etc.- Specified by:
informOfClassChangein interfaceGrailsPluginManager- Parameters:
aClass- The class
-
getPluginPath
public java.lang.String getPluginPath(java.lang.String name)
Description copied from interface:GrailsPluginManagerReturns the pluginContextPath for the given plugin- Specified by:
getPluginPathin interfaceGrailsPluginManager- Parameters:
name- The plugin name- Returns:
- the context path
-
getPluginPath
public java.lang.String getPluginPath(java.lang.String name, boolean forceCamelCase)Description copied from interface:GrailsPluginManagerReturns the pluginContextPath for the given plugin and will force name to camel case instead of '-' lower case my-plug-web would resolve to myPlugWeb if forceCamelCase is true.- Specified by:
getPluginPathin interfaceGrailsPluginManager- Parameters:
name- The plugin nameforceCamelCase- Force camel case for name- Returns:
- the context path
-
getPluginPathForInstance
public java.lang.String getPluginPathForInstance(java.lang.Object instance)
Description copied from interface:GrailsPluginManagerReturns the pluginContextPath for the given instance- Specified by:
getPluginPathForInstancein interfaceGrailsPluginManager- Parameters:
instance- The instance- Returns:
- The pluginContextPath
-
getPluginForInstance
public GrailsPlugin getPluginForInstance(java.lang.Object instance)
Description copied from interface:GrailsPluginManagerLooks up the plugin that defined the given instance. If no plugin defined the instance then null is returned.- Specified by:
getPluginForInstancein interfaceGrailsPluginManager- Parameters:
instance- The instance- Returns:
- The plugin that defined the instance or null
-
getPluginForClass
public GrailsPlugin getPluginForClass(java.lang.Class<?> theClass)
Description copied from interface:GrailsPluginManagerObtains the GrailsPlugin for the given class- Specified by:
getPluginForClassin interfaceGrailsPluginManager- Parameters:
theClass- The class- Returns:
- The GrailsPlugin for the given class or null if not related to any plugin
-
informPluginsOfConfigChange
public void informPluginsOfConfigChange()
Description copied from interface:GrailsPluginManagerInform of a change in configuration- Specified by:
informPluginsOfConfigChangein interfaceGrailsPluginManager
-
informOfFileChange
public void informOfFileChange(java.io.File file)
Description copied from interface:GrailsPluginManagerFire to inform the PluginManager that a particular file changes- Specified by:
informOfFileChangein interfaceGrailsPluginManager- Parameters:
file- The file that changed
-
informOfClassChange
public void informOfClassChange(java.io.File file, java.lang.Class cls)- Specified by:
informOfClassChangein interfaceGrailsPluginManager
-
getPluginPathForClass
public java.lang.String getPluginPathForClass(java.lang.Class<?> theClass)
Description copied from interface:GrailsPluginManagerReturns the plugin path for the given class- Specified by:
getPluginPathForClassin interfaceGrailsPluginManager- Parameters:
theClass- The class- Returns:
- The pluginContextPath
-
getPluginViewsPathForInstance
public java.lang.String getPluginViewsPathForInstance(java.lang.Object instance)
Description copied from interface:GrailsPluginManagerReturns the plugin views directory for the given instance- Specified by:
getPluginViewsPathForInstancein interfaceGrailsPluginManager- Parameters:
instance- The instance- Returns:
- The pluginContextPath
-
getPluginViewsPathForClass
public java.lang.String getPluginViewsPathForClass(java.lang.Class<?> theClass)
Description copied from interface:GrailsPluginManagerReturns the plugin views directory path for the given class- Specified by:
getPluginViewsPathForClassin interfaceGrailsPluginManager- Parameters:
theClass- The class- Returns:
- The pluginContextPath
-
-