Search in sources :

Example 11 with Advise

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();
    }
}
Also used : IntermediateType(org.apache.tapestry5.ioc.annotations.IntermediateType) Method(java.lang.reflect.Method) Advise(org.apache.tapestry5.ioc.annotations.Advise)

Aggregations

MethodAdvice (org.apache.tapestry5.plastic.MethodAdvice)7 MethodInvocation (org.apache.tapestry5.plastic.MethodInvocation)6 Method (java.lang.reflect.Method)3 Advise (org.apache.tapestry5.ioc.annotations.Advise)3 SessionTracker (com.flowlogix.web.mixins.SessionTracker)1 AJAX (com.flowlogix.web.services.annotations.AJAX)1 IOException (java.io.IOException)1 SneakyThrows (lombok.SneakyThrows)1 Binding (org.apache.tapestry5.Binding)1 ComponentResources (org.apache.tapestry5.ComponentResources)1 ObjectCreator (org.apache.tapestry5.commons.ObjectCreator)1 AdvisorDef (org.apache.tapestry5.ioc.AdvisorDef)1 MethodAdviceReceiver (org.apache.tapestry5.ioc.MethodAdviceReceiver)1 IntermediateType (org.apache.tapestry5.ioc.annotations.IntermediateType)1 Order (org.apache.tapestry5.ioc.annotations.Order)1 InjectionResources (org.apache.tapestry5.ioc.internal.util.InjectionResources)1 MapInjectionResources (org.apache.tapestry5.ioc.internal.util.MapInjectionResources)1 CacheMethodAdvice (org.apache.tapestry5.jcache.internal.CacheMethodAdvice)1 CachePutMethodAdvice (org.apache.tapestry5.jcache.internal.CachePutMethodAdvice)1 CacheRemoveAllMethodAdvice (org.apache.tapestry5.jcache.internal.CacheRemoveAllMethodAdvice)1