File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed
src/main/java/io/avaje/inject/core Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change 29
29
<version >1</version >
30
30
</dependency >
31
31
32
- <dependency >
33
- <groupId >javax.annotation</groupId >
34
- <artifactId >javax.annotation-api</artifactId >
35
- <version >1.3.2</version >
36
- </dependency >
37
-
38
32
<dependency >
39
33
<groupId >org.slf4j</groupId >
40
34
<artifactId >slf4j-api</artifactId >
Original file line number Diff line number Diff line change 5
5
import org .slf4j .Logger ;
6
6
import org .slf4j .LoggerFactory ;
7
7
8
- import javax . annotation .Priority ;
8
+ import java . lang . annotation .Annotation ;
9
9
import java .util .ArrayList ;
10
10
import java .util .Collections ;
11
11
import java .util .List ;
@@ -233,10 +233,21 @@ private static class SortBean<T> implements Comparable<SortBean<T>> {
233
233
}
234
234
235
235
int initPriority () {
236
- final Priority ann = bean .getClass ().getAnnotation (Priority .class );
237
- if (ann != null ) {
238
- priorityDefined = true ;
239
- return ann .value ();
236
+ // Avoid adding hard dependency on annotation-api by using reflection
237
+ for (Annotation ann : bean .getClass ().getAnnotations ()) {
238
+ Class <? extends Annotation > type = ann .annotationType ();
239
+ String name = type .getName ();
240
+ if (!"javax.annotation.Priority" .equals (name )) {
241
+ continue ;
242
+ }
243
+ try {
244
+ int priority = (Integer ) type .getMethod ("value" ).invoke (ann );
245
+ priorityDefined = true ;
246
+ return priority ;
247
+ } catch (ReflectiveOperationException | SecurityException | IllegalArgumentException | ExceptionInInitializerError | ClassCastException e ) {
248
+ // If this happens, something has gone very wrong...
249
+ throw new UnsupportedOperationException (e );
250
+ }
240
251
}
241
252
// Default priority as per javax.ws.rs.Priorities.USER
242
253
// User-level filter/interceptor priority
You can’t perform that action at this time.
0 commit comments