From c9a166100761ceda9dcaee258cd0a14d0a39b41b Mon Sep 17 00:00:00 2001 From: Michael Edgar Date: Fri, 19 Jan 2024 17:57:51 -0500 Subject: [PATCH 1/2] Revert "Deprecate `spi` module and contents" This reverts commit 8bb9a44889977304ce2d7f7a1da621040b7daf7a. --- api/pom.xml | 2 +- .../openapi/annotations/responses/APIResponse.java | 8 ++++---- spi/pom.xml | 10 +++------- .../microprofile/openapi/spi/OASFactoryResolver.java | 4 ---- .../eclipse/microprofile/openapi/spi/package-info.java | 8 ++------ 5 files changed, 10 insertions(+), 22 deletions(-) diff --git a/api/pom.xml b/api/pom.xml index 466875d4f..bf7ed9351 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -25,7 +25,7 @@ microprofile-openapi-api MicroProfile OpenAPI API - MicroProfile OpenAPI :: API + MicroProfile OpenAPI API :: API diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/APIResponse.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/APIResponse.java index 6f6660362..bd65ccfd8 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/APIResponse.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/APIResponse.java @@ -46,14 +46,14 @@ * } * *

- * When this annotation is applied to a Jakarta REST resource class, the response is added to the responses defined in - * all OpenAPI operations which correspond to a method on that class. If an operation already has a response with the + * When this annotation is applied to a Jakarta REST resource class, the response is added to the responses defined in all + * OpenAPI operations which correspond to a method on that class. If an operation already has a response with the * specified responseCode the response is not added to that operation. * *

* When this annotation is applied to an ExceptionMapper class or toResponse method, it allows - * developers to describe the API response that will be added to a generated OpenAPI operation based on a Jakarta REST - * method that declares an Exception of the type handled by the ExceptionMapper. + * developers to describe the API response that will be added to a generated OpenAPI operation based on a Jakarta REST method + * that declares an Exception of the type handled by the ExceptionMapper. * *

  * @Provider
diff --git a/spi/pom.xml b/spi/pom.xml
index 8ab4eeaad..c9e7e8657 100644
--- a/spi/pom.xml
+++ b/spi/pom.xml
@@ -25,13 +25,7 @@
 
     microprofile-openapi-spi
     MicroProfile OpenAPI SPI
-    
-        MicroProfile OpenAPI :: SPI
-
-        This module is deprecated and will be removed in a future release of MicroProfile
-        OpenAPI. The functionality offered by this module is available in the microprofile-openapi-api
-        module which should be used instead.
-    
+    MicroProfile OpenAPI SPI :: SPI
 
     
         
@@ -43,4 +37,6 @@
             microprofile-openapi-api
         
     
+
+    
 
diff --git a/spi/src/main/java/org/eclipse/microprofile/openapi/spi/OASFactoryResolver.java b/spi/src/main/java/org/eclipse/microprofile/openapi/spi/OASFactoryResolver.java
index c67414f3d..bef662e52 100644
--- a/spi/src/main/java/org/eclipse/microprofile/openapi/spi/OASFactoryResolver.java
+++ b/spi/src/main/java/org/eclipse/microprofile/openapi/spi/OASFactoryResolver.java
@@ -31,11 +31,7 @@
  * Service provider for OASFactoryResolver. The implementation registers itself via the {@link java.util.ServiceLoader}
  * mechanism or by manually setting their implementation using the setInstance method.
  *
- * @deprecated the OASFactoryResolver available in module
- *             {@code org.eclipse.microprofile.openapi:microprofile-openapi-api} should be used instead of this version
- *             which will be removed in a future major release.
  */
-@Deprecated(forRemoval = true)
 public abstract class OASFactoryResolver {
 
     private static volatile OASFactoryResolver instance = null;
diff --git a/spi/src/main/java/org/eclipse/microprofile/openapi/spi/package-info.java b/spi/src/main/java/org/eclipse/microprofile/openapi/spi/package-info.java
index 2560ea61e..01cc8df45 100644
--- a/spi/src/main/java/org/eclipse/microprofile/openapi/spi/package-info.java
+++ b/spi/src/main/java/org/eclipse/microprofile/openapi/spi/package-info.java
@@ -13,11 +13,7 @@
 
 /**
  * Service provider interface which allows vendors to set their implementations of OASFactoryResolver.
- * 

- * The {@code org.eclipse.microprofile.openapi.spi} package available in module - * {@code org.eclipse.microprofile.openapi:microprofile-openapi-api} should be used instead of this version which will - * be removed in a future major release. */ -@Deprecated(forRemoval = true) + @org.osgi.annotation.versioning.Version("1.0") -package org.eclipse.microprofile.openapi.spi; +package org.eclipse.microprofile.openapi.spi; \ No newline at end of file From 3e324d60a7eda1c446dbe6a32a35e9699cedf18c Mon Sep 17 00:00:00 2001 From: Michael Edgar Date: Sat, 20 Jan 2024 09:49:16 -0500 Subject: [PATCH 2/2] Move OASFactoryResolver to SPI module, bump version to 4.0-SNAPSHOT Signed-off-by: Michael Edgar --- api/pom.xml | 26 ++-- api/src/main/java/module-info.java | 4 +- .../annotations/responses/APIResponse.java | 8 +- .../openapi/spi/OASFactoryResolver.java | 121 ------------------ .../openapi/spi/package-info.java | 20 --- pom.xml | 18 ++- spec/pom.xml | 2 +- spi/pom.xml | 10 +- spi/src/main/java/module-info.java | 30 +++++ .../openapi/spi/OASFactoryResolver.java | 27 ++-- .../openapi/spi/package-info.java | 6 +- tck/pom.xml | 2 +- 12 files changed, 80 insertions(+), 194 deletions(-) delete mode 100644 api/src/main/java/org/eclipse/microprofile/openapi/spi/OASFactoryResolver.java delete mode 100644 api/src/main/java/org/eclipse/microprofile/openapi/spi/package-info.java create mode 100644 spi/src/main/java/module-info.java diff --git a/api/pom.xml b/api/pom.xml index bf7ed9351..3edf9fab7 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -20,12 +20,12 @@ org.eclipse.microprofile.openapi microprofile-openapi-parent - 3.2-SNAPSHOT + 4.0-SNAPSHOT microprofile-openapi-api MicroProfile OpenAPI API - MicroProfile OpenAPI API :: API + MicroProfile OpenAPI :: API @@ -33,21 +33,11 @@ osgi.annotation provided + + org.eclipse.microprofile.openapi + microprofile-openapi-spi + ${project.version} + provided + - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - 3.2.1 - - - **/module-info.java - - - - - diff --git a/api/src/main/java/module-info.java b/api/src/main/java/module-info.java index e107c72ca..67479a1a7 100644 --- a/api/src/main/java/module-info.java +++ b/api/src/main/java/module-info.java @@ -17,6 +17,7 @@ * A set of Java interfaces, annotations, and programming models which allow Java developers to natively produce OpenAPI * documents from Jakarta RESTful Web Services applications. */ +@SuppressWarnings("module") // silence warning about unstable name `osgi.annotation` module org.eclipse.microprofile.openapi { exports org.eclipse.microprofile.openapi; @@ -45,7 +46,8 @@ exports org.eclipse.microprofile.openapi.models.security; exports org.eclipse.microprofile.openapi.models.servers; exports org.eclipse.microprofile.openapi.models.tags; - exports org.eclipse.microprofile.openapi.spi; + + requires org.eclipse.microprofile.openapi.spi; // Required for compilation, not used at runtime requires static osgi.annotation; diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/APIResponse.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/APIResponse.java index bd65ccfd8..6f6660362 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/APIResponse.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/APIResponse.java @@ -46,14 +46,14 @@ * } *

*

- * When this annotation is applied to a Jakarta REST resource class, the response is added to the responses defined in all - * OpenAPI operations which correspond to a method on that class. If an operation already has a response with the + * When this annotation is applied to a Jakarta REST resource class, the response is added to the responses defined in + * all OpenAPI operations which correspond to a method on that class. If an operation already has a response with the * specified responseCode the response is not added to that operation. * *

* When this annotation is applied to an ExceptionMapper class or toResponse method, it allows - * developers to describe the API response that will be added to a generated OpenAPI operation based on a Jakarta REST method - * that declares an Exception of the type handled by the ExceptionMapper. + * developers to describe the API response that will be added to a generated OpenAPI operation based on a Jakarta REST + * method that declares an Exception of the type handled by the ExceptionMapper. * *

  * @Provider
diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/spi/OASFactoryResolver.java b/api/src/main/java/org/eclipse/microprofile/openapi/spi/OASFactoryResolver.java
deleted file mode 100644
index a0b72b608..000000000
--- a/api/src/main/java/org/eclipse/microprofile/openapi/spi/OASFactoryResolver.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2017 Contributors to the Eclipse Foundation
- * 

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.eclipse.microprofile.openapi.spi; - -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.ServiceLoader; - -import org.eclipse.microprofile.openapi.models.Constructible; - -/** - * This class is not intended to be used by end-users. It should be used by vendors to set their implementation of - * OASFactoryResolver. - * - *
- *
- * Service provider for OASFactoryResolver. The implementation registers itself via the {@link java.util.ServiceLoader} - * mechanism or by manually setting their implementation using the setInstance method. - * - */ -public abstract class OASFactoryResolver { - - private static volatile OASFactoryResolver instance = null; - - /** - * Create a new instance of a constructible element from the OpenAPI model tree. - * - * @param - * describes the type parameter - * @param clazz - * represents a model which extends the org.eclipse.microprofile.openapi.models.Constructible interface - * - * @return a new instance of the requested model class - * - * @throws NullPointerException - * if the specified class is null - * @throws IllegalArgumentException - * if an instance could not be created, most likely, due to an illegal or inappropriate class - */ - public abstract T createObject(Class clazz); - - /** - * Creates an OASFactoryResolver object. Only used internally from within - * {@link org.eclipse.microprofile.openapi.OASFactory} - * - * @return an instance of OASFactoryResolver - */ - public static OASFactoryResolver instance() { - if (instance == null) { - synchronized (OASFactoryResolver.class) { - if (instance != null) { - return instance; - } - - ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction() { - @Override - public ClassLoader run() { - return Thread.currentThread().getContextClassLoader(); - } - }); - if (cl == null) { - cl = OASFactoryResolver.class.getClassLoader(); - } - - OASFactoryResolver newInstance = loadSpi(cl); - - if (newInstance == null) { - throw new IllegalStateException("No OASFactoryResolver implementation found!"); - } - - instance = newInstance; - } - } - - return instance; - } - - private static OASFactoryResolver loadSpi(ClassLoader cl) { - if (cl == null) { - return null; - } - - OASFactoryResolver instance = null; - - ServiceLoader sl = ServiceLoader.load(OASFactoryResolver.class, cl); - for (OASFactoryResolver spi : sl) { - if (instance != null) { - throw new IllegalStateException( - "Multiple OASFactoryResolver implementations found: " + spi.getClass().getName() + " and " - + instance.getClass().getName()); - } else { - instance = spi; - } - } - return instance; - } - - /** - * Set the instance. It is used by OSGi environment while service loader pattern is not supported. - * - * @param factory - * set the instance. - */ - public static void setInstance(OASFactoryResolver factory) { - instance = factory; - } -} diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/spi/package-info.java b/api/src/main/java/org/eclipse/microprofile/openapi/spi/package-info.java deleted file mode 100644 index 0512e05cd..000000000 --- a/api/src/main/java/org/eclipse/microprofile/openapi/spi/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2017 Contributors to the Eclipse Foundation - *

- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations - * under the License. - */ - -/** - * Service provider interface which allows vendors to set their implementations of OASFactoryResolver. - */ - -@org.osgi.annotation.versioning.Version("1.0") -@org.osgi.annotation.versioning.ProviderType -package org.eclipse.microprofile.openapi.spi; \ No newline at end of file diff --git a/pom.xml b/pom.xml index 988797088..fde0114f9 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ org.eclipse.microprofile.openapi microprofile-openapi-parent - 3.2-SNAPSHOT + 4.0-SNAPSHOT pom MicroProfile OpenAPI Eclipse MicroProfile OpenAPI @@ -80,6 +80,7 @@ + api tck @@ -87,4 +88,19 @@ spi + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.2.1 + + + **/module-info.java + + + + + diff --git a/spec/pom.xml b/spec/pom.xml index 05d679445..336955778 100644 --- a/spec/pom.xml +++ b/spec/pom.xml @@ -20,7 +20,7 @@ org.eclipse.microprofile.openapi microprofile-openapi-parent - 3.2-SNAPSHOT + 4.0-SNAPSHOT microprofile-openapi-spec diff --git a/spi/pom.xml b/spi/pom.xml index c9e7e8657..0112f2c0c 100644 --- a/spi/pom.xml +++ b/spi/pom.xml @@ -20,23 +20,17 @@ org.eclipse.microprofile.openapi microprofile-openapi-parent - 3.2-SNAPSHOT + 4.0-SNAPSHOT microprofile-openapi-spi MicroProfile OpenAPI SPI - MicroProfile OpenAPI SPI :: SPI + MicroProfile OpenAPI :: SPI org.osgi osgi.annotation - - org.eclipse.microprofile.openapi - microprofile-openapi-api - - - diff --git a/spi/src/main/java/module-info.java b/spi/src/main/java/module-info.java new file mode 100644 index 000000000..6fe2d137b --- /dev/null +++ b/spi/src/main/java/module-info.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 Contributors to the Eclipse Foundation + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations + * under the License. + */ + +/** + * Eclipse MicroProfile OpenAPI SPI + *

+ * This module is not intended to be used by end-users. It should be used by vendors to set their implementation of + * OASFactoryResolver. + */ +@SuppressWarnings("module") // silence warning about unstable name `osgi.annotation` +module org.eclipse.microprofile.openapi.spi { + + exports org.eclipse.microprofile.openapi.spi; + + uses org.eclipse.microprofile.openapi.spi.OASFactoryResolver; + + // Required for compilation, not used at runtime + requires static osgi.annotation; + +} diff --git a/spi/src/main/java/org/eclipse/microprofile/openapi/spi/OASFactoryResolver.java b/spi/src/main/java/org/eclipse/microprofile/openapi/spi/OASFactoryResolver.java index bef662e52..531d67dd2 100644 --- a/spi/src/main/java/org/eclipse/microprofile/openapi/spi/OASFactoryResolver.java +++ b/spi/src/main/java/org/eclipse/microprofile/openapi/spi/OASFactoryResolver.java @@ -20,14 +20,11 @@ import java.security.PrivilegedAction; import java.util.ServiceLoader; -import org.eclipse.microprofile.openapi.models.Constructible; - /** * This class is not intended to be used by end-users. It should be used by vendors to set their implementation of * OASFactoryResolver. * - *
- *
+ *

* Service provider for OASFactoryResolver. The implementation registers itself via the {@link java.util.ServiceLoader} * mechanism or by manually setting their implementation using the setInstance method. * @@ -51,7 +48,7 @@ public abstract class OASFactoryResolver { * @throws IllegalArgumentException * if an instance could not be created, most likely, due to an illegal or inappropriate class */ - public abstract T createObject(Class clazz); + public abstract T createObject(Class clazz); /** * Creates an OASFactoryResolver object. Only used internally from within @@ -94,18 +91,16 @@ private static OASFactoryResolver loadSpi(ClassLoader cl) { return null; } - OASFactoryResolver instance = loadSpi(cl.getParent()); + OASFactoryResolver instance = null; - if (instance == null) { - ServiceLoader sl = ServiceLoader.load(OASFactoryResolver.class, cl); - for (OASFactoryResolver spi : sl) { - if (instance != null) { - throw new IllegalStateException( - "Multiple OASFactoryResolver implementations found: " + spi.getClass().getName() + " and " - + instance.getClass().getName()); - } else { - instance = spi; - } + ServiceLoader sl = ServiceLoader.load(OASFactoryResolver.class, cl); + for (OASFactoryResolver spi : sl) { + if (instance != null) { + throw new IllegalStateException( + "Multiple OASFactoryResolver implementations found: " + spi.getClass().getName() + " and " + + instance.getClass().getName()); + } else { + instance = spi; } } return instance; diff --git a/spi/src/main/java/org/eclipse/microprofile/openapi/spi/package-info.java b/spi/src/main/java/org/eclipse/microprofile/openapi/spi/package-info.java index 01cc8df45..d6129f3d6 100644 --- a/spi/src/main/java/org/eclipse/microprofile/openapi/spi/package-info.java +++ b/spi/src/main/java/org/eclipse/microprofile/openapi/spi/package-info.java @@ -14,6 +14,6 @@ /** * Service provider interface which allows vendors to set their implementations of OASFactoryResolver. */ - -@org.osgi.annotation.versioning.Version("1.0") -package org.eclipse.microprofile.openapi.spi; \ No newline at end of file +@org.osgi.annotation.versioning.Version("2.0") +@org.osgi.annotation.versioning.ProviderType +package org.eclipse.microprofile.openapi.spi; diff --git a/tck/pom.xml b/tck/pom.xml index 85370aba4..f2e5dfbe0 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -20,7 +20,7 @@ org.eclipse.microprofile.openapi microprofile-openapi-parent - 3.2-SNAPSHOT + 4.0-SNAPSHOT microprofile-openapi-tck