Skip to content

Commit bfa8d4b

Browse files
committed
Working in general solution
Signed-off-by: Jorge Bescos Gascon <[email protected]>
1 parent d248c30 commit bfa8d4b

File tree

6 files changed

+41
-23
lines changed

6 files changed

+41
-23
lines changed

dependencies/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
<version.lib.jakarta.websockets-api>2.1.1</version.lib.jakarta.websockets-api>
8888
<!-- Check Hibernate when upgrading to ensure its supplied jaxb-runtime is compatible. -->
8989
<version.lib.jakarta.xml.bind-api>3.0.1</version.lib.jakarta.xml.bind-api>
90-
<version.lib.jandex>2.4.3.Final</version.lib.jandex>
90+
<version.lib.jandex>3.0.8</version.lib.jandex>
9191
<version.lib.jaxb-core>3.0.2</version.lib.jaxb-core>
9292
<version.lib.jaxb-impl>3.0.2</version.lib.jaxb-impl>
9393
<version.lib.jboss.classfilewriter>1.2.5.Final</version.lib.jboss.classfilewriter>
@@ -148,7 +148,7 @@
148148
<version.lib.postgresql>42.4.4</version.lib.postgresql>
149149
<version.lib.prometheus>0.9.0</version.lib.prometheus>
150150
<version.lib.slf4j>2.0.9</version.lib.slf4j>
151-
<version.lib.smallrye-openapi>2.1.16</version.lib.smallrye-openapi>
151+
<version.lib.smallrye-openapi>2.1.24</version.lib.smallrye-openapi>
152152
<version.lib.snakeyaml>2.2</version.lib.snakeyaml>
153153
<version.lib.typesafe-config>1.4.2</version.lib.typesafe-config>
154154
<version.lib.tyrus>2.1.5</version.lib.tyrus>

microprofile/graphql/server/pom.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,6 @@
8282
<plugin>
8383
<groupId>org.jboss.jandex</groupId>
8484
<artifactId>jandex-maven-plugin</artifactId>
85-
<!-- Temporal fix meanwhile there are no newer versions of the plugin -->
86-
<dependencies>
87-
<dependency>
88-
<groupId>org.jboss</groupId>
89-
<artifactId>jandex</artifactId>
90-
<version>3.1.8</version>
91-
</dependency>
92-
</dependencies>
9385
<executions>
9486
<execution>
9587
<id>make-index</id>

microprofile/lra/jax-rs/src/main/java/io/helidon/microprofile/lra/InspectionService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -155,11 +155,12 @@ Set<AnnotationInstance> lookUpLraAnnotations(Method method) {
155155

156156
Set<AnnotationInstance> lookUpLraAnnotations(MethodInfo methodInfo) {
157157
Map<String, AnnotationInstance> annotations = new HashMap<>();
158+
Type[] types = methodInfo.parameters().stream().map(param -> param.type()).toArray(Type[]::new);
158159
deepScanLraMethod(
159160
methodInfo.declaringClass(),
160161
annotations,
161162
methodInfo.name(),
162-
methodInfo.parameters().toArray(new Type[0])
163+
types
163164
);
164165
HashSet<AnnotationInstance> result = new HashSet<>(annotations.values());
165166

microprofile/lra/jax-rs/src/main/java/io/helidon/microprofile/lra/LraCdiExtension.java

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021 Oracle and/or its affiliates.
2+
* Copyright (c) 2021, 2024 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
import java.util.Enumeration;
2626
import java.util.HashMap;
2727
import java.util.HashSet;
28+
import java.util.LinkedList;
2829
import java.util.List;
2930
import java.util.Map;
3031
import java.util.Set;
@@ -69,6 +70,7 @@
6970
import org.jboss.jandex.ClassInfo;
7071
import org.jboss.jandex.CompositeIndex;
7172
import org.jboss.jandex.DotName;
73+
import org.jboss.jandex.Index;
7274
import org.jboss.jandex.IndexReader;
7375
import org.jboss.jandex.IndexView;
7476
import org.jboss.jandex.Indexer;
@@ -94,7 +96,8 @@ public class LraCdiExtension implements Extension {
9496

9597
private final Set<Class<?>> beanTypesWithCdiLRAMethods = new HashSet<>();
9698
private final Map<Class<?>, Bean<?>> lraCdiBeanReferences = new HashMap<>();
97-
private final Indexer indexer;
99+
// Do not clear indexes. #index requires a strong reference to these.
100+
private final List<IndexView> indexes = new LinkedList<>();
98101
private final ClassLoader classLoader;
99102
private IndexView index;
100103

@@ -103,7 +106,6 @@ public class LraCdiExtension implements Extension {
103106
* Initialize MicroProfile Long Running Actions CDI extension.
104107
*/
105108
public LraCdiExtension() {
106-
indexer = new Indexer();
107109
classLoader = Thread.currentThread().getContextClassLoader();
108110
// Needs to be always indexed
109111
Set.of(LRA.class,
@@ -119,7 +121,9 @@ public LraCdiExtension() {
119121
try {
120122
indexFiles = findIndexFiles("META-INF/jandex.idx");
121123
if (!indexFiles.isEmpty()) {
122-
index = CompositeIndex.create(indexer.complete(), existingIndexFileReader(indexFiles));
124+
indexes.add(existingIndexFileReader(indexFiles));
125+
index = CompositeIndex.create(indexes);
126+
logIndexedClasses(index);
123127
} else {
124128
index = null;
125129
}
@@ -137,7 +141,8 @@ private void index(
137141
LRA.class,
138142
AfterLRA.class, Compensate.class, Complete.class, Forget.class, Status.class
139143
}) ProcessAnnotatedType<?> pat) {
140-
// compile time bilt index
144+
// compile time built index
145+
// If META-INF/jandex.idx exists we don't explore more
141146
if (index != null) return;
142147
// create runtime index when pre-built index is not available
143148
runtimeIndex(DotName.createSimple(pat.getAnnotatedType().getJavaClass().getName()));
@@ -227,7 +232,8 @@ private void ready(
227232

228233
if (index == null) {
229234
// compile time built index
230-
index = indexer.complete();
235+
index = CompositeIndex.create(indexes);
236+
logIndexedClasses(index);
231237
}
232238

233239
// ------------- Validate LRA participant methods -------------
@@ -255,13 +261,16 @@ Map<Class<?>, Bean<?>> lraCdiBeanReferences() {
255261
void runtimeIndex(DotName fqdn) {
256262
if (fqdn == null) return;
257263
LOGGER.fine("Indexing " + fqdn);
258-
ClassInfo classInfo;
259264
try {
260-
classInfo = indexer.index(classLoader.getResourceAsStream(fqdn.toString().replace('.', '/') + ".class"));
265+
Indexer newIndexer = new Indexer();
266+
newIndexer.index(classLoader.getResourceAsStream(fqdn.toString().replace('.', '/') + ".class"));
267+
Index index = newIndexer.complete();
268+
indexes.add(index);
269+
ClassInfo classInfo = index.getClassByName(fqdn);
261270
// look also for extended classes
262271
runtimeIndex(classInfo.superName());
263272
// and implemented interfaces
264-
classInfo.interfaceNames().forEach(this::runtimeIndex);
273+
classInfo.interfaceNames().forEach(dotName -> runtimeIndex(dotName));
265274
} catch (IOException e) {
266275
LOGGER.log(Level.SEVERE, "Unable to index referenced class.", e);
267276
}
@@ -313,4 +322,13 @@ static <T> T lookup(Bean<?> bean, BeanManager beanManager) {
313322
}
314323
return (T) instance;
315324
}
325+
326+
private void logIndexedClasses(IndexView index) {
327+
if (LOGGER.isLoggable(Level.FINE)) {
328+
LOGGER.fine(index.getKnownClasses().size()+ " indexed classes.");
329+
index.getKnownClasses().forEach(classInfo -> {
330+
LOGGER.fine("Indexed class - " + classInfo.name().toString());
331+
});
332+
}
333+
}
316334
}

microprofile/lra/jax-rs/src/main/java/io/helidon/microprofile/lra/ParticipantValidationModel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021 Oracle and/or its affiliates.
2+
* Copyright (c) 2021, 2024 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -155,7 +155,7 @@ private static class ParticipantMethod {
155155

156156
String nameWithParams() {
157157
return methodInfo.name() + methodInfo.parameters().stream()
158-
.map(Type::name)
158+
.map(paramInfo -> paramInfo.type().name())
159159
.map(DotName::toString)
160160
.collect(Collectors.joining());
161161
}

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,13 @@
465465
<groupId>org.jboss.jandex</groupId>
466466
<artifactId>jandex-maven-plugin</artifactId>
467467
<version>${version.plugin.jandex}</version>
468+
<dependencies>
469+
<dependency>
470+
<groupId>org.jboss</groupId>
471+
<artifactId>jandex</artifactId>
472+
<version>3.1.8</version>
473+
</dependency>
474+
</dependencies>
468475
</plugin>
469476
<plugin>
470477
<groupId>org.apache.maven.plugins</groupId>

0 commit comments

Comments
 (0)