Search in sources :

Example 1 with ConditionalTest

use of org.talend.dataprep.async.conditional.ConditionalTest in project data-prep by Talend.

the class AsyncAspect method executeAsynchronously.

/**
 * Return if we need to execute the method asynchronously by calling the conditionalClass definined on the annotation.
 * By Default call the AlwaysTrueCondtion
 * @param pjp pjp the proceeding join point.
 * @return true if we need to execute the method asynchronously. False otherwise
 */
private Boolean executeAsynchronously(ProceedingJoinPoint pjp) {
    MethodSignature ms = (MethodSignature) pjp.getSignature();
    Method m = ms.getMethod();
    final AsyncOperation asyncOperationAnnotation = m.getAnnotation(AsyncOperation.class);
    Class<? extends ConditionalTest> conditionalTestGenerator = asyncOperationAnnotation.conditionalClass();
    final ConditionalTest conditionalTest = applicationContext.getBean(conditionalTestGenerator);
    Object[] args = AnnotationUtils.extractAsyncParameter(pjp);
    return conditionalTest.apply(args);
}
Also used : MethodSignature(org.aspectj.lang.reflect.MethodSignature) ConditionalTest(org.talend.dataprep.async.conditional.ConditionalTest) Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)1 MethodSignature (org.aspectj.lang.reflect.MethodSignature)1 ConditionalTest (org.talend.dataprep.async.conditional.ConditionalTest)1