java通过反射动态获取类名和方法名

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/danruoshui315/article/details/84783696
import org.aopalliance.intercept.MethodInvocation;
@Override
	public Object invoke(final MethodInvocation invoke) throws Throwable {
		long time = System.currentTimeMillis();
		try {
			return invoke.proceed();
		} finally {
			long date = System.currentTimeMillis() - time;
			Method method = invoke.getMethod();
			String className = method.getDeclaringClass().getName();
			String methodName = method.getName();
			MethodMonitor methodMonitor = MethodMonitor.builder().className(className).appName(appName)
					.id(String.valueOf(IdGenerator.getInstance().generateId())).invokeTime(time)
					.methodName(methodName).methodType("").responseTime(date)
					.methodStatus("success").build();
			results.addTime(methodMonitor);
		}
	}

猜你喜欢

转载自blog.csdn.net/danruoshui315/article/details/84783696