我有以下情况
拦截器接口
@Inherited
@InterceptorBinding
@Documented
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface IErrorHandlerInterceptor {
Car tyre() default Car.FOUR;
}
枚举类
public enum Car{
FOUR,FIVE;
}
EJB 无状态类
@ErrorHandlerInterceptor(tyre= Car.FIVE)
public List<?> getCarByName(String name) {
----------
return List<?>;
}
豆类.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
<interceptors>
<class>de.festado.interceptor.impl.ErrorHandlerInterceptor</class>
</interceptors>
</beans>
拦截器实现
@IErrorHandlerInterceptor
@Interceptor
public class ErrorHandlerInterceptor {
@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
IErrorHandlerInterceptor ei = getClass().getAnnotation(IErrorHandlerInterceptor.class);
String tyresNumber= ei.tyre().toString();
try {
return context.proceed();
} catch(Exception e) {
....
} finally {
.....
}
return null;
}
现在我的问题:
每当我调用String tyresNumber= ei.tyre().toString();
它时,只需返回我在接口声明中设置的默认值。
我在这里做错了什么?我忘记了什么吗?
谢谢你的帮助