|
19 | 19 | import io.micronaut.aop.MethodInterceptor;
|
20 | 20 | import io.micronaut.aop.MethodInvocationContext;
|
21 | 21 | import io.micronaut.context.BeanContext;
|
| 22 | +import io.micronaut.core.annotation.AnnotationValue; |
22 | 23 | import io.micronaut.core.annotation.Internal;
|
23 | 24 | import io.micronaut.core.annotation.Nullable;
|
24 | 25 | import io.micronaut.core.util.StringUtils;
|
@@ -49,19 +50,22 @@ final class AdapterIntroduction implements MethodInterceptor<Object, Object> {
|
49 | 50 | * @param method The target method
|
50 | 51 | */
|
51 | 52 | AdapterIntroduction(BeanContext beanContext, ExecutableMethod<?, ?> method) {
|
52 |
| - Class<?> beanType = method.classValue(Adapter.class, ADAPTED_BEAN).orElse(null); |
53 |
| - |
| 53 | + AnnotationValue<Adapter> adapterAnnotationValue = method.getAnnotation(Adapter.class); |
| 54 | + if (adapterAnnotationValue == null) { |
| 55 | + throw new IllegalStateException("Adapter method must have @Adapter annotation"); |
| 56 | + } |
| 57 | + Class<?> beanType = adapterAnnotationValue.classValue(ADAPTED_BEAN).orElse(null); |
54 | 58 | if (beanType == null) {
|
55 | 59 | throw new IllegalStateException("No bean type to adapt found in Adapter configuration for method: " + method);
|
56 | 60 | }
|
57 | 61 |
|
58 |
| - String beanMethod = method.stringValue(Adapter.class, ADAPTED_METHOD).orElse(null); |
| 62 | + String beanMethod = adapterAnnotationValue.stringValue(ADAPTED_METHOD).orElse(null); |
59 | 63 | if (StringUtils.isEmpty(beanMethod)) {
|
60 | 64 | throw new IllegalStateException("No bean method to adapt found in Adapter configuration for method: " + method);
|
61 | 65 | }
|
62 | 66 |
|
63 |
| - String beanQualifier = method.stringValue(Adapter.class, ADAPTED_QUALIFIER).orElse(null); |
64 |
| - Class<?>[] argumentTypes = method.classValues(Adapter.class, ADAPTED_ARGUMENT_TYPES); |
| 67 | + String beanQualifier = adapterAnnotationValue.stringValue(ADAPTED_QUALIFIER).orElse(null); |
| 68 | + Class<?>[] argumentTypes = adapterAnnotationValue.classValues(ADAPTED_ARGUMENT_TYPES); |
65 | 69 | Class<?>[] methodArgumentTypes = method.getArgumentTypes();
|
66 | 70 | Class<?>[] arguments = argumentTypes.length == methodArgumentTypes.length ? argumentTypes : methodArgumentTypes;
|
67 | 71 | if (StringUtils.isNotEmpty(beanQualifier)) {
|
|
0 commit comments