use of io.micronaut.aop.ConstructorInterceptor in project micronaut-core by micronaut-projects.
the class DefaultInterceptorRegistry method resolveInterceptors.
@Override
@NonNull
public <T> Interceptor<T, ?>[] resolveInterceptors(@NonNull Executable<T, ?> method, @NonNull Collection<BeanRegistration<Interceptor<T, ?>>> interceptors, @NonNull InterceptorKind interceptorKind) {
final AnnotationMetadata annotationMetadata = method.getAnnotationMetadata();
if (interceptors.isEmpty()) {
return resolveToNone((ExecutableMethod<?, ?>) method, interceptorKind, annotationMetadata);
} else {
instrumentAnnotationMetadata(beanContext, method);
final Collection<AnnotationValue<?>> applicableBindings = AbstractInterceptorChain.resolveInterceptorValues(annotationMetadata, interceptorKind);
if (applicableBindings.isEmpty()) {
return resolveToNone((ExecutableMethod<?, ?>) method, interceptorKind, annotationMetadata);
} else {
@SuppressWarnings({ "unchecked", "rawtypes" }) final Interceptor[] resolvedInterceptors = (Interceptor[]) interceptorStream(method.getDeclaringType(), (Collection) interceptors, interceptorKind, applicableBindings).filter(bean -> (bean instanceof MethodInterceptor) || !(bean instanceof ConstructorInterceptor)).toArray(Interceptor[]::new);
if (LOG.isTraceEnabled()) {
LOG.trace("Resolved {} {} interceptors out of a possible {} for method: {} - {}", resolvedInterceptors.length, interceptorKind, interceptors.size(), method.getDeclaringType(), method instanceof Described ? ((Described) method).getDescription(true) : method.toString());
for (int i = 0; i < resolvedInterceptors.length; i++) {
Interceptor<?, ?> resolvedInterceptor = resolvedInterceptors[i];
LOG.trace("Interceptor {} - {}", i, resolvedInterceptor);
}
}
// noinspection unchecked
return resolvedInterceptors;
}
}
}
Aggregations