如何在Play模块中调用beforeActionInvocation和afterActionInvocation? [英] How to get beforeActionInvocation and afterActionInvocation to be called in Play module?

查看:72
本文介绍了如何在Play模块中调用beforeActionInvocation和afterActionInvocation?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建我的第一个Play模块.我使用另一个模块作为示例,并创建了一个Plugin.java类作为我的主界面.我可以从我的标签轻松访问此类的方法,但是看来该对象未经历正常的生命周期.具体来说,永远不会调用beforeActionInvocation()afterActionInvocation().

I'm working on building my first Play module. I used another module as an example and created a Plugin.java class to serve as my main interface. I can access the methods on this class easily from my tags, but it seems that the object is not going through the normal lifecycle. Specifically, beforeActionInvocation() and afterActionInvocation() are never being called.

此模块现在或多或少是一个存根,是通过播放新模块"创建的,并且我还没有修改任何默认文件(尽管我已经添加了此类和一些标签).

This module is more or less a stub right now, created via "play new-module" and I've not modified any of the default files (though I have added this class and some tags).

我的问题是:是什么导致Plugin类经历正常的插件生命周期,因为我的似乎并非如此?我缺少一些配置吗?

My question is: what causes a Plugin class to go through the normal plugin lifecycle, as it seems mine is not? Is there some configuration I'm missing?

推荐答案

在您的类路径中,您必须具有PlayPlugin的子类和文件play.plugins,并在其中注册

You must have a subclass of PlayPlugin and a file play.plugins in your classpath, where you register it with

1003:myPackage.MyPlugin

这篇关于如何在Play模块中调用beforeActionInvocation和afterActionInvocation?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆