/** * A map from exception classes to a threshold value of type Integer. * * @param thresholds the threshold value map. */ public void setThresholds(Map<Class<? extends Throwable>, Integer> thresholds) { Map<Class<? extends Throwable>, IntegerHolder> typeMap = new HashMap<>(); for (Entry<Class<? extends Throwable>, Integer> entry : thresholds.entrySet()) { typeMap.put(entry.getKey(), new IntegerHolder(entry.getValue())); } exceptionClassifier = new SubclassClassifier<>(typeMap, ZERO); }
/** * Setter for policy map used to create a classifier. Either this property * or the exception classifier directly should be set, but not both. * * @param policyMap a map of Throwable class to {@link RetryPolicy} that * will be used to create a {@link Classifier} to locate a policy. */ public void setPolicyMap(Map<Class<? extends Throwable>, RetryPolicy> policyMap) { this.exceptionClassifier = new SubclassClassifier<Throwable, RetryPolicy>(policyMap, new NeverRetryPolicy()); }
/** * Setter for policy map. This property should not be changed dynamically - * set it once, e.g. in configuration, and then don't change it during a * running application. Either this property or the exception classifier * directly should be set, but not both. * * @param policyMap a map of String to {@link SkipPolicy} that will be used * to create a {@link Classifier} to locate a policy. */ public void setPolicyMap(Map<Class<? extends Throwable>, SkipPolicy> policyMap) { SubclassClassifier<Throwable, SkipPolicy> subclassClassifier = new SubclassClassifier<>( policyMap, new NeverSkipItemSkipPolicy()); this.classifier = subclassClassifier; }
/** * Wrap the provided {@link org.springframework.retry.RetryPolicy} so that it never retries explicitly non-retryable * exceptions. */ private RetryPolicy getFatalExceptionAwareProxy(RetryPolicy retryPolicy) { NeverRetryPolicy neverRetryPolicy = new NeverRetryPolicy(); Map<Class<? extends Throwable>, RetryPolicy> map = new HashMap<>(); for (Class<? extends Throwable> fatal : nonRetryableExceptionClasses) { map.put(fatal, neverRetryPolicy); } SubclassClassifier<Throwable, RetryPolicy> classifier = new SubclassClassifier<>( retryPolicy); classifier.setTypeMap(map); ExceptionClassifierRetryPolicy retryPolicyWrapper = new ExceptionClassifierRetryPolicy(); retryPolicyWrapper.setExceptionClassifier(classifier); return retryPolicyWrapper; }
/** * Wrap a {@link SkipPolicy} and make it consistent with known fatal exceptions. * * @param skipPolicy an existing skip policy * @return a skip policy that will not skip fatal exceptions */ protected SkipPolicy getFatalExceptionAwareProxy(SkipPolicy skipPolicy) { NeverSkipItemSkipPolicy neverSkipPolicy = new NeverSkipItemSkipPolicy(); Map<Class<? extends Throwable>, SkipPolicy> map = new HashMap<>(); for (Class<? extends Throwable> fatal : nonSkippableExceptionClasses) { map.put(fatal, neverSkipPolicy); } SubclassClassifier<Throwable, SkipPolicy> classifier = new SubclassClassifier<>(skipPolicy); classifier.setTypeMap(map); ExceptionClassifierSkipPolicy skipPolicyWrapper = new ExceptionClassifierSkipPolicy(); skipPolicyWrapper.setExceptionClassifier(classifier); return skipPolicyWrapper; }
new SubclassClassifier<>(); Map<Class<? extends Number>, ItemProcessor<?, ? extends CharSequence>> typeMap = new HashMap<>();
/** * A map from exception classes to a threshold value of type Integer. * * @param thresholds the threshold value map. */ public void setThresholds(Map<Class<? extends Throwable>, Integer> thresholds) { Map<Class<? extends Throwable>, IntegerHolder> typeMap = new HashMap<Class<? extends Throwable>, IntegerHolder>(); for (Entry<Class<? extends Throwable>, Integer> entry : thresholds.entrySet()) { typeMap.put(entry.getKey(), new IntegerHolder(entry.getValue())); } exceptionClassifier = new SubclassClassifier<>(typeMap, ZERO); }
/** * Setter for policy map used to create a classifier. Either this property * or the exception classifier directly should be set, but not both. * * @param policyMap a map of Throwable class to {@link RetryPolicy} that * will be used to create a {@link Classifier} to locate a policy. */ public void setPolicyMap(Map<Class<? extends Throwable>, RetryPolicy> policyMap) { this.exceptionClassifier = new SubclassClassifier<Throwable, RetryPolicy>(policyMap, new NeverRetryPolicy()); }
/** * Setter for policy map. This property should not be changed dynamically - * set it once, e.g. in configuration, and then don't change it during a * running application. Either this property or the exception classifier * directly should be set, but not both. * * @param policyMap a map of String to {@link SkipPolicy} that will be used * to create a {@link Classifier} to locate a policy. */ public void setPolicyMap(Map<Class<? extends Throwable>, SkipPolicy> policyMap) { SubclassClassifier<Throwable, SkipPolicy> subclassClassifier = new SubclassClassifier<Throwable, SkipPolicy>( policyMap, new NeverSkipItemSkipPolicy()); this.classifier = subclassClassifier; }
/** * Setter for policy map. This property should not be changed dynamically - * set it once, e.g. in configuration, and then don't change it during a * running application. Either this property or the exception classifier * directly should be set, but not both. * * @param policyMap a map of String to {@link SkipPolicy} that will be used * to create a {@link Classifier} to locate a policy. */ public void setPolicyMap(Map<Class<? extends Throwable>, SkipPolicy> policyMap) { SubclassClassifier<Throwable, SkipPolicy> subclassClassifier = new SubclassClassifier<Throwable, SkipPolicy>( policyMap, new NeverSkipItemSkipPolicy()); this.classifier = subclassClassifier; }
/** * Setter for policy map. This property should not be changed dynamically - * set it once, e.g. in configuration, and then don't change it during a * running application. Either this property or the exception classifier * directly should be set, but not both. * * @param policyMap a map of String to {@link SkipPolicy} that will be used * to create a {@link Classifier} to locate a policy. */ public void setPolicyMap(Map<Class<? extends Throwable>, SkipPolicy> policyMap) { SubclassClassifier<Throwable, SkipPolicy> subclassClassifier = new SubclassClassifier<Throwable, SkipPolicy>( policyMap, new NeverSkipItemSkipPolicy()); this.classifier = subclassClassifier; }
/** * Wrap a {@link SkipPolicy} and make it consistent with known fatal exceptions. * * @param skipPolicy an existing skip policy * @return a skip policy that will not skip fatal exceptions */ protected SkipPolicy getFatalExceptionAwareProxy(SkipPolicy skipPolicy) { NeverSkipItemSkipPolicy neverSkipPolicy = new NeverSkipItemSkipPolicy(); Map<Class<? extends Throwable>, SkipPolicy> map = new HashMap<Class<? extends Throwable>, SkipPolicy>(); for (Class<? extends Throwable> fatal : nonSkippableExceptionClasses) { map.put(fatal, neverSkipPolicy); } SubclassClassifier<Throwable, SkipPolicy> classifier = new SubclassClassifier<Throwable, SkipPolicy>(skipPolicy); classifier.setTypeMap(map); ExceptionClassifierSkipPolicy skipPolicyWrapper = new ExceptionClassifierSkipPolicy(); skipPolicyWrapper.setExceptionClassifier(classifier); return skipPolicyWrapper; }
/** * Wrap the provided {@link org.springframework.retry.RetryPolicy} so that it never retries explicitly non-retryable * exceptions. */ private RetryPolicy getFatalExceptionAwareProxy(RetryPolicy retryPolicy) { NeverRetryPolicy neverRetryPolicy = new NeverRetryPolicy(); Map<Class<? extends Throwable>, RetryPolicy> map = new HashMap<Class<? extends Throwable>, RetryPolicy>(); for (Class<? extends Throwable> fatal : nonRetryableExceptionClasses) { map.put(fatal, neverRetryPolicy); } SubclassClassifier<Throwable, RetryPolicy> classifier = new SubclassClassifier<Throwable, RetryPolicy>( retryPolicy); classifier.setTypeMap(map); ExceptionClassifierRetryPolicy retryPolicyWrapper = new ExceptionClassifierRetryPolicy(); retryPolicyWrapper.setExceptionClassifier(classifier); return retryPolicyWrapper; }
/** * Wrap the provided {@link org.springframework.retry.RetryPolicy} so that it never retries explicitly non-retryable * exceptions. */ private RetryPolicy getFatalExceptionAwareProxy(RetryPolicy retryPolicy) { NeverRetryPolicy neverRetryPolicy = new NeverRetryPolicy(); Map<Class<? extends Throwable>, RetryPolicy> map = new HashMap<Class<? extends Throwable>, RetryPolicy>(); for (Class<? extends Throwable> fatal : nonRetryableExceptionClasses) { map.put(fatal, neverRetryPolicy); } SubclassClassifier<Throwable, RetryPolicy> classifier = new SubclassClassifier<Throwable, RetryPolicy>( retryPolicy); classifier.setTypeMap(map); ExceptionClassifierRetryPolicy retryPolicyWrapper = new ExceptionClassifierRetryPolicy(); retryPolicyWrapper.setExceptionClassifier(classifier); return retryPolicyWrapper; }
/** * Wrap a {@link SkipPolicy} and make it consistent with known fatal exceptions. * * @param skipPolicy an existing skip policy * @return a skip policy that will not skip fatal exceptions */ protected SkipPolicy getFatalExceptionAwareProxy(SkipPolicy skipPolicy) { NeverSkipItemSkipPolicy neverSkipPolicy = new NeverSkipItemSkipPolicy(); Map<Class<? extends Throwable>, SkipPolicy> map = new HashMap<Class<? extends Throwable>, SkipPolicy>(); for (Class<? extends Throwable> fatal : nonSkippableExceptionClasses) { map.put(fatal, neverSkipPolicy); } SubclassClassifier<Throwable, SkipPolicy> classifier = new SubclassClassifier<Throwable, SkipPolicy>(skipPolicy); classifier.setTypeMap(map); ExceptionClassifierSkipPolicy skipPolicyWrapper = new ExceptionClassifierSkipPolicy(); skipPolicyWrapper.setExceptionClassifier(classifier); return skipPolicyWrapper; }
/** * Wrap a {@link SkipPolicy} and make it consistent with known fatal exceptions. * * @param skipPolicy an existing skip policy * @return a skip policy that will not skip fatal exceptions */ protected SkipPolicy getFatalExceptionAwareProxy(SkipPolicy skipPolicy) { NeverSkipItemSkipPolicy neverSkipPolicy = new NeverSkipItemSkipPolicy(); Map<Class<? extends Throwable>, SkipPolicy> map = new HashMap<Class<? extends Throwable>, SkipPolicy>(); for (Class<? extends Throwable> fatal : nonSkippableExceptionClasses) { map.put(fatal, neverSkipPolicy); } SubclassClassifier<Throwable, SkipPolicy> classifier = new SubclassClassifier<Throwable, SkipPolicy>(skipPolicy); classifier.setTypeMap(map); ExceptionClassifierSkipPolicy skipPolicyWrapper = new ExceptionClassifierSkipPolicy(); skipPolicyWrapper.setExceptionClassifier(classifier); return skipPolicyWrapper; }
/** * Wrap the provided {@link org.springframework.retry.RetryPolicy} so that it never retries explicitly non-retryable * exceptions. */ private RetryPolicy getFatalExceptionAwareProxy(RetryPolicy retryPolicy) { NeverRetryPolicy neverRetryPolicy = new NeverRetryPolicy(); Map<Class<? extends Throwable>, RetryPolicy> map = new HashMap<Class<? extends Throwable>, RetryPolicy>(); for (Class<? extends Throwable> fatal : nonRetryableExceptionClasses) { map.put(fatal, neverRetryPolicy); } SubclassClassifier<Throwable, RetryPolicy> classifier = new SubclassClassifier<Throwable, RetryPolicy>( retryPolicy); classifier.setTypeMap(map); ExceptionClassifierRetryPolicy retryPolicyWrapper = new ExceptionClassifierRetryPolicy(); retryPolicyWrapper.setExceptionClassifier(classifier); return retryPolicyWrapper; }
Map<Class<? extends Throwable>, Boolean> typeMap = new HashMap<>(); typeMap.put(JobInterruptedException.class, true); rollbackClassifier = new SubclassClassifier<Throwable, Boolean>(typeMap, false); newChunkProvider.setRollbackClassifier(rollbackClassifier); newChunkProvider.setSkipPolicy(skipPolicy);