Interceptor method not called with interceptor binding

后端 未结 3 1413
甜味超标
甜味超标 2020-12-10 13:06

I\'m using Java EE 6 & Jboss AS7.1 and try to use interceptor binding (Example from jboss site).

I have an InterceptorBinding annotation:

@Interc         


        
相关标签:
3条回答
  • 2020-12-10 13:26

    Did you enable your interceptor as described in the referenced example?

    By default, a bean archive has no enabled interceptors bound via interceptor bindings. An interceptor must be explicitly enabled by listing its class under the element of the beans.xml file of the bean archive.

    0 讨论(0)
  • 2020-12-10 13:33

    According to the documentation there is another way rather than using beans.xml:

    You do not need to specify the interceptor in the beans.xml file when you use the @Priority annotation.

    @Logged
    @Interceptor
    @Priority(Interceptor.Priority.APPLICATION)
    public class LoggedInterceptor implements Serializable { ... }
    

    And it works.

    0 讨论(0)
  • 2020-12-10 13:36

    You can use any priority value = Priority.Application is 2000 by default.

    For example =

    @Interceptor 
    @Loggable 
    @Priority(100)
    public class FileLogger {}
    

    Priority type:

    • PLATFORM_BEFORE [0-999] - interceptors start at the first. They are started by the platform.
    • LIBRARY_BEFORE [1000-1999] - by the libraries.
    • APPLICATION [2000-2999]- by the application
    • LIBRARY_AFTER,PLATFORM_AFTER [3000-4000]

    You manage primary loading for interceptors.

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