private AggregatedFTPolicy processPolicies(InvocationContext context, BeanManager beanManager) {
        AsynchronousConfig asynchronous = null;
        RetryConfig retry = null;
        CircuitBreakerConfig circuitBreaker = null;
        TimeoutConfig timeout = null;
        BulkheadConfig bulkhead = null;
        FallbackConfig fallback = null;
        FTEnablementConfig enablement = FaultToleranceCDIComponent.getEnablementConfig();
        AnnotationConfigFactory annotationConfigFactory = FaultToleranceCDIExtension.getAnnotationConfigFactory();

        //first check the annotations on the target class
        Class<?> targetClass = context.getTarget().getClass();
        Annotation[] annotations = targetClass.getAnnotations();
        for (Annotation annotation : annotations) {

            //Check that the annotation has not been disabled for this specific class.
            if (enablement.isFaultTolerance(annotation) && enablement.isAnnotationEnabled(annotation, targetClass)) {

                if (annotation.annotationType().equals(Asynchronous.class)) {
                    asynchronous = annotationConfigFactory.createAsynchronousConfig(targetClass, (Asynchronous) annotation);
                    asynchronous.validate();
                } else if (annotation.annotationType().equals(Retry.class)) {
                    retry = new RetryConfig(targetClass, (Retry) annotation);
                    retry.validate();
                } else if (annotation.annotationType().equals(CircuitBreaker.class)) {
                    circuitBreaker = new CircuitBreakerConfig(targetClass, (CircuitBreaker) annotation);
                    circuitBreaker.validate();
                } else if (annotation.annotationType().equals(Timeout.class)) {
                    timeout = new TimeoutConfig(targetClass, (Timeout) annotation);
                    timeout.validate();
                } else if (annotation.annotationType().equals(Bulkhead.class)) {
                    bulkhead = new BulkheadConfig(targetClass, (Bulkhead) annotation);
                    bulkhead.validate();
                }
            }
        }

        //then look for annotations on the specific method
        //method level annotations override class level ones
        Method method = context.getMethod();
        annotations = method.getAnnotations();
        for (Annotation annotation : annotations) {

            //Check that the annotation has not been disabled for this specific method.
            if (enablement.isFaultTolerance(annotation) && enablement.isAnnotationEnabled(annotation, targetClass, method)) {

                if (annotation.annotationType().equals(Asynchronous.class)) {
                    asynchronous = annotationConfigFactory.createAsynchronousConfig(method, targetClass, (Asynchronous) annotation);
                    asynchronous.validate();
                } else if (annotation.annotationType().equals(Retry.class)) {
                    retry = new RetryConfig(method, targetClass, (Retry) annotation);
                    retry.validate();
                } else if (annotation.annotationType().equals(CircuitBreaker.class)) {
                    circuitBreaker = new CircuitBreakerConfig(method, targetClass, (CircuitBreaker) annotation);
                    circuitBreaker.validate();
                } else if (annotation.annotationType().equals(Timeout.class)) {
                    timeout = new TimeoutConfig(method, targetClass, (Timeout) annotation);
                    timeout.validate();
                } else if (annotation.annotationType().equals(Bulkhead.class)) {
                    bulkhead = new BulkheadConfig(method, targetClass, (Bulkhead) annotation);
                    bulkhead.validate();
                } else if (annotation.annotationType().equals(Fallback.class)) {
                    fallback = new FallbackConfig(method, targetClass, (Fallback) annotation);
                    fallback.validate();
                }
            }
        }

        AggregatedFTPolicy aggregatedFTPolicy = new AggregatedFTPolicy();

        aggregatedFTPolicy.setMethod(method);

        if (asynchronous != null) {
            aggregatedFTPolicy.setAsynchronousResultWrapper(method.getReturnType());
        }

        //generate the TimeoutPolicy
        if (timeout != null) {
            TimeoutPolicy timeoutPolicy = timeout.generatePolicy();
            aggregatedFTPolicy.setTimeoutPolicy(timeoutPolicy);
        }

        //generate the RetryPolicy
        if (retry != null) {
            RetryPolicy retryPolicy = retry.generatePolicy();
            aggregatedFTPolicy.setRetryPolicy(retryPolicy);
        }

        //generate the CircuitBreakerPolicy
        if (circuitBreaker != null) {
            CircuitBreakerPolicy circuitBreakerPolicy = circuitBreaker.generatePolicy();
            aggregatedFTPolicy.setCircuitBreakerPolicy(circuitBreakerPolicy);
        }

        //generate the BulkheadPolicy
        if (bulkhead != null) {
            BulkheadPolicy bulkheadPolicy = bulkhead.generatePolicy();
            aggregatedFTPolicy.setBulkheadPolicy(bulkheadPolicy);
        }

        //generate the FallbackPolicy
        if (fallback != null) {
            FallbackPolicy fallbackPolicy = fallback.generatePolicy(context, beanManager);
            aggregatedFTPolicy.setFallbackPolicy(fallbackPolicy);
        }

        return aggregatedFTPolicy;
    }
private AggregatedFTPolicy processPolicies ( InvocationContext context , BeanManager beanManager ) { AsynchronousConfig asynchronous = null ; RetryConfig retry = null ; CircuitBreakerConfig circuitBreaker = null ; TimeoutConfig timeout = null ; BulkheadConfig bulkhead = null ; FallbackConfig fallback = null ; FTEnablementConfig enablement = FaultToleranceCDIComponent . getEnablementConfig ( ) ; AnnotationConfigFactory annotationConfigFactory = FaultToleranceCDIExtension . getAnnotationConfigFactory ( ) ; Class < ? > targetClass = context . getTarget ( ) . getClass ( ) ; Annotation [ ] annotations = targetClass . getAnnotations ( ) ; for ( Annotation annotation : annotations ) { if ( enablement . isFaultTolerance ( annotation ) && enablement . isAnnotationEnabled ( annotation , targetClass ) ) { if ( annotation . annotationType ( ) . equals ( Asynchronous . class ) ) { asynchronous = annotationConfigFactory . createAsynchronousConfig ( targetClass , ( Asynchronous ) annotation ) ; asynchronous . validate ( ) ; } else if ( annotation . annotationType ( ) . equals ( Retry . class ) ) { retry = new RetryConfig ( targetClass , ( Retry ) annotation ) ; retry . validate ( ) ; } else if ( annotation . annotationType ( ) . equals ( CircuitBreaker . class ) ) { circuitBreaker = new CircuitBreakerConfig ( targetClass , ( CircuitBreaker ) annotation ) ; circuitBreaker . validate ( ) ; } else if ( annotation . annotationType ( ) . equals ( Timeout . class ) ) { timeout = new TimeoutConfig ( targetClass , ( Timeout ) annotation ) ; timeout . validate ( ) ; } else if ( annotation . annotationType ( ) . equals ( Bulkhead . class ) ) { bulkhead = new BulkheadConfig ( targetClass , ( Bulkhead ) annotation ) ; bulkhead . validate ( ) ; } } } Method method = context . getMethod ( ) ; annotations = method . getAnnotations ( ) ; for ( Annotation annotation : annotations ) { if ( enablement . isFaultTolerance ( annotation ) && enablement . isAnnotationEnabled ( annotation , targetClass , method ) ) { if ( annotation . annotationType ( ) . equals ( Asynchronous . class ) ) { asynchronous = annotationConfigFactory . createAsynchronousConfig ( method , targetClass , ( Asynchronous ) annotation ) ; asynchronous . validate ( ) ; } else if ( annotation . annotationType ( ) . equals ( Retry . class ) ) { retry = new RetryConfig ( method , targetClass , ( Retry ) annotation ) ; retry . validate ( ) ; } else if ( annotation . annotationType ( ) . equals ( CircuitBreaker . class ) ) { circuitBreaker = new CircuitBreakerConfig ( method , targetClass , ( CircuitBreaker ) annotation ) ; circuitBreaker . validate ( ) ; } else if ( annotation . annotationType ( ) . equals ( Timeout . class ) ) { timeout = new TimeoutConfig ( method , targetClass , ( Timeout ) annotation ) ; timeout . validate ( ) ; } else if ( annotation . annotationType ( ) . equals ( Bulkhead . class ) ) { bulkhead = new BulkheadConfig ( method , targetClass , ( Bulkhead ) annotation ) ; bulkhead . validate ( ) ; } else if ( annotation . annotationType ( ) . equals ( Fallback . class ) ) { fallback = new FallbackConfig ( method , targetClass , ( Fallback ) annotation ) ; fallback . validate ( ) ; } } } AggregatedFTPolicy aggregatedFTPolicy = new AggregatedFTPolicy ( ) ; aggregatedFTPolicy . setMethod ( method ) ; if ( asynchronous != null ) { aggregatedFTPolicy . setAsynchronousResultWrapper ( method . getReturnType ( ) ) ; } if ( timeout != null ) { TimeoutPolicy timeoutPolicy = timeout . generatePolicy ( ) ; aggregatedFTPolicy . setTimeoutPolicy ( timeoutPolicy ) ; } if ( retry != null ) { RetryPolicy retryPolicy = retry . generatePolicy ( ) ; aggregatedFTPolicy . setRetryPolicy ( retryPolicy ) ; } if ( circuitBreaker != null ) { CircuitBreakerPolicy circuitBreakerPolicy = circuitBreaker . generatePolicy ( ) ; aggregatedFTPolicy . setCircuitBreakerPolicy ( circuitBreakerPolicy ) ; } if ( bulkhead != null ) { BulkheadPolicy bulkheadPolicy = bulkhead . generatePolicy ( ) ; aggregatedFTPolicy . setBulkheadPolicy ( bulkheadPolicy ) ; } if ( fallback != null ) { FallbackPolicy fallbackPolicy = fallback . generatePolicy ( context , beanManager ) ; aggregatedFTPolicy . setFallbackPolicy ( fallbackPolicy ) ; } return aggregatedFTPolicy ; }
@param context
@return