Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ApacheShiro+;Guice-can';我无法让注释正常工作_Apache_Guice_Vaadin_Shiro - Fatal编程技术网

ApacheShiro+;Guice-can';我无法让注释正常工作

ApacheShiro+;Guice-can';我无法让注释正常工作,apache,guice,vaadin,shiro,Apache,Guice,Vaadin,Shiro,所以我能够让ApacheShiro在Vaadin上与Guice合作(感谢ShiroWebModule)。 Shiro注释(@requireAuthentication,@requirepermission)仅在主Vaadin应用程序类和自定义类内部工作。它们在CustomComponent/Window类中不起作用 我尝试通过injector.getInstance将窗口类注入到具有提供程序的应用程序类中,但仍然不起作用 我是Guice和Shiro的新手,所以也许我错过了什么 为什么它适用于其他

所以我能够让ApacheShiro在Vaadin上与Guice合作(感谢ShiroWebModule)。 Shiro注释(
@requireAuthentication
@requirepermission
)仅在主Vaadin应用程序类和自定义类内部工作。它们在CustomComponent/Window类中不起作用

我尝试通过
injector.getInstance
将窗口类注入到具有提供程序的应用程序类中,但仍然不起作用

我是Guice和Shiro的新手,所以也许我错过了什么

为什么它适用于其他自定义类?这将按预期工作(引发异常)

这不符合预期(方法已执行,Apache Shiro注释被忽略):


在运行时使用这样的注释通常涉及AOP

使用SpringAOP,您无法拦截对self的调用:这是因为SpringAOP生成代理类,而拦截发生在这些代理上->它无法拦截对self的调用

我怀疑Guice AOP也以同样的方式工作


注意:TestClass/Impl和LoginView之间的区别之一是TestClass实现了一个接口;Guice可能会以不同的方式对待接口代理和“普通类”代理——我会尝试更改TestClass以扩展抽象类,看看会发生什么。

谢谢您的回复。但是TestClassImpl即使直接注入也可以工作,没有接口。因此,这不会引发异常(但它应该)
injector.getInstance(LoginView.class)并且这可以按预期工作(抛出安全异常)
injector.getInstance(TestClassImpl.class)。它们都在构造函数中调用一个方法,该方法用@requireauthentication注释。好的,这里有一个更基本的问题。Guice不会在CustomComponents中注入任何类。我不知道为什么。这肯定会奏效,但我做错了。更新。我有解决这个问题的办法。只有构造函数注入在组件/窗口中工作(不知道为什么)。因此,我注入了我需要的服务类,这些服务类中包含了Shiro注释,可以正常工作。我只需要通过编程检查Vaadin组件/窗口类中的Shiro角色/权限。
public class TestClassImpl implements TestClass {

    @Override

    public void doSomeWork() {
        //this will throw an exception as expected
        test();
    }

    @RequiresAuthentication

    public void test() {

    }
}
  public class LoginView extends CustomComponent {

    public LoginWindow() {
        setCompositionRoot(mainLayout);
        //this will execture but it should not
        test();
    }

    @RequiresAuthentication

    public void test() {

    }
}