Skip to content

Commit 5c1c7bf

Browse files
committed
1 parent 2584831 commit 5c1c7bf

File tree

6 files changed

+38
-6
lines changed

6 files changed

+38
-6
lines changed

projects/stage-1/middleware-frameworks/my-fault-tolerance/src/main/java/org/geektimes/microprofile/faulttolerance/AsynchronousInterceptor.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@
2121
import org.geektimes.commons.function.ThrowableSupplier;
2222
import org.geektimes.interceptor.AnnotatedInterceptor;
2323

24+
import javax.annotation.Priority;
2425
import javax.interceptor.Interceptor;
2526
import javax.interceptor.InvocationContext;
2627
import java.lang.reflect.Method;
2728
import java.util.concurrent.*;
2829

2930
import static java.util.concurrent.CompletableFuture.supplyAsync;
31+
import static org.geektimes.microprofile.faulttolerance.AsynchronousInterceptor.ASYNCHRONOUS_PRIORITY;
32+
import static org.geektimes.microprofile.faulttolerance.TimeoutInterceptor.TIMEOUT_PRIORITY;
3033

3134
/**
3235
* The interceptor implementation for the annotation {@link Asynchronous} of
@@ -37,14 +40,16 @@
3740
*/
3841
@Asynchronous
3942
@Interceptor
43+
@Priority(ASYNCHRONOUS_PRIORITY)
4044
public class AsynchronousInterceptor extends AnnotatedInterceptor<Asynchronous> {
4145

46+
public static final int ASYNCHRONOUS_PRIORITY = TIMEOUT_PRIORITY + 100;
47+
4248
// TODO ExecutorService fixed size = external Server Thread numbers
4349
private final ExecutorService executor = ForkJoinPool.commonPool();
4450

4551
public AsynchronousInterceptor() {
4652
super();
47-
setPriority(500);
4853
}
4954

5055
@Override

projects/stage-1/middleware-frameworks/my-fault-tolerance/src/main/java/org/geektimes/microprofile/faulttolerance/BulkheadInterceptor.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@
2121
import org.eclipse.microprofile.faulttolerance.exceptions.BulkheadException;
2222
import org.geektimes.interceptor.AnnotatedInterceptor;
2323

24+
import javax.annotation.Priority;
2425
import javax.interceptor.Interceptor;
2526
import javax.interceptor.InvocationContext;
2627
import java.lang.reflect.Method;
2728
import java.util.concurrent.*;
2829
import java.util.concurrent.atomic.AtomicInteger;
2930

3031
import static java.lang.String.format;
32+
import static org.geektimes.microprofile.faulttolerance.BulkheadInterceptor.BULKHEAD_PRIORITY;
33+
import static org.geektimes.microprofile.faulttolerance.CircuitBreakerInterceptor.CIRCUIT_BREAKER_PRIORITY;
3134

3235
/**
3336
* The interceptor implementation for the annotation {@link Bulkhead} of
@@ -38,15 +41,17 @@
3841
*/
3942
@Bulkhead
4043
@Interceptor
44+
@Priority(BULKHEAD_PRIORITY)
4145
public class BulkheadInterceptor extends AnnotatedInterceptor<Bulkhead> {
4246

47+
public static final int BULKHEAD_PRIORITY = CIRCUIT_BREAKER_PRIORITY + 100;
48+
4349
private final ConcurrentMap<Bulkhead, ExecutorService> executorsCache = new ConcurrentHashMap<>();
4450

4551
private final ConcurrentHashMap<Bulkhead, Semaphore> semaphoresCache = new ConcurrentHashMap<>();
4652

4753
public BulkheadInterceptor() {
4854
super();
49-
setPriority(100);
5055
}
5156

5257
@Override

projects/stage-1/middleware-frameworks/my-fault-tolerance/src/main/java/org/geektimes/microprofile/faulttolerance/CircuitBreakerInterceptor.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.geektimes.commons.util.TimeUtils;
2222
import org.geektimes.interceptor.AnnotatedInterceptor;
2323

24+
import javax.annotation.Priority;
2425
import javax.interceptor.Interceptor;
2526
import javax.interceptor.InvocationContext;
2627
import java.util.Arrays;
@@ -29,7 +30,9 @@
2930
import java.util.concurrent.TimeUnit;
3031
import java.util.concurrent.atomic.LongAdder;
3132

33+
import static javax.interceptor.Interceptor.Priority.LIBRARY_BEFORE;
3234
import static org.geektimes.commons.reflect.util.ClassUtils.isDerived;
35+
import static org.geektimes.microprofile.faulttolerance.CircuitBreakerInterceptor.CIRCUIT_BREAKER_PRIORITY;
3336

3437
/**
3538
* The interceptor implementation for the annotation {@link CircuitBreaker} of
@@ -40,13 +43,15 @@
4043
*/
4144
@CircuitBreaker
4245
@Interceptor
46+
@Priority(CIRCUIT_BREAKER_PRIORITY)
4347
public class CircuitBreakerInterceptor extends AnnotatedInterceptor<CircuitBreaker> {
4448

49+
public static final int CIRCUIT_BREAKER_PRIORITY = LIBRARY_BEFORE + 100;
50+
4551
private final ConcurrentMap<CircuitBreaker, CountableSlidingWindow> slidingWindowsCache = new ConcurrentHashMap<>();
4652

4753
public CircuitBreakerInterceptor() {
4854
super();
49-
setPriority(0);
5055
}
5156

5257
@Override

projects/stage-1/middleware-frameworks/my-fault-tolerance/src/main/java/org/geektimes/microprofile/faulttolerance/FallbackInterceptor.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@
2222
import org.eclipse.microprofile.faulttolerance.exceptions.FaultToleranceDefinitionException;
2323
import org.geektimes.interceptor.AnnotatedInterceptor;
2424

25+
import javax.annotation.Priority;
2526
import javax.interceptor.Interceptor;
2627
import javax.interceptor.InvocationContext;
2728
import java.lang.reflect.Method;
2829

2930
import static java.lang.String.format;
3031
import static org.geektimes.commons.reflect.util.ClassUtils.getTypes;
3132
import static org.geektimes.commons.reflect.util.ClassUtils.isDerived;
33+
import static org.geektimes.microprofile.faulttolerance.BulkheadInterceptor.BULKHEAD_PRIORITY;
34+
import static org.geektimes.microprofile.faulttolerance.FallbackInterceptor.FALLBACK_PRIORITY;
3235

3336
/**
3437
* The interceptor implementation for the annotation {@link Fallback} of
@@ -38,11 +41,13 @@
3841
* @since 1.0.0
3942
*/
4043
@Interceptor
44+
@Priority(FALLBACK_PRIORITY)
4145
public class FallbackInterceptor extends AnnotatedInterceptor<Fallback> {
4246

47+
public static final int FALLBACK_PRIORITY = BULKHEAD_PRIORITY + 100;
48+
4349
public FallbackInterceptor() {
4450
super();
45-
setPriority(200);
4651
}
4752

4853
@Override

projects/stage-1/middleware-frameworks/my-fault-tolerance/src/main/java/org/geektimes/microprofile/faulttolerance/RetryInterceptor.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.eclipse.microprofile.faulttolerance.Retry;
2020
import org.geektimes.interceptor.AnnotatedInterceptor;
2121

22+
import javax.annotation.Priority;
2223
import javax.interceptor.Interceptor;
2324
import javax.interceptor.InvocationContext;
2425
import java.util.Optional;
@@ -28,8 +29,12 @@
2829
import static java.util.Optional.empty;
2930
import static java.util.Optional.of;
3031
import static java.util.concurrent.Executors.newScheduledThreadPool;
32+
import static javax.interceptor.Interceptor.Priority.LIBRARY_BEFORE;
3133
import static org.geektimes.commons.reflect.util.ClassUtils.isDerived;
3234
import static org.geektimes.commons.util.TimeUtils.toTimeUnit;
35+
import static org.geektimes.microprofile.faulttolerance.BulkheadInterceptor.BULKHEAD_PRIORITY;
36+
import static org.geektimes.microprofile.faulttolerance.FallbackInterceptor.FALLBACK_PRIORITY;
37+
import static org.geektimes.microprofile.faulttolerance.RetryInterceptor.RETRY_PRIORITY;
3338

3439
/**
3540
* The interceptor implementation for the annotation {@link Retry} of
@@ -40,14 +45,16 @@
4045
*/
4146
@Retry
4247
@Interceptor
48+
@Priority(RETRY_PRIORITY)
4349
public class RetryInterceptor extends AnnotatedInterceptor<Retry> {
4450

51+
public static final int RETRY_PRIORITY = FALLBACK_PRIORITY + 100;
52+
4553
private final ScheduledExecutorService executorService = newScheduledThreadPool(2);
4654

4755

4856
public RetryInterceptor() {
4957
super();
50-
setPriority(300);
5158
}
5259

5360
@Override

projects/stage-1/middleware-frameworks/my-fault-tolerance/src/main/java/org/geektimes/microprofile/faulttolerance/TimeoutInterceptor.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
import org.eclipse.microprofile.faulttolerance.Timeout;
2020
import org.geektimes.interceptor.AnnotatedInterceptor;
2121

22+
import javax.annotation.Priority;
2223
import javax.interceptor.Interceptor;
2324
import javax.interceptor.InvocationContext;
2425
import java.time.temporal.ChronoUnit;
2526
import java.util.concurrent.*;
2627

2728
import static org.geektimes.commons.util.TimeUtils.toTimeUnit;
29+
import static org.geektimes.microprofile.faulttolerance.RetryInterceptor.RETRY_PRIORITY;
30+
import static org.geektimes.microprofile.faulttolerance.TimeoutInterceptor.TIMEOUT_PRIORITY;
2831

2932
/**
3033
* The interceptor implementation for the annotation {@link Timeout} of
@@ -35,14 +38,16 @@
3538
*/
3639
@Timeout
3740
@Interceptor
41+
@Priority(TIMEOUT_PRIORITY)
3842
public class TimeoutInterceptor extends AnnotatedInterceptor<Timeout> {
3943

44+
public static final int TIMEOUT_PRIORITY = RETRY_PRIORITY + 100;
45+
4046
// TODO ExecutorService fixed size = external Server Thread numbers
4147
private final ExecutorService executor = ForkJoinPool.commonPool();
4248

4349
public TimeoutInterceptor() {
4450
super();
45-
setPriority(400);
4651
}
4752

4853
@Override

0 commit comments

Comments
 (0)