【发布时间】:2013-09-21 22:13:46
【问题描述】:
是否可以在方法变量被拦截时提取一次/同时提取它的值?我不想截取参数而是方法中的属性值?例如
Business Logic:
@MyInterceptor
void myMethod(Object o){
ArrayList myList= null;
myList= dao.getRecords(o.getId) //intercept the result of this dao call
//I only want to call doWork after I have 'validated' contents of myList in interceptor
doWork(myList)
}
The Interceptor:
@Interceptor
@MyInterceptor
MyInterceptor{
@AroundInvoke{
public Object invoke(InvocationContext ctx) throws Exception {
//retrieve the contents of myList above and perform validation
//if it passes validation call ctx.proceed else return error
}
}
谢谢
【问题讨论】:
标签: java java-ee-6 cdi interceptor jboss-weld