因此,我能夠讓Vaidin獲得Apache Shiro與Guice(感謝ShiroWebModule)的合作。 Shiro註釋(@RequiresAuthentication
,@RequiresPermission
)僅適用於主Vaadin應用程序類和自定義類內。它們在CustomComponent/Window類中不起作用。Apache Shiro + Guice - 無法獲得註解工作
我試圖注入窗口類與供應商的應用程序類,通過injector.getInstance
,它仍然無法正常工作......
我是新來吉斯和四郎,所以也許我失去了一些東西?
爲什麼它適用於其他自定義類?這工作正常(拋出異常)
public class TestClassImpl implements TestClass {
@Override
public void doSomeWork() {
//this will throw an exception as expected
test();
}
@RequiresAuthentication
public void test() {
}
}
預期這不起作用(執行方法,在Apache四郎註釋被忽略):
public class LoginView extends CustomComponent {
public LoginWindow() {
setCompositionRoot(mainLayout);
//this will execture but it should not
test();
}
@RequiresAuthentication
public void test() {
}
}
謝謝您的回覆。但是即使直接注入,TestClassImpl也可以工作,沒有接口。因此,這會不會引發異常(但應)'injector.getInstance(LoginView.class);'這按預期工作(會引發安全異常)\t'injector.getInstance(TestClassImpl.class);'。他們都在用@RequiresAuthentification註解的構造函數中調用一個方法。 – 2012-04-16 19:52:33
好的,這裏有一個更基本的問題。 Guice不會在CustomComponents中注入任何類。我不知道爲什麼。這絕對應該工作,但我做錯了什麼。 – 2012-04-18 18:11:54
更新。我有解決這個問題的辦法。只有構造函數注入在Components/Windows中工作(不知道爲什麼)。因此,我注入了我需要的服務類,並在裏面有Shiro註釋,這些都是可行的。我只需要編程檢查Vaadin組件/窗口類中的Shiro角色/權限。 – 2012-04-18 20:35:54