Skip to content

Commit

Permalink
4.x: Interceptor creator now uses TypeName (and related changes) (hel…
Browse files Browse the repository at this point in the history
…idon-io#7420)

* Interceptor creator now uses TypeName (and related changes)
  • Loading branch information
tomas-langer authored and dalexandrov committed Aug 26, 2023
1 parent 4384ab1 commit f62f407
Show file tree
Hide file tree
Showing 19 changed files with 255 additions and 222 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public CircuitBreakerMethodCreator() {
}

@Override
public Set<String> annoTypes() {
return Set.of(FT_ANNOTATION);
public Set<TypeName> annoTypes() {
return Set.of(FT_ANNOTATION_TYPE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public FallbackMethodCreator() {
}

@Override
public Set<String> annoTypes() {
return Set.of(FALLBACK_ANNOTATION);
public Set<TypeName> annoTypes() {
return Set.of(FALLBACK_ANNOTATION_TYPE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public RetryMethodCreator() {
}

@Override
public Set<String> annoTypes() {
return Set.of(RETRY_ANNOTATION);
public Set<TypeName> annoTypes() {
return Set.of(RETRY_ANNOTATION_TYPE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public HttpEndpointCreator() {
}

@Override
public Set<String> annoTypes() {
return Set.of(PATH_ANNOTATION);
public Set<TypeName> annoTypes() {
return Set.of(TypeName.create(PATH_ANNOTATION));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ public HttpMethodCreator() {
}

@Override
public Set<String> annoTypes() {
return Set.of(GET_ANNOTATION,
HEADER_PARAM_ANNOTATION,
HTTP_METHOD_ANNOTATION,
POST_ANNOTATION,
PATH_ANNOTATION,
QUERY_PARAM_ANNOTATION);
public Set<TypeName> annoTypes() {
return Set.of(TypeName.create(GET_ANNOTATION),
TypeName.create(HEADER_PARAM_ANNOTATION),
TypeName.create(HTTP_METHOD_ANNOTATION),
TypeName.create(POST_ANNOTATION),
TypeName.create(PATH_ANNOTATION),
TypeName.create(QUERY_PARAM_ANNOTATION));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,19 @@ static List<CustomAnnotationTemplateCreator> initialize() {
List<CustomAnnotationTemplateCreator> creators = HelidonServiceLoader.create(loader()).asList();
creators.forEach(creator -> {
try {
Set<String> annoTypes = creator.annoTypes();
Set<TypeName> annoTypes = creator.annoTypes();
annoTypes.forEach(annoType -> {
PRODUCERS_BY_ANNOTATION.compute(TypeName.create(annoType), (k, v) -> {
PRODUCERS_BY_ANNOTATION.compute(annoType, (k, v) -> {
if (v == null) {
v = new LinkedHashSet<>();
}
v.add(creator);
return v;
});
});
ALL_ANNO_TYPES_HANDLED.addAll(annoTypes);
ALL_ANNO_TYPES_HANDLED.addAll(annoTypes.stream()
.map(TypeName::fqName)
.toList());
} catch (Throwable t) {
System.Logger logger = System.getLogger(CustomAnnotationProcessor.class.getName());
ToolsException te = new ToolsException("Failed to initialize: " + creator, t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,8 @@ private void processInterceptors(ServicesToProcess services,
InterceptorCreator.InterceptorProcessor processor = interceptorCreator.createInterceptorProcessor(
interceptedServiceInfo,
interceptorCreator,
Optional.of(processingEnv));
Set<String> annotationTypeTriggers = processor.allAnnotationTypeTriggers();
processingEnv);
Set<TypeName> annotationTypeTriggers = processor.allAnnotationTypeTriggers();
if (annotationTypeTriggers.isEmpty()) {
services.addInterceptorPlanFor(serviceTypeName, Optional.empty());
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public ExtensibleGetTemplateProducer() {
}

@Override
public Set<String> annoTypes() {
return Set.of("io.helidon.inject.processor.testsubjects.ExtensibleGET");
public Set<TypeName> annoTypes() {
return Set.of(TypeName.create("io.helidon.inject.processor.testsubjects.ExtensibleGET"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import io.helidon.config.Config;
import io.helidon.config.ConfigSources;
import io.helidon.inject.api.InjectionException;
import io.helidon.inject.api.Interceptor;
import io.helidon.inject.api.InjectionServices;
import io.helidon.inject.api.Interceptor;
import io.helidon.inject.api.ServiceInfo;
import io.helidon.inject.api.ServiceInfoCriteria;
import io.helidon.inject.api.ServiceProvider;
Expand All @@ -43,7 +43,6 @@
import jakarta.inject.Named;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static io.helidon.inject.api.Qualifier.create;
Expand Down Expand Up @@ -97,7 +96,6 @@ void createNoArgBasedInterceptorSource() throws Exception {
java);
}

@Disabled // will be handled in https://github.com/helidon-io/helidon/issues/6542
@Test
void createInterfaceBasedInterceptorSource() throws Exception {
TypeName interceptorTypeName = TypeName.create(YImpl$$Injection$$Interceptor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import java.util.function.Function;
import io.helidon.common.types.Annotation;
import io.helidon.common.types.TypeName;
import io.helidon.common.types.TypedElementInfo;
import io.helidon.common.types.TypeName;
import io.helidon.common.types.TypedElementInfo;
import io.helidon.common.types.TypeValues;
import io.helidon.inject.api.ClassNamed;
import io.helidon.inject.api.InvocationContext;
Expand Down Expand Up @@ -228,17 +226,17 @@ public class XImpl$$Injection$$Interceptor extends io.helidon.inject.tests.injec
@Inject
@SuppressWarnings("unchecked")
XImpl$$Injection$$Interceptor(
@ClassNamed(io.helidon.inject.tests.plain.interceptor.InterceptorBasedAnno.class) List<Provider<Interceptor>> io_helidon_inject_tests_plain_interceptor_InterceptorBasedAnno,
@ClassNamed(io.helidon.inject.tests.inject.interceptor.TestNamed.class) List<Provider<Interceptor>> io_helidon_inject_tests_inject_interceptor_TestNamed,
@ClassNamed(io.helidon.inject.tests.plain.interceptor.InterceptorBasedAnno.class) List<Provider<Interceptor>> io_helidon_inject_tests_plain_interceptor_InterceptorBasedAnno,
Provider<io.helidon.inject.tests.inject.interceptor.XImpl> provider) {
this.__provider = Objects.requireNonNull(provider);
this.__sp = (provider instanceof ServiceProvider) ? (ServiceProvider<io.helidon.inject.tests.inject.interceptor.XImpl>) __provider : null;
List<Provider<Interceptor>> __ctor__interceptors = mergeAndCollapse(io_helidon_inject_tests_inject_interceptor_TestNamed);
this.__methodIA1__interceptors = mergeAndCollapse(io_helidon_inject_tests_inject_interceptor_TestNamed);
this.__methodIA2__interceptors = mergeAndCollapse(io_helidon_inject_tests_plain_interceptor_InterceptorBasedAnno, io_helidon_inject_tests_inject_interceptor_TestNamed);
this.__methodIB__interceptors = mergeAndCollapse(io_helidon_inject_tests_plain_interceptor_InterceptorBasedAnno, io_helidon_inject_tests_inject_interceptor_TestNamed);
this.__methodIB2__interceptors = mergeAndCollapse(io_helidon_inject_tests_plain_interceptor_InterceptorBasedAnno, io_helidon_inject_tests_inject_interceptor_TestNamed);
this.__close__interceptors = mergeAndCollapse(io_helidon_inject_tests_plain_interceptor_InterceptorBasedAnno, io_helidon_inject_tests_inject_interceptor_TestNamed);
this.__methodIA2__interceptors = mergeAndCollapse(io_helidon_inject_tests_inject_interceptor_TestNamed, io_helidon_inject_tests_plain_interceptor_InterceptorBasedAnno);
this.__methodIB__interceptors = mergeAndCollapse(io_helidon_inject_tests_inject_interceptor_TestNamed, io_helidon_inject_tests_plain_interceptor_InterceptorBasedAnno);
this.__methodIB2__interceptors = mergeAndCollapse(io_helidon_inject_tests_inject_interceptor_TestNamed, io_helidon_inject_tests_plain_interceptor_InterceptorBasedAnno);
this.__close__interceptors = mergeAndCollapse(io_helidon_inject_tests_inject_interceptor_TestNamed, io_helidon_inject_tests_plain_interceptor_InterceptorBasedAnno);
this.__methodX__interceptors = mergeAndCollapse(io_helidon_inject_tests_inject_interceptor_TestNamed);
this.__methodY__interceptors = mergeAndCollapse(io_helidon_inject_tests_inject_interceptor_TestNamed);
this.__methodZ__interceptors = mergeAndCollapse(io_helidon_inject_tests_inject_interceptor_TestNamed);
Expand Down
Loading

0 comments on commit f62f407

Please sign in to comment.