use of org.apache.tapestry5.ioc.annotations.Advise in project tapestry-5 by apache.
the class TestAdvice method advise.
@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();
}
}
Aggregations