blob: 853a8912fc6b5fca8a638ed9103865664e3d1e90 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
package examples.stateless.interceptors;
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
public class AuditorInterceptor {
@AroundInvoke
public Object checkCost(InvocationContext inv) throws Exception {
if (inv.getMethod().getName().startsWith("getTax")) {
Object[] o = inv.getParameters();
double cost = ((Double)o[0]).doubleValue();
if (cost > 50) {
System.out.println("Cost is > 50!");
}
}
return inv.proceed();
}
}
|