我正在使用Java EE 6& Jboss AS7.1并尝试使用拦截器绑定(
Example from jboss site).
我有一个InterceptorBinding注释:
@InterceptorBinding
@Target({ ElementType.METHOD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface GeoRestrictedEquipment {
}
拦截器:
@GeoRestrictedEquipment
@Interceptor
public class GeoRestrictedEquipmentInterceptor {
@EJB EquipmentDao equipmenttDao;
@EJB SecurityService securityService;
@AroundInvoke
public Object checker(InvocationContext ctx) throws Exception {
Integer id = (Integer) ctx.getParameters()[0];
Equipment equipment = equipmenttDao.findById(id);
GeoChecker.check(equipment.getSite(), securityService.getUser());
return ctx.proceed();
}
}
还有一个豆子:
@Stateless
@LocalBean
@SecurityDomain(Realm.NAME)
@RolesAllowed({ Roles.REGISTERED })
public class PumpService implements PumpServiceLocal {
@Override
@GeoRestrictedEquipment
public PumpInfos getPumpInfos(Integer pumpId) {
/* ... */
}
}
但拦截器没有被调用……我从这个例子中错过了什么?
我写这个时会调用拦截器:
@Override
@Interceptors({GeoRestrictedEquipmentInterceptor.class})
public PumpInfos getPumpInfos(Integer pumpId) {
/* ... */
}
谢谢你的帮助.