From 5f6a8dcf707462e108f6ffb249c9299a201d6d2c Mon Sep 17 00:00:00 2001 From: Nicolas Filotto Date: Tue, 6 Dec 2022 18:04:32 +0100 Subject: [PATCH] Add a scenario with an extension registering many classes Co-authored-by: Rostislav Svoboda --- .../README.md | 3 + .../deployment/pom.xml | 55 ++++++++++++++++ .../deployment/SomeExtensionProcessor.java | 23 +++++++ .../pom.xml | 16 +++++ .../runner/pom.xml | 22 +++++++ .../io/quarkus/qe/someext/SomeResource.java | 21 +++++++ .../io/quarkus/qe/someext/SomeResourceIT.java | 7 +++ .../quarkus/qe/someext/SomeResourceTest.java | 24 +++++++ .../runtime/pom.xml | 63 +++++++++++++++++++ .../resources/META-INF/quarkus-extension.yaml | 8 +++ pom.xml | 1 + 11 files changed, 243 insertions(+) create mode 100644 024-quarkus-extension-with-many-classes-to-register/README.md create mode 100644 024-quarkus-extension-with-many-classes-to-register/deployment/pom.xml create mode 100644 024-quarkus-extension-with-many-classes-to-register/deployment/src/main/java/io/quarkus/qe/someext/deployment/SomeExtensionProcessor.java create mode 100644 024-quarkus-extension-with-many-classes-to-register/pom.xml create mode 100644 024-quarkus-extension-with-many-classes-to-register/runner/pom.xml create mode 100644 024-quarkus-extension-with-many-classes-to-register/runner/src/main/java/io/quarkus/qe/someext/SomeResource.java create mode 100644 024-quarkus-extension-with-many-classes-to-register/runner/src/test/java/io/quarkus/qe/someext/SomeResourceIT.java create mode 100644 024-quarkus-extension-with-many-classes-to-register/runner/src/test/java/io/quarkus/qe/someext/SomeResourceTest.java create mode 100644 024-quarkus-extension-with-many-classes-to-register/runtime/pom.xml create mode 100644 024-quarkus-extension-with-many-classes-to-register/runtime/src/main/resources/META-INF/quarkus-extension.yaml diff --git a/024-quarkus-extension-with-many-classes-to-register/README.md b/024-quarkus-extension-with-many-classes-to-register/README.md new file mode 100644 index 00000000..9a5d0a72 --- /dev/null +++ b/024-quarkus-extension-with-many-classes-to-register/README.md @@ -0,0 +1,3 @@ +# Quarkus - many classes to register + +An example of extension that needs to register many classes for reflection. \ No newline at end of file diff --git a/024-quarkus-extension-with-many-classes-to-register/deployment/pom.xml b/024-quarkus-extension-with-many-classes-to-register/deployment/pom.xml new file mode 100644 index 00000000..f522c46e --- /dev/null +++ b/024-quarkus-extension-with-many-classes-to-register/deployment/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + + io.quarkus.qe + 024-quarkus-extension-with-many-classes-to-register-parent + 1.0.0-SNAPSHOT + ../pom.xml + + 024-quarkus-extension-with-many-classes-to-register-deployment + + true + + + + io.quarkus + quarkus-core-deployment + + + io.quarkus.qe + 024-quarkus-extension-with-many-classes-to-register + ${project.version} + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${quarkus.platform.version} + + + + + + + + + native + + + native + + + + jar + + + + diff --git a/024-quarkus-extension-with-many-classes-to-register/deployment/src/main/java/io/quarkus/qe/someext/deployment/SomeExtensionProcessor.java b/024-quarkus-extension-with-many-classes-to-register/deployment/src/main/java/io/quarkus/qe/someext/deployment/SomeExtensionProcessor.java new file mode 100644 index 00000000..19317734 --- /dev/null +++ b/024-quarkus-extension-with-many-classes-to-register/deployment/src/main/java/io/quarkus/qe/someext/deployment/SomeExtensionProcessor.java @@ -0,0 +1,23 @@ +package io.quarkus.qe.someext.deployment; + +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; + +class SomeExtensionProcessor { + + private static final String FEATURE = "some-extension"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + void registerManyClassesForReflection(BuildProducer reflectiveClass) { + for (int i = 0; i < 30_000; i++) { + reflectiveClass.produce(new ReflectiveClassBuildItem(false, true, String.format("io.quarkus.qe.SomeClass%d", i))); + } + } +} diff --git a/024-quarkus-extension-with-many-classes-to-register/pom.xml b/024-quarkus-extension-with-many-classes-to-register/pom.xml new file mode 100644 index 00000000..7b9ef2d2 --- /dev/null +++ b/024-quarkus-extension-with-many-classes-to-register/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + + io.quarkus.qe + beefy-scenarios + 1.0.0-SNAPSHOT + + 024-quarkus-extension-with-many-classes-to-register-parent + pom + + deployment + runtime + runner + + diff --git a/024-quarkus-extension-with-many-classes-to-register/runner/pom.xml b/024-quarkus-extension-with-many-classes-to-register/runner/pom.xml new file mode 100644 index 00000000..8f5b20d7 --- /dev/null +++ b/024-quarkus-extension-with-many-classes-to-register/runner/pom.xml @@ -0,0 +1,22 @@ + + + 4.0.0 + + io.quarkus.qe + 024-quarkus-extension-with-many-classes-to-register-parent + 1.0.0-SNAPSHOT + ../pom.xml + + 024-quarkus-extension-with-many-classes-to-register-runner + + + io.quarkus.qe + 024-quarkus-extension-with-many-classes-to-register + ${project.version} + + + io.quarkus + quarkus-resteasy + + + diff --git a/024-quarkus-extension-with-many-classes-to-register/runner/src/main/java/io/quarkus/qe/someext/SomeResource.java b/024-quarkus-extension-with-many-classes-to-register/runner/src/main/java/io/quarkus/qe/someext/SomeResource.java new file mode 100644 index 00000000..08605766 --- /dev/null +++ b/024-quarkus-extension-with-many-classes-to-register/runner/src/main/java/io/quarkus/qe/someext/SomeResource.java @@ -0,0 +1,21 @@ +package io.quarkus.qe.someext; + +import javax.enterprise.context.ApplicationScoped; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Path("/") +@ApplicationScoped +public class SomeResource { + + @Path("/echo") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public String echo(String message) { + return message; + } +} diff --git a/024-quarkus-extension-with-many-classes-to-register/runner/src/test/java/io/quarkus/qe/someext/SomeResourceIT.java b/024-quarkus-extension-with-many-classes-to-register/runner/src/test/java/io/quarkus/qe/someext/SomeResourceIT.java new file mode 100644 index 00000000..964f4560 --- /dev/null +++ b/024-quarkus-extension-with-many-classes-to-register/runner/src/test/java/io/quarkus/qe/someext/SomeResourceIT.java @@ -0,0 +1,7 @@ +package io.quarkus.qe.someext; + +import io.quarkus.test.junit.QuarkusIntegrationTest; + +@QuarkusIntegrationTest +class SomeResourceIT extends SomeResourceTest { +} diff --git a/024-quarkus-extension-with-many-classes-to-register/runner/src/test/java/io/quarkus/qe/someext/SomeResourceTest.java b/024-quarkus-extension-with-many-classes-to-register/runner/src/test/java/io/quarkus/qe/someext/SomeResourceTest.java new file mode 100644 index 00000000..6711ce87 --- /dev/null +++ b/024-quarkus-extension-with-many-classes-to-register/runner/src/test/java/io/quarkus/qe/someext/SomeResourceTest.java @@ -0,0 +1,24 @@ +package io.quarkus.qe.someext; + +import static org.hamcrest.Matchers.equalTo; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; + +@QuarkusTest +class SomeResourceTest { + + @Test + void testEcho() { + RestAssured.given() // + .contentType(ContentType.TEXT) + .body("Hello World") + .post("/echo") // + .then() + .body(equalTo("Hello World")) + .statusCode(200); + } +} diff --git a/024-quarkus-extension-with-many-classes-to-register/runtime/pom.xml b/024-quarkus-extension-with-many-classes-to-register/runtime/pom.xml new file mode 100644 index 00000000..8abfd61d --- /dev/null +++ b/024-quarkus-extension-with-many-classes-to-register/runtime/pom.xml @@ -0,0 +1,63 @@ + + + 4.0.0 + + io.quarkus.qe + 024-quarkus-extension-with-many-classes-to-register-parent + 1.0.0-SNAPSHOT + ../pom.xml + + 024-quarkus-extension-with-many-classes-to-register + + + io.quarkus + quarkus-core + + + + + + io.quarkus + quarkus-extension-maven-plugin + ${quarkus.platform.version} + + + compile + + extension-descriptor + + + ${project.groupId}:${project.artifactId}-deployment:${project.version} + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${quarkus.platform.version} + + + + + + + + + native + + + native + + + + jar + + + + diff --git a/024-quarkus-extension-with-many-classes-to-register/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/024-quarkus-extension-with-many-classes-to-register/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 00000000..5aa24962 --- /dev/null +++ b/024-quarkus-extension-with-many-classes-to-register/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,8 @@ +--- +name: "Some Extension" +description: "Extension with many classes to register for reflection" +metadata: + categories: + - "core" + status: "stable" + unlisted: true diff --git a/pom.xml b/pom.xml index 62f42a73..e5bf8697 100644 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,7 @@ 022-quarkus-properties-config-all + 024-quarkus-extension-with-many-classes-to-register 101-javaee-like-getting-started 201-large-static-content 300-quarkus-vertx-webClient