From d573b52d2bf0f042016cf57be7854217464873f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiago=20Henrique=20H=C3=BCpner?= Date: Fri, 16 Jun 2023 00:27:03 -0300 Subject: [PATCH] Fixes #3335 - Use the new extension --- extension/coreprofile/pom.xml | 6 ++++++ .../extension/coreprofile/CoreProfileExtension.java | 13 +++++++++++-- .../coreprofile/src/main/java/module-info.java | 1 + extension/microprofile/pom.xml | 6 ++++++ .../microprofile/MicroProfileExtension.java | 13 +++++++++++-- .../microprofile/src/main/java/module-info.java | 1 + extension/platform/pom.xml | 6 ++++++ .../extension/platform/PlatformExtension.java | 13 +++++++++++-- extension/platform/src/main/java/module-info.java | 1 + extension/servlet/pom.xml | 6 ++++++ .../piranha/extension/servlet/ServletExtension.java | 12 ++++++++++-- extension/servlet/src/main/java/module-info.java | 1 + .../ServletAnnotationsExtensionTest.java | 4 ++-- .../servletannotations/WebServletTest.java | 4 ++-- extension/webprofile/pom.xml | 6 ++++++ .../extension/webprofile/WebProfileExtension.java | 13 +++++++++++-- extension/webprofile/src/main/java/module-info.java | 1 + .../piranha/micro/core/MicroInnerDeployer.java | 2 +- .../impl/DefaultResourceManagerClassLoader.java | 2 +- 19 files changed, 95 insertions(+), 16 deletions(-) diff --git a/extension/coreprofile/pom.xml b/extension/coreprofile/pom.xml index d8501fd0fb..94b1266f76 100644 --- a/extension/coreprofile/pom.xml +++ b/extension/coreprofile/pom.xml @@ -31,6 +31,12 @@ ${project.version} compile + + cloud.piranha.extension + piranha-extension-annotationscan-classfile + ${project.version} + compile + cloud.piranha.extension piranha-extension-naming diff --git a/extension/coreprofile/src/main/java/cloud/piranha/extension/coreprofile/CoreProfileExtension.java b/extension/coreprofile/src/main/java/cloud/piranha/extension/coreprofile/CoreProfileExtension.java index de03ac88bf..73c2590749 100644 --- a/extension/coreprofile/src/main/java/cloud/piranha/extension/coreprofile/CoreProfileExtension.java +++ b/extension/coreprofile/src/main/java/cloud/piranha/extension/coreprofile/CoreProfileExtension.java @@ -29,7 +29,8 @@ import cloud.piranha.core.api.WebApplicationExtension; import cloud.piranha.core.api.WebApplicationExtensionContext; -import cloud.piranha.extension.annotationscan.classfile.AnnotationScanExtension; +import cloud.piranha.extension.annotationscan.AnnotationScanExtension; +import cloud.piranha.extension.annotationscan.classfile.ClassfileAnnotationScanExtension; import cloud.piranha.extension.naming.NamingExtension; import cloud.piranha.extension.scinitializer.ServletContainerInitializerExtension; @@ -43,7 +44,15 @@ public class CoreProfileExtension implements WebApplicationExtension { @Override public void extend(WebApplicationExtensionContext context) { context.add(NamingExtension.class); // Naming (JNDI) - context.add(AnnotationScanExtension.class); + context.add(getAnnotationScanExtensionClass()); context.add(ServletContainerInitializerExtension.class); // ServletContainerInitializer } + + private static Class getAnnotationScanExtensionClass() { + if (System.getProperty(ClassfileAnnotationScanExtension.EXPERIMENTAL_PROPERTY) != null) { + return ClassfileAnnotationScanExtension.class; // Annotation scanning using the new Classfile API + } + return AnnotationScanExtension.class; // Annotation scanning + } + } diff --git a/extension/coreprofile/src/main/java/module-info.java b/extension/coreprofile/src/main/java/module-info.java index a5ba16480c..425068f191 100644 --- a/extension/coreprofile/src/main/java/module-info.java +++ b/extension/coreprofile/src/main/java/module-info.java @@ -49,6 +49,7 @@ opens cloud.piranha.extension.coreprofile; requires cloud.piranha.core.api; requires cloud.piranha.extension.annotationscan; + requires cloud.piranha.extension.annotationscan.classfile; requires cloud.piranha.extension.naming; requires cloud.piranha.extension.scinitializer; requires jakarta.ws.rs; diff --git a/extension/microprofile/pom.xml b/extension/microprofile/pom.xml index 16671c84d0..a94b3d5947 100644 --- a/extension/microprofile/pom.xml +++ b/extension/microprofile/pom.xml @@ -31,6 +31,12 @@ ${project.version} compile + + cloud.piranha.extension + piranha-extension-annotationscan-classfile + ${project.version} + compile + cloud.piranha.extension piranha-extension-naming diff --git a/extension/microprofile/src/main/java/cloud/piranha/extension/microprofile/MicroProfileExtension.java b/extension/microprofile/src/main/java/cloud/piranha/extension/microprofile/MicroProfileExtension.java index 8e880ccb6e..8f2b727a7d 100644 --- a/extension/microprofile/src/main/java/cloud/piranha/extension/microprofile/MicroProfileExtension.java +++ b/extension/microprofile/src/main/java/cloud/piranha/extension/microprofile/MicroProfileExtension.java @@ -29,7 +29,8 @@ import cloud.piranha.core.api.WebApplicationExtension; import cloud.piranha.core.api.WebApplicationExtensionContext; -import cloud.piranha.extension.annotationscan.classfile.AnnotationScanExtension; +import cloud.piranha.extension.annotationscan.AnnotationScanExtension; +import cloud.piranha.extension.annotationscan.classfile.ClassfileAnnotationScanExtension; import cloud.piranha.extension.naming.NamingExtension; import cloud.piranha.extension.scinitializer.ServletContainerInitializerExtension; @@ -43,7 +44,15 @@ public class MicroProfileExtension implements WebApplicationExtension { @Override public void extend(WebApplicationExtensionContext context) { context.add(NamingExtension.class); // Naming (JNDI) - context.add(AnnotationScanExtension.class); + context.add(getAnnotationScanExtensionClass()); context.add(ServletContainerInitializerExtension.class); // ServletContainerInitializer } + + private static Class getAnnotationScanExtensionClass() { + if (System.getProperty(ClassfileAnnotationScanExtension.EXPERIMENTAL_PROPERTY) != null) { + return ClassfileAnnotationScanExtension.class; // Annotation scanning using the new Classfile API + } + return AnnotationScanExtension.class; // Annotation scanning + } + } diff --git a/extension/microprofile/src/main/java/module-info.java b/extension/microprofile/src/main/java/module-info.java index 64bb8d8655..6173255cb0 100644 --- a/extension/microprofile/src/main/java/module-info.java +++ b/extension/microprofile/src/main/java/module-info.java @@ -48,6 +48,7 @@ opens cloud.piranha.extension.microprofile; requires cloud.piranha.core.api; requires cloud.piranha.extension.annotationscan; + requires cloud.piranha.extension.annotationscan.classfile; requires cloud.piranha.extension.naming; requires cloud.piranha.extension.scinitializer; requires jakarta.ws.rs; diff --git a/extension/platform/pom.xml b/extension/platform/pom.xml index 0b67a5569d..0e7b30e5f6 100644 --- a/extension/platform/pom.xml +++ b/extension/platform/pom.xml @@ -32,6 +32,12 @@ ${project.version} compile + + cloud.piranha.extension + piranha-extension-annotationscan-classfile + ${project.version} + compile + cloud.piranha.extension piranha-extension-naming diff --git a/extension/platform/src/main/java/cloud/piranha/extension/platform/PlatformExtension.java b/extension/platform/src/main/java/cloud/piranha/extension/platform/PlatformExtension.java index 29e5b0bfda..1414b54ba6 100644 --- a/extension/platform/src/main/java/cloud/piranha/extension/platform/PlatformExtension.java +++ b/extension/platform/src/main/java/cloud/piranha/extension/platform/PlatformExtension.java @@ -29,7 +29,8 @@ import cloud.piranha.core.api.WebApplicationExtension; import cloud.piranha.core.api.WebApplicationExtensionContext; -import cloud.piranha.extension.annotationscan.classfile.AnnotationScanExtension; +import cloud.piranha.extension.annotationscan.AnnotationScanExtension; +import cloud.piranha.extension.annotationscan.classfile.ClassfileAnnotationScanExtension; import cloud.piranha.extension.naming.NamingExtension; import cloud.piranha.extension.scinitializer.ServletContainerInitializerExtension; @@ -43,7 +44,15 @@ public class PlatformExtension implements WebApplicationExtension { @Override public void extend(WebApplicationExtensionContext context) { context.add(NamingExtension.class); // Naming (JNDI) - context.add(AnnotationScanExtension.class); // Annotation scanning + context.add(getAnnotationScanExtensionClass()); // Annotation scanning context.add(ServletContainerInitializerExtension.class); // ServletContainerInitializer } + + private static Class getAnnotationScanExtensionClass() { + if (System.getProperty(ClassfileAnnotationScanExtension.EXPERIMENTAL_PROPERTY) != null) { + return ClassfileAnnotationScanExtension.class; // Annotation scanning using the new Classfile API + } + return AnnotationScanExtension.class; // Annotation scanning + } + } diff --git a/extension/platform/src/main/java/module-info.java b/extension/platform/src/main/java/module-info.java index 1ecfd107c8..97d03bb575 100644 --- a/extension/platform/src/main/java/module-info.java +++ b/extension/platform/src/main/java/module-info.java @@ -49,6 +49,7 @@ opens cloud.piranha.extension.platform; requires cloud.piranha.core.api; requires cloud.piranha.extension.annotationscan; + requires cloud.piranha.extension.annotationscan.classfile; requires cloud.piranha.extension.naming; requires cloud.piranha.extension.scinitializer; requires jakarta.ws.rs; diff --git a/extension/servlet/pom.xml b/extension/servlet/pom.xml index 684dbee3d3..8e8c401043 100644 --- a/extension/servlet/pom.xml +++ b/extension/servlet/pom.xml @@ -32,6 +32,12 @@ ${project.version} compile + + cloud.piranha.extension + piranha-extension-annotationscan-classfile + ${project.version} + compile + cloud.piranha.extension piranha-extension-apache-fileupload diff --git a/extension/servlet/src/main/java/cloud/piranha/extension/servlet/ServletExtension.java b/extension/servlet/src/main/java/cloud/piranha/extension/servlet/ServletExtension.java index ed3d76c85c..b3adca0563 100644 --- a/extension/servlet/src/main/java/cloud/piranha/extension/servlet/ServletExtension.java +++ b/extension/servlet/src/main/java/cloud/piranha/extension/servlet/ServletExtension.java @@ -29,7 +29,8 @@ import cloud.piranha.core.api.WebApplicationExtension; import cloud.piranha.core.api.WebApplicationExtensionContext; -import cloud.piranha.extension.annotationscan.classfile.AnnotationScanExtension; +import cloud.piranha.extension.annotationscan.AnnotationScanExtension; +import cloud.piranha.extension.annotationscan.classfile.ClassfileAnnotationScanExtension; import cloud.piranha.extension.apache.fileupload.ApacheMultiPartExtension; import cloud.piranha.extension.naming.NamingExtension; import cloud.piranha.extension.policy.PolicyExtension; @@ -60,10 +61,17 @@ public void extend(WebApplicationExtensionContext context) { context.add(WaspJspManagerExtension.class); // addJspFile context.add(NamingExtension.class); // Naming (JNDI) context.add(WebXmlExtension.class); // web.xml - context.add(AnnotationScanExtension.class); // Annotation scanning + context.add(getAnnotationScanExtensionClass()); // Annotation scanning context.add(ServletAnnotationsExtension.class); // Servlet annotations context.add(WaspExtension.class); // WaSP context.add(ServletContainerInitializerExtension.class); // ServletContainerInitializer context.add(ServletSecurityExtension.class); // Security implementation } + + private static Class getAnnotationScanExtensionClass() { + if (System.getProperty(ClassfileAnnotationScanExtension.EXPERIMENTAL_PROPERTY) != null) { + return ClassfileAnnotationScanExtension.class; // Annotation scanning using the new Classfile API + } + return AnnotationScanExtension.class; // Annotation scanning + } } diff --git a/extension/servlet/src/main/java/module-info.java b/extension/servlet/src/main/java/module-info.java index df582f1d20..512bfa1435 100644 --- a/extension/servlet/src/main/java/module-info.java +++ b/extension/servlet/src/main/java/module-info.java @@ -53,6 +53,7 @@ opens cloud.piranha.extension.servlet; requires cloud.piranha.core.api; requires cloud.piranha.extension.annotationscan; + requires cloud.piranha.extension.annotationscan.classfile; requires cloud.piranha.extension.apache.fileupload; requires cloud.piranha.extension.naming; requires cloud.piranha.extension.policy; diff --git a/extension/servletannotations/src/test/java/cloud/piranha/extension/servletannotations/ServletAnnotationsExtensionTest.java b/extension/servletannotations/src/test/java/cloud/piranha/extension/servletannotations/ServletAnnotationsExtensionTest.java index aaa0a93f62..b21ea7f590 100644 --- a/extension/servletannotations/src/test/java/cloud/piranha/extension/servletannotations/ServletAnnotationsExtensionTest.java +++ b/extension/servletannotations/src/test/java/cloud/piranha/extension/servletannotations/ServletAnnotationsExtensionTest.java @@ -32,8 +32,8 @@ import cloud.piranha.core.impl.DefaultWebApplication; import cloud.piranha.core.impl.DefaultWebApplicationClassLoader; import cloud.piranha.core.impl.DefaultWebApplicationExtensionContext; -import cloud.piranha.extension.annotationscan.classfile.internal.InternalAnnotationScanAnnotationManager; -import cloud.piranha.extension.annotationscan.classfile.AnnotationScanInitializer; +import cloud.piranha.extension.annotationscan.internal.InternalAnnotationScanAnnotationManager; +import cloud.piranha.extension.annotationscan.AnnotationScanInitializer; import cloud.piranha.resource.impl.ClassResource; import jakarta.servlet.FilterRegistration; import jakarta.servlet.ServletRegistration; diff --git a/extension/servletannotations/src/test/java/cloud/piranha/extension/servletannotations/WebServletTest.java b/extension/servletannotations/src/test/java/cloud/piranha/extension/servletannotations/WebServletTest.java index fee6a9e026..10436af590 100644 --- a/extension/servletannotations/src/test/java/cloud/piranha/extension/servletannotations/WebServletTest.java +++ b/extension/servletannotations/src/test/java/cloud/piranha/extension/servletannotations/WebServletTest.java @@ -33,8 +33,8 @@ import cloud.piranha.embedded.EmbeddedRequestBuilder; import cloud.piranha.embedded.EmbeddedResponse; import cloud.piranha.embedded.EmbeddedResponseBuilder; -import cloud.piranha.extension.annotationscan.classfile.AnnotationScanInitializer; -import cloud.piranha.extension.annotationscan.classfile.internal.InternalAnnotationScanAnnotationManager; +import cloud.piranha.extension.annotationscan.AnnotationScanInitializer; +import cloud.piranha.extension.annotationscan.internal.InternalAnnotationScanAnnotationManager; import cloud.piranha.extension.webxml.WebXmlInitializer; import cloud.piranha.resource.impl.ClassResource; import cloud.piranha.resource.impl.DirectoryResource; diff --git a/extension/webprofile/pom.xml b/extension/webprofile/pom.xml index 7e2f1e776e..45f61b4aab 100644 --- a/extension/webprofile/pom.xml +++ b/extension/webprofile/pom.xml @@ -32,6 +32,12 @@ ${project.version} compile + + cloud.piranha.extension + piranha-extension-annotationscan-classfile + ${project.version} + compile + cloud.piranha.extension piranha-extension-apache-fileupload diff --git a/extension/webprofile/src/main/java/cloud/piranha/extension/webprofile/WebProfileExtension.java b/extension/webprofile/src/main/java/cloud/piranha/extension/webprofile/WebProfileExtension.java index b34637c09e..5c16bc13a0 100644 --- a/extension/webprofile/src/main/java/cloud/piranha/extension/webprofile/WebProfileExtension.java +++ b/extension/webprofile/src/main/java/cloud/piranha/extension/webprofile/WebProfileExtension.java @@ -29,7 +29,8 @@ import cloud.piranha.core.api.WebApplicationExtension; import cloud.piranha.core.api.WebApplicationExtensionContext; -import cloud.piranha.extension.annotationscan.classfile.AnnotationScanExtension; +import cloud.piranha.extension.annotationscan.AnnotationScanExtension; +import cloud.piranha.extension.annotationscan.classfile.ClassfileAnnotationScanExtension; import cloud.piranha.extension.apache.fileupload.ApacheMultiPartExtension; import cloud.piranha.extension.datasource.DefaultDatasourceExtension; import cloud.piranha.extension.eclipselink.EclipseLinkExtension; @@ -64,7 +65,7 @@ public void extend(WebApplicationExtensionContext context) { context.add(WaspJspManagerExtension.class); // addJspFile context.add(NamingExtension.class); // Naming (JNDI) context.add(WebXmlExtension.class); // web.xml - context.add(AnnotationScanExtension.class); // Annotation scanning + context.add(getAnnotationScanExtensionClass()); // Annotation scanning context.add(ServletAnnotationsExtension.class); // Servlet annotations context.add(WeldExtension.class); context.add(DefaultDatasourceExtension.class); // Default data source @@ -74,4 +75,12 @@ public void extend(WebApplicationExtensionContext context) { context.add(EclipseLinkExtension.class); // Jakarta Persistence context.add(ServletContainerInitializerExtension.class); // ServletContainerInitializer } + + private static Class getAnnotationScanExtensionClass() { + if (System.getProperty(ClassfileAnnotationScanExtension.EXPERIMENTAL_PROPERTY) != null) { + return ClassfileAnnotationScanExtension.class; // Annotation scanning using the new Classfile API + } + return AnnotationScanExtension.class; // Annotation scanning + } + } diff --git a/extension/webprofile/src/main/java/module-info.java b/extension/webprofile/src/main/java/module-info.java index d509cde54d..bf4ca8773c 100644 --- a/extension/webprofile/src/main/java/module-info.java +++ b/extension/webprofile/src/main/java/module-info.java @@ -55,6 +55,7 @@ opens cloud.piranha.extension.webprofile; requires cloud.piranha.core.api; requires cloud.piranha.extension.annotationscan; + requires cloud.piranha.extension.annotationscan.classfile; requires cloud.piranha.extension.apache.fileupload; requires cloud.piranha.extension.datasource; requires cloud.piranha.extension.eclipselink; diff --git a/micro/core/src/main/java/cloud/piranha/micro/core/MicroInnerDeployer.java b/micro/core/src/main/java/cloud/piranha/micro/core/MicroInnerDeployer.java index 733d9ae1fc..5e1d47ed4d 100644 --- a/micro/core/src/main/java/cloud/piranha/micro/core/MicroInnerDeployer.java +++ b/micro/core/src/main/java/cloud/piranha/micro/core/MicroInnerDeployer.java @@ -77,7 +77,7 @@ import cloud.piranha.core.api.WebApplicationExtension; import cloud.piranha.core.impl.DefaultWebApplication; import cloud.piranha.core.impl.DefaultWebApplicationExtensionContext; -import cloud.piranha.extension.annotationscan.classfile.internal.InternalAnnotationScanAnnotationManager; +import cloud.piranha.extension.annotationscan.internal.InternalAnnotationScanAnnotationManager; import cloud.piranha.http.api.HttpServer; import cloud.piranha.http.impl.DefaultHttpServer; import cloud.piranha.http.webapp.HttpWebApplicationServer; diff --git a/resource/impl/src/main/java/cloud/piranha/resource/impl/DefaultResourceManagerClassLoader.java b/resource/impl/src/main/java/cloud/piranha/resource/impl/DefaultResourceManagerClassLoader.java index 4e897c081e..c02ff59564 100644 --- a/resource/impl/src/main/java/cloud/piranha/resource/impl/DefaultResourceManagerClassLoader.java +++ b/resource/impl/src/main/java/cloud/piranha/resource/impl/DefaultResourceManagerClassLoader.java @@ -111,7 +111,7 @@ public DefaultResourceManagerClassLoader(ResourceManager resourceManager) { /** * Yet another Constructor. - * + * @param classLoader the class loader. * @param resourceManager the resource manager. */ public DefaultResourceManagerClassLoader(ClassLoader classLoader, ResourceManager resourceManager) {