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

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);
		}
	}

 

你可能感兴趣的:(java后台)