Package play
Class PlayPlugin
- java.lang.Object
-
- play.PlayPlugin
-
- All Implemented Interfaces:
java.lang.Comparable<PlayPlugin>
- Direct Known Subclasses:
ConfigurablePluginDisablingPlugin
,ConfigurationChangeWatcherPlugin
,DBBrowserPlugin
,DBPlugin
,EnhancerPlugin
,Evolutions
,JobsPlugin
,JPAPlugin
,MessagesPlugin
,PlayStatusPlugin
,TempFilePlugin
,ValidationPlugin
,WS
public abstract class PlayPlugin extends java.lang.Object implements java.lang.Comparable<PlayPlugin>
A framework plugin
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PlayPlugin.Filter<T>
Class that define a filter.
-
Field Summary
Fields Modifier and Type Field Description int
index
Plugin priority (0 for highest priority)
-
Constructor Summary
Constructors Constructor Description PlayPlugin()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.String>
addMimeTypes()
Override to provide additional mime types from your plugin.java.util.List<java.lang.String>
addTemplateExtensions()
void
afterActionInvocation()
Called at the end of the action invocation.void
afterApplicationStart()
Called after the application start.void
afterFixtureLoad()
void
afterInvocation()
Called after an invocation.void
beforeActionInvocation(java.lang.reflect.Method actionMethod)
Called before an 'action' invocation, ie an HTTP request processing.void
beforeDetectingChanges()
void
beforeInvocation()
Called before a Play! invocation.java.lang.Object
bind(java.lang.String name, java.lang.Class clazz, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations, java.util.Map<java.lang.String,java.lang.String[]> params)
Deprecated.java.lang.Object
bind(java.lang.String name, java.lang.Object o, java.util.Map<java.lang.String,java.lang.String[]> params)
Deprecated.Use bindBean insteadjava.lang.Object
bind(RootParamNode rootParamNode, java.lang.String name, java.lang.Class<?> clazz, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations)
Called when play need to bind a Java object from HTTP params.java.lang.Object
bindBean(RootParamNode rootParamNode, java.lang.String name, java.lang.Object bean)
Called when play need to bind an existing Java object from HTTP params.int
compareTo(PlayPlugin o)
void
compileAll(java.util.List<ApplicationClasses.ApplicationClass> classes)
Deprecated.boolean
compileSources()
void
detectChange()
It's time for the plugin to detect changes.boolean
detectClassesChange()
It's time for the plugin to detect changes.void
enhance(ApplicationClasses.ApplicationClass applicationClass)
Enhance this classPlayPlugin.Filter
getFilter()
Return the filter implementation for this plugin.java.util.Collection<java.lang.Class>
getFunctionalTests()
Implement to add some classes that should be considered functional tests but do not extendFunctionalTest
to tests that can be executed by test runner (will be visible in test UI).com.google.gson.JsonObject
getJsonStatus()
Return the plugin status in JSON formatjava.lang.String
getMessage(java.lang.String locale, java.lang.Object key, java.lang.Object... args)
Translate the given key for the given locale and arguments.java.lang.String
getStatus()
Return the plugin statusjava.util.Collection<java.lang.Class>
getUnitTests()
Implement to add some classes that should be considered unit tests but do not extendAssert
to tests that can be executed by test runner (will be visible in test UI).boolean
hasFilter()
void
invocationFinally()
Called at the end of the invocation.Template
loadTemplate(VirtualFile file)
Model.Factory
modelFactory(java.lang.Class<? extends Model> modelClass)
void
onActionInvocationFinally()
Called at the end of the action invocation (either in case of success or any failure).void
onActionInvocationResult(Result result)
Called when the action method has thrown a result.void
onApplicationReady()
void
onApplicationStart()
Called at application start (and at each reloading) Time to start stateful things.void
onApplicationStop()
Called at application stop (and before each reloading) Time to shutdown stateful things.java.util.List<ApplicationClasses.ApplicationClass>
onClassesChange(java.util.List<ApplicationClasses.ApplicationClass> modified)
void
onConfigurationRead()
Called when the application.conf has been read.void
onEvent(java.lang.String message, java.lang.Object context)
Event may be sent by plugins or other componentsvoid
onInvocationException(java.lang.Throwable e)
Called if an exception occurred during the invocation.void
onInvocationSuccess()
void
onLoad()
Called at plugin loadingvoid
onRequestRouting(Router.Route route)
Called when the request has been routed.void
onRoutesLoaded()
Called after routes loading.void
onTemplateCompilation(Template template)
Deprecated.java.lang.String
overrideTemplateSource(BaseTemplate template, java.lang.String source)
static void
postEvent(java.lang.String message, java.lang.Object context)
Inter-plugin communication.boolean
rawInvocation(Http.Request request, Http.Response response)
Give a chance to this plugin to fully manage this requestvoid
routeRequest(Http.Request request)
Let some plugins route themselfTestEngine.TestResults
runTest(java.lang.Class<BaseTest> clazz)
Run a test classboolean
serveStatic(VirtualFile file, Http.Request request, Http.Response response)
Let a chance to this plugin to manage a static resourcejava.util.Map<java.lang.String,java.lang.Object>
unBind(java.lang.Object src, java.lang.String name)
Unbind an objectjava.lang.Object
willBeValidated(java.lang.Object value)
-
-
-
Method Detail
-
onLoad
public void onLoad()
Called at plugin loading
-
compileSources
public boolean compileSources()
-
runTest
public TestEngine.TestResults runTest(java.lang.Class<BaseTest> clazz)
Run a test class- Parameters:
clazz
- the class to run- Returns:
- : tests results
-
bind
@Deprecated public java.lang.Object bind(java.lang.String name, java.lang.Class clazz, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations, java.util.Map<java.lang.String,java.lang.String[]> params)
Deprecated.Use method using RootParamNode instead- Parameters:
name
- the name of the objectclazz
- the class of the object to bindtype
- typeannotations
- annotation on the objectparams
- parameters to bind- Returns:
- binding object
-
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)
Called when play need to bind a Java object from HTTP params. When overriding this method, do not call super impl.. super impl is calling old bind method to be backward compatible.- Parameters:
rootParamNode
- parameters to bindname
- the name of the objectclazz
- the class of the object to bindtype
- typeannotations
- annotation on the object- Returns:
- binding object
-
bind
@Deprecated public java.lang.Object bind(java.lang.String name, java.lang.Object o, java.util.Map<java.lang.String,java.lang.String[]> params)
Deprecated.Use bindBean instead- Parameters:
name
- the name of the objecto
- object to bindparams
- parameters to bind- Returns:
- binding object
-
bindBean
public java.lang.Object bindBean(RootParamNode rootParamNode, java.lang.String name, java.lang.Object bean)
Called when play need to bind an existing Java object from HTTP params. When overriding this method, DO NOT call the super method, since its default impl is to call the old bind method to be backward compatible.- Parameters:
rootParamNode
- parameters to bindname
- the name of the objectbean
- object to bind- Returns:
- binding object
-
unBind
public java.util.Map<java.lang.String,java.lang.Object> unBind(java.lang.Object src, java.lang.String name)
Unbind an object- Parameters:
src
- object to unbindname
- the name of the object- Returns:
- List of parameters
-
getMessage
public java.lang.String getMessage(java.lang.String locale, java.lang.Object key, java.lang.Object... args)
Translate the given key for the given locale and arguments. If null is returned, Play's normal message translation mechanism will be used.- Parameters:
locale
- the locale we wantkey
- the message keyargs
- arguments of the messages- Returns:
- the formatted string
-
getStatus
public java.lang.String getStatus()
Return the plugin status- Returns:
- the plugin status
-
getJsonStatus
public com.google.gson.JsonObject getJsonStatus()
Return the plugin status in JSON format- Returns:
- the plugin status in JSON format
-
enhance
public void enhance(ApplicationClasses.ApplicationClass applicationClass) throws java.lang.Exception
Enhance this class- Parameters:
applicationClass
- the class to enhance- Throws:
java.lang.Exception
- if cannot enhance the class
-
onTemplateCompilation
@Deprecated public void onTemplateCompilation(Template template)
Deprecated.This hook is not plugged, don't implement it- Parameters:
template
- the template to compile
-
rawInvocation
public boolean rawInvocation(Http.Request request, Http.Response response) throws java.lang.Exception
Give a chance to this plugin to fully manage this request- Parameters:
request
- The Play requestresponse
- The Play response- Returns:
- true if this plugin has managed this request
- Throws:
java.lang.Exception
- if cannot enhance the class
-
serveStatic
public boolean serveStatic(VirtualFile file, Http.Request request, Http.Response response)
Let a chance to this plugin to manage a static resource- Parameters:
file
- The requested filerequest
- The Play requestresponse
- The Play response- Returns:
- true if this plugin has managed this request
-
beforeDetectingChanges
public void beforeDetectingChanges()
-
loadTemplate
public Template loadTemplate(VirtualFile file)
- Parameters:
file
- the file of the template to load- Returns:
- the template object
-
detectChange
public void detectChange()
It's time for the plugin to detect changes. Throw an exception is the application must be reloaded.
-
detectClassesChange
public boolean detectClassesChange()
It's time for the plugin to detect changes. Throw an exception is the application must be reloaded.- Returns:
- false si no change detected
-
onApplicationStart
public void onApplicationStart()
Called at application start (and at each reloading) Time to start stateful things.
-
afterApplicationStart
public void afterApplicationStart()
Called after the application start.
-
onApplicationStop
public void onApplicationStop()
Called at application stop (and before each reloading) Time to shutdown stateful things.
-
beforeInvocation
public void beforeInvocation()
Called before a Play! invocation. Time to prepare request specific things.
-
afterInvocation
public void afterInvocation()
Called after an invocation. (unless an exception has been thrown). Time to close request specific things.
-
onInvocationException
public void onInvocationException(java.lang.Throwable e)
Called if an exception occurred during the invocation.- Parameters:
e
- The caught exception.
-
invocationFinally
public void invocationFinally()
Called at the end of the invocation. (even if an exception occurred). Time to close request specific things.
-
beforeActionInvocation
public void beforeActionInvocation(java.lang.reflect.Method actionMethod)
Called before an 'action' invocation, ie an HTTP request processing.- Parameters:
actionMethod
- name of the method
-
onActionInvocationResult
public void onActionInvocationResult(Result result)
Called when the action method has thrown a result.- Parameters:
result
- The result object for the request.
-
onInvocationSuccess
public void onInvocationSuccess()
-
onRequestRouting
public void onRequestRouting(Router.Route route)
Called when the request has been routed.- Parameters:
route
- The route selected.
-
afterActionInvocation
public void afterActionInvocation()
Called at the end of the action invocation.
-
onActionInvocationFinally
public void onActionInvocationFinally()
Called at the end of the action invocation (either in case of success or any failure).
-
onConfigurationRead
public void onConfigurationRead()
Called when the application.conf has been read.
-
onRoutesLoaded
public void onRoutesLoaded()
Called after routes loading.
-
onEvent
public void onEvent(java.lang.String message, java.lang.Object context)
Event may be sent by plugins or other components- Parameters:
message
- convention: pluginClassShortName.messagecontext
- depends on the plugin
-
onClassesChange
public java.util.List<ApplicationClasses.ApplicationClass> onClassesChange(java.util.List<ApplicationClasses.ApplicationClass> modified)
- Parameters:
modified
- list of modified class- Returns:
- List of class
-
addTemplateExtensions
public java.util.List<java.lang.String> addTemplateExtensions()
- Returns:
- List of the template extension
-
addMimeTypes
public java.util.Map<java.lang.String,java.lang.String> addMimeTypes()
Override to provide additional mime types from your plugin. These mimetypes get priority over the default framework mimetypes but not over the application's configuration.- Returns:
- a Map from extensions (without dot) to mimetypes
-
compileAll
@Deprecated public void compileAll(java.util.List<ApplicationClasses.ApplicationClass> classes)
Deprecated.Let a chance to the plugin to compile it owns classes. Must be added to the mutable list.- Parameters:
classes
- list of class to compile
-
routeRequest
public void routeRequest(Http.Request request)
Let some plugins route themself- Parameters:
request
- the current request
-
modelFactory
public Model.Factory modelFactory(java.lang.Class<? extends Model> modelClass)
- Parameters:
modelClass
- class of the model- Returns:
- the Model factory
-
afterFixtureLoad
public void afterFixtureLoad()
-
postEvent
public static void postEvent(java.lang.String message, java.lang.Object context)
Inter-plugin communication.- Parameters:
message
- the message to postcontext
- an object
-
onApplicationReady
public void onApplicationReady()
-
compareTo
public int compareTo(PlayPlugin o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<PlayPlugin>
-
overrideTemplateSource
public java.lang.String overrideTemplateSource(BaseTemplate template, java.lang.String source)
-
willBeValidated
public java.lang.Object willBeValidated(java.lang.Object value)
-
getUnitTests
public java.util.Collection<java.lang.Class> getUnitTests()
Implement to add some classes that should be considered unit tests but do not extendAssert
to tests that can be executed by test runner (will be visible in test UI).Note:You probably will also need to override
runTest(java.lang.Class)
method to handle unsupported tests execution properly.Keep in mind that this method can only add tests to currently loaded ones. You cannot disable tests this way. You should also make sure you do not duplicate already loaded tests.
- Returns:
- list of plugin supported unit test classes (empty list in default implementation)
-
getFunctionalTests
public java.util.Collection<java.lang.Class> getFunctionalTests()
Implement to add some classes that should be considered functional tests but do not extendFunctionalTest
to tests that can be executed by test runner (will be visible in test UI).Note:You probably will also need to override
runTest(java.lang.Class)
method to handle unsupported tests execution properly.Keep in mind that this method can only add tests to currently loaded ones. You cannot disable tests this way. You should also make sure you do not duplicate already loaded tests.
- Returns:
- list of plugin supported functional test classes (empty list in default implementation)
-
hasFilter
public final boolean hasFilter()
-
getFilter
public PlayPlugin.Filter getFilter()
Return the filter implementation for this plugin.- Returns:
- filter object of this plugin
-
-