Can't Get Guice Method Interception to Work

后端 未结 1 1667
名媛妹妹
名媛妹妹 2020-12-19 22:45

I\'m trying to print a \"Hello, AOP!\" message whenever Guice/AOP Alliance intercepts a method marked with a particular (custom) annotation. I have followed the official do

相关标签:
1条回答
  • 2020-12-19 22:51

    If you don't let Guice construct your object, it can't provide you an instance with the interceptor wrapped around. You must not use new AopTest() to get an instance of your object. Instead, you must ask Guice to give you one instance:

    Injector injector = Guice.createInjector(new ValidatingModule ());
    AopTest test = injector.getInstance(AopTest.class);
    

    See http://code.google.com/p/google-guice/wiki/GettingStarted

    0 讨论(0)
提交回复
热议问题