auditorinterceptor.java

来自「EJB3.0请一定要上载质量高而且本站没有的源码」· Java 代码 · 共 19 行

JAVA
19
字号
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();
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?