/*** 使用AOP联盟提供的API,用来定义拦截器使用* @param args* @throws Throwable*/public static void main(String[] args) throws Throwable {// 我特意这么写用以显示指定拦截器的使用方法MethodInterceptor interceptor = new MethodInterceptor() {@Overridepublic Object invoke(MethodInvocation methodInvocation) throws Throwable {System.out.println("before...");Object proceed = methodInvocation.proceed();System.out.println("after...");return proceed;}};Object result = interceptor.invoke(new MethodInvocation() {@Overridepublic Method getMethod() {return null;}@Overridepublic Object[] getArguments() {return new Object[0];}@Overridepublic Object proceed() throws Throwable {System.out.println("invoke action");return "HELLO,AOP";}@Overridepublic Object getThis() {return null;}@Overridepublic AccessibleObject getStaticPart() {return null;}});System.out.println(result);}
