标签:cep main aries val long rgs private run dynamic
timeCountIntecetor implements handlerInterceptor { preHandle(); postHandle(); afterComplete(); }
class MyProxy implements InvocationHandler { Object obj; public Object bind(Object obj) { this.obj = obj; return Proxy.newProxyInstance(obj.getClass().getClassLoader(), obj .getClass().getInterfaces(), this); } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { System.out.println("I‘m proxy!"); Object res = method.invoke(obj, args); return res; } } public class DynamicProxy { public static void main(String[] args) { MyProxy myproxy = new MyProxy(); HoseeDynamicimpl dynamicimpl = new HoseeDynamicimpl(); HoseeDynamic proxy = (HoseeDynamic)myproxy.bind(dynamicimpl); System.out.println(proxy.sayhi()); } }
@Pointcut("execution(* me.ele.jarch.aries.service.*.*(..))") private void serviceMethod() { } // @Around("me.ele.jarch.aries.aspect.ServiceTimeCountAspect.serviceMethod()") // @Around("serviceMethod() || repositoryMethod()") @Around("serviceMethod()") public Object logServiceMethodRunningTime(ProceedingJoinPoint pjp) throws Throwable { // start stopwatch StopWatch watch = new StopWatch(); watch.start(); Object retVal = pjp.proceed(); // stop stopwatch watch.stop(); Long time = watch.getTotalTimeMillis(); String methodName = pjp.getSignature().getName(); logger.info("service method: {} time count : {}", methodName, time); return retVal; }
标签:cep main aries val long rgs private run dynamic
原文地址:http://www.cnblogs.com/mywy/p/6130144.html