The plugin base class in Play 1, is play.PlayPlugin, which has a lot of methods (fields):
index : int
onLoad()
compileSources()
runTest(Class<BaseTest>)
bind(String, Class, Type, Annotation[], Map<String, String[]>)
bind(RootParamNode, String, Class<?>, Type, Annotation[])
bind(String, Object, Map<String, String[]>)
bindBean(RootParamNode, String, Object)
unBind(Object, String)
getMessage(String, Object, Object...)
getStatus()
getJsonStatus()
enhance(ApplicationClass)
onTemplateCompilation(Template)
rawInvocation(Request, Response)
serveStatic(VirtualFile, Request, Response)
beforeDetectingChanges()
loadTemplate(VirtualFile)
detectChange()
detectClassesChange()
onApplicationStart()
afterApplicationStart()
onApplicationStop()
beforeInvocation()
afterInvocation()
onInvocationException(Throwable)
invocationFinally()
beforeActionInvocation(Method)
onActionInvocationResult(Result)
onInvocationSuccess()
onRequestRouting(Route)
afterActionInvocation()
onConfigurationRead()
onRoutesLoaded()
onEvent(String, Object)
onClassesChange(List<ApplicationClass>)
addTemplateExtensions()
addMimeTypes()
compileAll(List<ApplicationClass>)
routeRequest(Request)
modelFactory(Class<? extends Model>)
afterFixtureLoad()
postEvent(String, Object)
onApplicationReady()
compareTo(PlayPlugin)
overrideTemplateSource(BaseTemplate, String)
willBeValidated(Object)
And Play 2’s is play.api.Plugin, which is very simple:
onStart(): Unit
onStop(): Unit
enabled: Boolean
Why are they so different? And I think the methods in plugin class of Play 1, are defined as extension-points, aren’t they not needed anymore for Play 2?
Play 2.0 differentiates global settings and plugins.
Global settings are specific to an application and allows to customize some behavior of the framework (e.g. what should be done if no action were found for a request). Actually most of the extension points of Play 1.x plugins are now in Play 2.x global settings.
Plugins are modules which may need to be aware of the application lifecycle to perform initialization/cleaning operations.