有一些示例将不同类型的对象注入到演示者中,但我找不到如何完成此操作的解释。
In the 引导程序代码 http://dev.arcbees.com/gwtp/get-started/Bootstrap-Code.html例如他们正在注入ASecurityDelegate
目的。
也在看门人 http://dev.arcbees.com/gwtp/core/security/例如我看到有东西被注入,例如MyGatekeeper
,但是这是怎么做到的呢?
我想要的是首先检查用户是否登录,然后创建一个CurrentSession
对象或类似的东西。但是我怎样才能传递/注入这个对象呢?
目前我正在初始化一个单例对象CurrentUser
恕我直言,这有点丑陋。我想运行 GWTP 支持,但是如何实现呢?
以这个例子为例CurrentSession
被注入到网守中:
@DefaultGatekeeper
public class LoggedInGatekeeper implements Gatekeeper {
private final CurrentSession currentSession;
@Inject
LoggedInGatekeeper(CurrentSession currentSession) {
this.currentSession = currentSession;
}
@Override
public boolean canReveal() {
return currentSession.isLoggedIn();
}
}
我该如何注射CurrentSession
here?
这是解释如何使用 Gatekeeper 的教程:http://dev.arcbees.com/gwtp/tutorials/tutorial-part2.html http://dev.arcbees.com/gwtp/tutorials/tutorial-part2.html
在 Gin 的模块中将 CurrentSession 的类(本教程中的 CurrentUser )声明为 Singleton,如下所示:
public class YourGinModule extends AbstractGinModule {
@Override
protected void configure() {
bind( CurrentSession.class ).in ( Singleton.class );
...
}
}
在这里您可以找到另一个在客户端使用 GWTP Gatekeeper 并在服务器端使用 Spring Security 的示例:https://github.com/imrabti/gwtp-spring-security https://github.com/imrabti/gwtp-spring-security
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)