-
Notifications
You must be signed in to change notification settings - Fork 82
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
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 |
---|---|---|
|
@@ -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; | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dropped There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implementations should already be checking that There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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; | ||
|
There was a problem hiding this comment.
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.