简体   繁体   English

如何将服务注入Play Framework 2.1插件?

[英]How to inject services into Play Framework 2.1 plugin?

I'm trying to write a plugin for Play Framework Java 2.1.1 and I would like to inject a service inside the plugin so I can unit test the plugin properly. 我正在尝试为Play Framework Java 2.1.1编写插件,我想在插件内部注入服务,以便可以正确地对插件进行单元测试。

However, in the constructor I only have this. 但是,在构造函数中我只有这个。

public TestUsernamePasswordAuthProvider(Application app) {
    super(app);
}

which I think I cannot change I already have GlobalSettings to inject the services into controllers, can I do something like that for plugins? 我想我无法更改,因为我已经有GlobalSettings可以将服务注入控制器中,我可以为插件做类似的事情吗?

Thanks. 谢谢。

As of now, it's impossible see https://github.com/playframework/playframework/issues/1389 到目前为止,不可能看到https://github.com/playframework/playframework/issues/1389

but with some luck this Pull Request will be merge soon in the master. 但是如果运气好的话,这个Pull Request将很快在主服务器中合并。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM