Search in sources :

Example 1 with AsyncGroupKey

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

the class AnnotationGroupIdGenerator method getGroupId.

/**
 * @see GroupIdGenerator#getGroupId(ProceedingJoinPoint)
 */
@Override
public String getGroupId(ProceedingJoinPoint pjp) {
    // look for the @AsyncGroupId annotated parameter
    int idParameterIndex = AnnotationUtils.getAnnotatedParameterIndex(pjp, AsyncGroupId.class);
    // to get the @AsyncGroupId parameter value
    final String asyncGroupId;
    if (idParameterIndex >= 0) {
        MethodSignature ms = (MethodSignature) pjp.getSignature();
        final Class groupIdParameterType = ms.getParameterTypes()[idParameterIndex];
        if (AsyncGroupKey.class.isAssignableFrom(groupIdParameterType)) {
            final AsyncGroupKey paramValue = (AsyncGroupKey) pjp.getArgs()[idParameterIndex];
            asyncGroupId = paramValue.getAsyncGroupKey();
        } else {
            asyncGroupId = String.valueOf(pjp.getArgs()[idParameterIndex]);
        }
    } else {
        asyncGroupId = null;
    }
    return asyncGroupId;
}
Also used : MethodSignature(org.aspectj.lang.reflect.MethodSignature) AsyncGroupKey(org.talend.dataprep.async.AsyncGroupKey) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint)

Aggregations

ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)1 MethodSignature (org.aspectj.lang.reflect.MethodSignature)1 AsyncGroupKey (org.talend.dataprep.async.AsyncGroupKey)1