Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move OASFactoryResolver to SPI module, bump version to 4.0-SNAPSHOT #594

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 7 additions & 17 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<!-- This is just for now and will not work if the API has a separate release cycle than the rest. -->
<groupId>org.eclipse.microprofile.openapi</groupId>
<artifactId>microprofile-openapi-parent</artifactId>
<version>3.2-SNAPSHOT</version>
<version>4.0-SNAPSHOT</version>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Module version bump required to pass biz.aQute.bnd:bnd-baseline-maven-plugin verification.

</parent>

<artifactId>microprofile-openapi-api</artifactId>
Expand All @@ -33,21 +33,11 @@
<artifactId>osgi.annotation</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.openapi</groupId>
<artifactId>microprofile-openapi-spi</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<!-- https://github.com/checkstyle/checkstyle/issues/8240 -->
<excludes>**/module-info.java</excludes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
4 changes: 3 additions & 1 deletion api/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

This file was deleted.

This file was deleted.

18 changes: 17 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<groupId>org.eclipse.microprofile.openapi</groupId>
<artifactId>microprofile-openapi-parent</artifactId>
<version>3.2-SNAPSHOT</version>
<version>4.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>MicroProfile OpenAPI</name>
<description>Eclipse MicroProfile OpenAPI</description>
Expand Down Expand Up @@ -80,11 +80,27 @@
</dependency>
</dependencies>
</dependencyManagement>

<modules>
<module>api</module>
<module>tck</module>
<module>spec</module>
<module>spi</module>
</modules>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<!-- https://github.com/checkstyle/checkstyle/issues/8240 -->
<excludes>**/module-info.java</excludes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
2 changes: 1 addition & 1 deletion spec/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<!-- This is just for now and will not work if the API has a separate release cycle than the rest. -->
<groupId>org.eclipse.microprofile.openapi</groupId>
<artifactId>microprofile-openapi-parent</artifactId>
<version>3.2-SNAPSHOT</version>
<version>4.0-SNAPSHOT</version>
</parent>

<artifactId>microprofile-openapi-spec</artifactId>
Expand Down
14 changes: 2 additions & 12 deletions spi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,17 @@
<!-- This is just for now and will not work if the API has a separate release cycle than the rest. -->
<groupId>org.eclipse.microprofile.openapi</groupId>
<artifactId>microprofile-openapi-parent</artifactId>
<version>3.2-SNAPSHOT</version>
<version>4.0-SNAPSHOT</version>
</parent>

<artifactId>microprofile-openapi-spi</artifactId>
<name>MicroProfile OpenAPI SPI</name>
<description>
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.
</description>
<description>MicroProfile OpenAPI :: SPI</description>

<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.annotation</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.openapi</groupId>
<artifactId>microprofile-openapi-api</artifactId>
</dependency>
</dependencies>
</project>
30 changes: 30 additions & 0 deletions spi/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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
* <p>
* 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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,15 @@
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.
*
* <br>
* <br>
* <p>
* 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;
Expand All @@ -55,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 extends Constructible> T createObject(Class<T> clazz);
public abstract <T> T createObject(Class<T> clazz);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped extends Constructible to avoid dependency cycle with api module.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementations should already be checking that T is Constructible and the API used by applications in OASFactory retains the Constructible type on createObject.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in #576 , this is not a great solution as it breaks compatibility with previous versions and also makes the SPI contract too loose.


/**
* Creates an OASFactoryResolver object. Only used internally from within
Expand Down Expand Up @@ -98,18 +91,16 @@ private static OASFactoryResolver loadSpi(ClassLoader cl) {
return null;
}

OASFactoryResolver instance = loadSpi(cl.getParent());
OASFactoryResolver instance = null;

if (instance == null) {
ServiceLoader<OASFactoryResolver> 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<OASFactoryResolver> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@

/**
* Service provider interface which allows vendors to set their implementations of OASFactoryResolver.
* <p>
* 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")
@org.osgi.annotation.versioning.Version("2.0")
@org.osgi.annotation.versioning.ProviderType
package org.eclipse.microprofile.openapi.spi;
2 changes: 1 addition & 1 deletion tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<!-- This is just for now and will not work if the API has a separate release cycle than the rest. -->
<groupId>org.eclipse.microprofile.openapi</groupId>
<artifactId>microprofile-openapi-parent</artifactId>
<version>3.2-SNAPSHOT</version>
<version>4.0-SNAPSHOT</version>
</parent>

<artifactId>microprofile-openapi-tck</artifactId>
Expand Down
Loading