2012-04-02 22 views
0

Play 1插件基類,是play.PlayPlugin,裏面有很多的方法(場):爲什麼Play 1和Play 2之間`plugin`的基類有如此不同?

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) 

和播放2的是play.api.Plugin,這是非常簡單的:

onStart(): Unit 
onStop(): Unit 
enabled: Boolean 

爲什麼他們如此不同?我認爲Play 1的插件類中的方法定義爲extension-points,對於Play 2,它們不再需要嗎?

回答

1

播放2.0區分全局設置插件

Global settings是特定於應用程序,並允許定製框架的某些行爲(例如,如果沒有找到請求的操作應該做什麼)。實際上Play 1.x插件的大多數擴展點現在都在Play 2.x全局設置中。

Plugins是可能需要了解應用程序生命週期以執行初始化/清理操作的模塊。

相關問題