@Override protected Method getMethod(MethodInvocation invocation) { return invocation.getMethod(); }
@Override protected Method getMethod(MethodInvocation invocation) { return invocation.getMethod(); }
@Override protected Object[] getParameters(MethodInvocation invocation) { Object[] parameters = new Object[invocation.getMethod().getParameterTypes().length]; for (int i = 0; i < parameters.length; i++) { parameters[i] = invocation.getParameter(i); } return parameters; }
private Object[] extractParameters(MethodInvocation invocation) { int count = invocation.getMethod().getParameterTypes().length; Object[] result = new Object[count]; for (int i = 0; i < count; i++) { result[i] = invocation.getParameter(i); } return result; } }
private Object[] extractParameters(MethodInvocation invocation) { int count = invocation.getMethod().getParameterTypes().length; Object[] result = new Object[count]; for (int i = 0; i < count; i++) { result[i] = invocation.getParameter(i); } return result; } }
@Override protected Object[] getParameters(MethodInvocation invocation) { Object[] parameters = new Object[invocation.getMethod().getParameterTypes().length]; for (int i = 0; i < parameters.length; i++) { parameters[i] = invocation.getParameter(i); } return parameters; }
/** * Invoked when method invocation instead throws an exception. * * @param invocation identifies method invocation which failed * @param t exception throws by method invocation */ public void fail(MethodInvocation invocation, Throwable t) { logger.debug( format("[%s] %s -- %s", FAIL, invocation.getMethod().getName(), t.getClass().getName()), exceptionTracker.exceptionLogged(t) ? null : t); } }
/** * Invoked when method invocation instead throws an exception. * * @param invocation identifies method invocation which failed * @param t exception throws by method invocation */ public void fail(MethodInvocation invocation, Throwable t) { logger.debug( format("[%s] %s -- %s", FAIL, invocation.getMethod().getName(), t.getClass().getName()), exceptionTracker.exceptionLogged(t) ? null : t); } }
/** * Invoked when a method is first entered * * @param invocation identifies method invoked as well as parameters passed to method */ public void entry(MethodInvocation invocation) { StringBuilder buffer = new StringBuilder(BUFFER_SIZE); buffer.append(format("[%s] %s(", ENTER, invocation.getMethod().getName())); for (int i = 0; i < invocation.getMethod().getParameterTypes().length; i++) { if (i > 0) buffer.append(", "); convert(buffer, invocation.getParameter(i)); } buffer.append(')'); logger.debug(buffer.toString()); }
/** * Invoked when a method is first entered * * @param invocation identifies method invoked as well as parameters passed to method */ public void entry(MethodInvocation invocation) { StringBuilder buffer = new StringBuilder(BUFFER_SIZE); buffer.append(format("[%s] %s(", ENTER, invocation.getMethod().getName())); for (int i = 0; i < invocation.getMethod().getParameterTypes().length; i++) { if (i > 0) buffer.append(", "); convert(buffer, invocation.getParameter(i)); } buffer.append(')'); logger.debug(buffer.toString()); }
/** * Invoked when a method exits (possibly returning a value). * * @param invocation identifies method invocation and result value */ public void exit(MethodInvocation invocation) { StringBuilder buffer = new StringBuilder(BUFFER_SIZE); buffer.append(format("[%s] %s", EXIT, invocation.getMethod().getName())); if (invocation.getMethod().getReturnType() != void.class) { buffer.append(" ["); convert(buffer, invocation.getReturnValue()); buffer.append(']'); } logger.debug(buffer.toString()); }
/** * Invoked when a method exits (possibly returning a value). * * @param invocation identifies method invocation and result value */ public void exit(MethodInvocation invocation) { StringBuilder buffer = new StringBuilder(BUFFER_SIZE); buffer.append(format("[%s] %s", EXIT, invocation.getMethod().getName())); if (invocation.getMethod().getReturnType() != void.class) { buffer.append(" ["); convert(buffer, invocation.getReturnValue()); buffer.append(']'); } logger.debug(buffer.toString()); }
@Override protected Method getMethod(MethodInvocation invocation) { Method method = invocation.getMethod(); final Class<?> methodClass = method.getClass(); final Class<?> targetClass = getTargetClass(invocation); if (methodClass != targetClass) { method = findMethod(method, targetClass); } return method; }
public void advise(MethodInvocation invocation) { Class<?>[] parameterTypes = invocation.getMethod().getParameterTypes(); for (int i = 0; i < parameterTypes.length; i++) { if (parameterTypes[i].equals(String.class)) { String value = (String) invocation.getParameter(i); invocation.setParameter(i, reverse(value)); } } invocation.proceed(); if (invocation.getMethod().getReturnType().equals(String.class)) { if (invocation.didThrowCheckedException()) { Exception thrown = invocation.getCheckedException(Exception.class); invocation.setReturnValue(String.format("Invocation of method %s() failed with %s.", invocation.getMethod().getName(), thrown.getClass().getName())); return; } String value = (String) invocation.getReturnValue(); invocation.setReturnValue(reverse(value)); } }
@Override public void advise(MethodInvocation invocation) { final Method method = invocation.getMethod(); boolean annotationFoundInMethod = checkAnnotation(method.getAnnotation(Advise.class)); boolean annotationFoundThroughAnnotationProvider = checkAnnotation(invocation.getAnnotation(Advise.class)); IntermediateType parameterAnnotation = null; final Annotation[][] parameterAnnotations = method.getParameterAnnotations(); if (parameterAnnotations.length > 0 && parameterAnnotations[0].length > 0) { parameterAnnotation = (IntermediateType) parameterAnnotations[0][0]; } boolean annotationParameter = parameterAnnotation != null && parameterAnnotation.value() == String.class; if (annotationFoundInMethod && annotationFoundThroughAnnotationProvider && annotationParameter) { invocation.setReturnValue(ANNOTATION_FOUND); } else { invocation.proceed(); } }