public Object makeAsynchronous()

in src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/AsynchronousAspect.java [44:78]


    public Object makeAsynchronous(ProceedingJoinPoint pjp, Asynchronous asynchronousAnnotation) throws Throwable {
        final Signature signature = pjp.getStaticPart().getSignature();
        if (signature instanceof MethodSignature) {
            final MethodSignature methodSignature = (MethodSignature) signature;
            int i = 0;
            Object[] methodArguments = pjp.getArgs();
            Annotation[][] parameterAnnotations = methodSignature.getMethod().getParameterAnnotations();
            List<Promise> valueParams = new ArrayList<Promise>();
            for (final Class<?> parameterType : methodSignature.getParameterTypes()) {
                if ((isPromise(parameterType) || isPromiseArray(parameterType) || (isCollection(parameterType) && hasWaitAnnotation(parameterAnnotations[i])))
                        && !hasNoWaitAnnotation(parameterAnnotations[i])) {
                    Object param = methodArguments[i];
                    if (isPromise(parameterType)) {
                        valueParams.add((Promise) param);
                    }
                    else if (isCollection(parameterType)) {
                        valueParams.add(new AndPromise((Collection) param));
                    }
                    else {
                        valueParams.add(new AndPromise((Promise[]) param));
                    }
                } else {
                    valueParams.add(null);
                }
                i++;
            }

            Promise[] values = valueParams.toArray(new Promise[0]);
            Boolean daemon = asynchronousAnnotation.daemon() ? true : null;
            AsynchronousAspectTask task = new AsynchronousAspectTask(daemon, pjp, values);
            return task.getReturnValue();
        }

        return pjp.proceed();
    }