使用自定义注释添加EJB拦截器 [英] Adding EJB interceptors with custom annotations

查看:153
本文介绍了使用自定义注释添加EJB拦截器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些需要额外配置的EJB3.0拦截器。到目前为止,我只是通过 @Interceptors({MyInterceptor.class})添加拦截器,然后添加了一个第二个自定义注释,如 @MyInterceptorConfiguration( value = something)



虽然这很麻烦,是否可以注释自定义注释,以便它会触发添加拦截器?理想情况下,我想将 @DoMyInterception(config = foo)添加到一个类中,并添加我的拦截器。

解决方案

只有CDI 原型注释(请参阅拦截器绑定页面的例子)在EE 6(EJB 3.1)中。


I have a number of EJB3.0 interceptors that require additional configuration. So far I have been simply adding the interceptors via @Interceptors( { MyInterceptor.class } ) and then added a second, custom annotation like @MyInterceptorConfiguration(value=something).

This is rather tedious though. Is it possible to annotate a custom annotation so that it will trigger the addition of an Interceptor? Ideally I would like to just add @DoMyInterception(config=foo) to a class and have that add my interceptor.

解决方案

This is only possible with CDI stereotype annotations (see the interceptor bindings page for examples) in EE 6 (EJB 3.1).

这篇关于使用自定义注释添加EJB拦截器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆