play.plugins
Class PluginCollection

java.lang.Object
  extended by play.plugins.PluginCollection

public class PluginCollection
extends java.lang.Object

Class handling all plugins used by Play. Loading/reloading/enabling/disabling is handled here. This class also exposes many PlayPlugin-methods which when called, the method is executed on all enabled plugins. Since all the enabled-plugins-iteration is done here, the code elsewhere is cleaner.


Field Summary
protected  java.util.List<PlayPlugin> allPlugins
          List that holds all loaded plugins, enabled or disabled
protected  java.util.List<PlayPlugin> allPlugins_readOnlyCopy
          Readonly copy of allPlugins - updated each time allPlugins is updated.
protected  java.util.List<PlayPlugin> enabledPlugins
          List of all enabled plugins
protected  java.util.List<PlayPlugin> enabledPlugins_readOnlyCopy
          Readonly copy of enabledPlugins - updated each time enabledPlugins is updated.
protected  java.lang.Object lock
           
protected  java.lang.String play_plugins_resourceName
          Property holding the name of the play.plugins-resource-name.
 
Constructor Summary
PluginCollection()
           
 
Method Summary
protected  boolean addPlugin(PlayPlugin plugin)
          Adds one plugin and enables it
 java.util.List<java.lang.String> addTemplateExtensions()
           
 void afterActionInvocation()
           
 void afterApplicationStart()
           
 void afterFixtureLoad()
           
 void afterInvocation()
           
 void beforeActionInvocation(java.lang.reflect.Method actionMethod)
           
 void beforeDetectingChanges()
           
 void beforeInvocation()
           
 java.lang.Object bind(RootParamNode rootParamNode, java.lang.String name, java.lang.Class<?> clazz, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations)
           
 java.lang.Object bindBean(RootParamNode rootParamNode, java.lang.String name, java.lang.Object bean)
           
 void compileAll(java.util.List<ApplicationClasses.ApplicationClass> classes)
          Deprecated. 
 boolean compileSources()
           
protected  java.util.List<PlayPlugin> createReadonlyCopy(java.util.List<PlayPlugin> list)
          Using readonly list to crash if someone tries to modify the copy.
 void detectChange()
           
 boolean detectClassesChange()
           
 boolean disablePlugin(java.lang.Class<? extends PlayPlugin> pluginClazz)
          disable plugin of specified type
 boolean disablePlugin(PlayPlugin plugin)
          disable plugin
 boolean enablePlugin(java.lang.Class<? extends PlayPlugin> pluginClazz)
          enable plugin of specified type
 boolean enablePlugin(PlayPlugin plugin)
          Enable plugin.
 void enhance(ApplicationClasses.ApplicationClass applicationClass)
           
 java.util.List<PlayPlugin> getAllPlugins()
          Returns new readonly list of all plugins
 java.util.List<PlayPlugin> getEnabledPlugins()
          Returns new readonly list of all enabled plugins
 java.lang.String getMessage(java.lang.String locale, java.lang.Object key, java.lang.Object... args)
           
 PlayPlugin getPluginInstance(java.lang.Class<? extends PlayPlugin> pluginClazz)
          Returns the first instance of a loaded plugin of specified type
 java.util.Collection<PlayPlugin> getReversedEnabledPlugins()
          Returns readonly view of all enabled plugins in reversed order
protected  void initializePlugin(PlayPlugin plugin)
          Calls plugin.onLoad but detects if plugin removes other plugins from Play.plugins-list to detect if plugins disables a plugin the old hacked way..
 void invocationFinally()
           
 boolean isEnabled(PlayPlugin plugin)
           
protected  boolean isLoadedByApplicationClassloader(PlayPlugin plugin)
           
 void loadPlugins()
          Enable found plugins
 Template loadTemplate(VirtualFile file)
           
 Model.Factory modelFactory(java.lang.Class<? extends Model> modelClass)
           
 void onActionInvocationResult(Result result)
           
 void onApplicationReady()
           
 void onApplicationStart()
           
 void onApplicationStop()
           
 java.util.List<ApplicationClasses.ApplicationClass> onClassesChange(java.util.List<ApplicationClasses.ApplicationClass> modified)
          Deprecated. 
 void onConfigurationRead()
           
 void onEvent(java.lang.String message, java.lang.Object context)
           
 void onInvocationException(java.lang.Throwable e)
           
 void onInvocationSuccess()
           
 void onRequestRouting(Router.Route route)
           
 void onRoutesLoaded()
           
 java.lang.String overrideTemplateSource(BaseTemplate template, java.lang.String source)
           
 boolean rawInvocation(Http.Request request, Http.Response response)
           
 void reloadApplicationPlugins()
          Reloads all loaded plugins that is application-supplied.
protected  void replacePlugin(PlayPlugin oldPlugin, PlayPlugin newPlugin)
           
 void routeRequest(Http.Request request)
           
 TestEngine.TestResults runTest(java.lang.Class<BaseTest> clazz)
           
 boolean serveStatic(VirtualFile file, Http.Request request, Http.Response response)
           
 java.util.Map<java.lang.String,java.lang.Object> unBind(java.lang.Object src, java.lang.String name)
           
 void updatePlayPluginsList()
          Must update Play.plugins-list to be backward compatible
 java.lang.Object willBeValidated(java.lang.Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

play_plugins_resourceName

protected java.lang.String play_plugins_resourceName
Property holding the name of the play.plugins-resource-name. Can be modified in unittest to supply modifies plugin-list


lock

protected java.lang.Object lock

allPlugins

protected java.util.List<PlayPlugin> allPlugins
List that holds all loaded plugins, enabled or disabled


allPlugins_readOnlyCopy

protected java.util.List<PlayPlugin> allPlugins_readOnlyCopy
Readonly copy of allPlugins - updated each time allPlugins is updated. Using this cached copy so we don't have to create it all the time..


enabledPlugins

protected java.util.List<PlayPlugin> enabledPlugins
List of all enabled plugins


enabledPlugins_readOnlyCopy

protected java.util.List<PlayPlugin> enabledPlugins_readOnlyCopy
Readonly copy of enabledPlugins - updated each time enabledPlugins is updated. Using this cached copy so we don't have to create it all the time

Constructor Detail

PluginCollection

public PluginCollection()
Method Detail

createReadonlyCopy

protected java.util.List<PlayPlugin> createReadonlyCopy(java.util.List<PlayPlugin> list)
Using readonly list to crash if someone tries to modify the copy.

Parameters:
list -
Returns:

loadPlugins

public void loadPlugins()
Enable found plugins


reloadApplicationPlugins

public void reloadApplicationPlugins()
                              throws java.lang.Exception
Reloads all loaded plugins that is application-supplied.

Throws:
java.lang.Exception

isLoadedByApplicationClassloader

protected boolean isLoadedByApplicationClassloader(PlayPlugin plugin)

initializePlugin

protected void initializePlugin(PlayPlugin plugin)
Calls plugin.onLoad but detects if plugin removes other plugins from Play.plugins-list to detect if plugins disables a plugin the old hacked way..

Parameters:
plugin -

addPlugin

protected boolean addPlugin(PlayPlugin plugin)
Adds one plugin and enables it

Parameters:
plugin -
Returns:
true if plugin was new and was added

replacePlugin

protected void replacePlugin(PlayPlugin oldPlugin,
                             PlayPlugin newPlugin)

enablePlugin

public boolean enablePlugin(PlayPlugin plugin)
Enable plugin.

Parameters:
plugin -
Returns:
true if plugin exists and was enabled now

enablePlugin

public boolean enablePlugin(java.lang.Class<? extends PlayPlugin> pluginClazz)
enable plugin of specified type

Returns:
true if plugin was enabled

getPluginInstance

public PlayPlugin getPluginInstance(java.lang.Class<? extends PlayPlugin> pluginClazz)
Returns the first instance of a loaded plugin of specified type

Parameters:
pluginClazz -
Returns:

disablePlugin

public boolean disablePlugin(PlayPlugin plugin)
disable plugin

Parameters:
plugin -
Returns:
true if plugin was enabled and now is disabled

disablePlugin

public boolean disablePlugin(java.lang.Class<? extends PlayPlugin> pluginClazz)
disable plugin of specified type

Returns:
true if plugin was enabled and now is disabled

updatePlayPluginsList

public void updatePlayPluginsList()
Must update Play.plugins-list to be backward compatible


getEnabledPlugins

public java.util.List<PlayPlugin> getEnabledPlugins()
Returns new readonly list of all enabled plugins

Returns:

getReversedEnabledPlugins

public java.util.Collection<PlayPlugin> getReversedEnabledPlugins()
Returns readonly view of all enabled plugins in reversed order

Returns:

getAllPlugins

public java.util.List<PlayPlugin> getAllPlugins()
Returns new readonly list of all plugins

Returns:

isEnabled

public boolean isEnabled(PlayPlugin plugin)
Parameters:
plugin -
Returns:
true if plugin is enabled

compileSources

public boolean compileSources()

detectClassesChange

public boolean detectClassesChange()

invocationFinally

public void invocationFinally()

beforeInvocation

public void beforeInvocation()

afterInvocation

public void afterInvocation()

onInvocationSuccess

public void onInvocationSuccess()

onInvocationException

public void onInvocationException(java.lang.Throwable e)

beforeDetectingChanges

public void beforeDetectingChanges()

detectChange

public void detectChange()

onApplicationReady

public void onApplicationReady()

onConfigurationRead

public void onConfigurationRead()

onApplicationStart

public void onApplicationStart()

afterApplicationStart

public void afterApplicationStart()

onApplicationStop

public void onApplicationStop()

onEvent

public void onEvent(java.lang.String message,
                    java.lang.Object context)

enhance

public void enhance(ApplicationClasses.ApplicationClass applicationClass)

onClassesChange

@Deprecated
public java.util.List<ApplicationClasses.ApplicationClass> onClassesChange(java.util.List<ApplicationClasses.ApplicationClass> modified)
Deprecated. 


compileAll

@Deprecated
public void compileAll(java.util.List<ApplicationClasses.ApplicationClass> classes)
Deprecated. 


bind

public java.lang.Object bind(RootParamNode rootParamNode,
                             java.lang.String name,
                             java.lang.Class<?> clazz,
                             java.lang.reflect.Type type,
                             java.lang.annotation.Annotation[] annotations)

bindBean

public java.lang.Object bindBean(RootParamNode rootParamNode,
                                 java.lang.String name,
                                 java.lang.Object bean)

unBind

public java.util.Map<java.lang.String,java.lang.Object> unBind(java.lang.Object src,
                                                               java.lang.String name)

willBeValidated

public java.lang.Object willBeValidated(java.lang.Object value)

modelFactory

public Model.Factory modelFactory(java.lang.Class<? extends Model> modelClass)

getMessage

public java.lang.String getMessage(java.lang.String locale,
                                   java.lang.Object key,
                                   java.lang.Object... args)

beforeActionInvocation

public void beforeActionInvocation(java.lang.reflect.Method actionMethod)

onActionInvocationResult

public void onActionInvocationResult(Result result)

afterActionInvocation

public void afterActionInvocation()

routeRequest

public void routeRequest(Http.Request request)

onRequestRouting

public void onRequestRouting(Router.Route route)

onRoutesLoaded

public void onRoutesLoaded()

rawInvocation

public boolean rawInvocation(Http.Request request,
                             Http.Response response)
                      throws java.lang.Exception
Throws:
java.lang.Exception

serveStatic

public boolean serveStatic(VirtualFile file,
                           Http.Request request,
                           Http.Response response)

addTemplateExtensions

public java.util.List<java.lang.String> addTemplateExtensions()

overrideTemplateSource

public java.lang.String overrideTemplateSource(BaseTemplate template,
                                               java.lang.String source)

loadTemplate

public Template loadTemplate(VirtualFile file)

afterFixtureLoad

public void afterFixtureLoad()

runTest

public TestEngine.TestResults runTest(java.lang.Class<BaseTest> clazz)


Guillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly