File tree Expand file tree Collapse file tree 2 files changed +17
-11
lines changed
src/main/java/io/avaje/inject/core Expand file tree Collapse file tree 2 files changed +17
-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
+ import java .lang .reflect .InvocationTargetException ;
9
10
import java .util .ArrayList ;
10
11
import java .util .Collections ;
11
12
import java .util .List ;
@@ -233,10 +234,21 @@ private static class SortBean<T> implements Comparable<SortBean<T>> {
233
234
}
234
235
235
236
int initPriority () {
236
- final Priority ann = bean .getClass ().getAnnotation (Priority .class );
237
- if (ann != null ) {
238
- priorityDefined = true ;
239
- return ann .value ();
237
+ // Avoid adding hard dependency on annotation-api by using reflection
238
+ for (Annotation ann : bean .getClass ().getAnnotations ()) {
239
+ Class <? extends Annotation > type = ann .annotationType ();
240
+ String name = type .getName ();
241
+ if (!"javax.annotation.Priority" .equals (name )) {
242
+ continue ;
243
+ }
244
+ try {
245
+ int priority = (Integer ) type .getMethod ("value" ).invoke (ann );
246
+ priorityDefined = true ;
247
+ return priority ;
248
+ } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | ExceptionInInitializerError | ClassCastException e ) {
249
+ // If this happens, something has gone very wrong...
250
+ throw new UnsupportedOperationException (e );
251
+ }
240
252
}
241
253
// Default priority as per javax.ws.rs.Priorities.USER
242
254
// User-level filter/interceptor priority
You can’t perform that action at this time.
0 commit comments