You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rz...@apache.org on 2022/10/04 14:19:30 UTC
[tomee] branch tomee-8.x updated: TOMEE-4057 - Ports the changes from CXF-8652 to our patched version of CXF
This is an automated email from the ASF dual-hosted git repository.
rzo1 pushed a commit to branch tomee-8.x
in repository https://gitbox.apache.org/repos/asf/tomee.git
The following commit(s) were added to refs/heads/tomee-8.x by this push:
new 42a414f99d TOMEE-4057 - Ports the changes from CXF-8652 to our patched version of CXF
42a414f99d is described below
commit 42a414f99d9a7272ce981983aaa1c46cc72c6853
Author: Richard Zowalla <ri...@hs-heilbronn.de>
AuthorDate: Tue Oct 4 16:18:01 2022 +0200
TOMEE-4057 - Ports the changes from CXF-8652 to our patched version of CXF
---
.../apache/cxf/jaxrs/provider/ProviderFactory.java | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java b/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
index 9577bcabf3..d9572e00b9 100644
--- a/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
+++ b/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
@@ -40,7 +40,9 @@ import java.util.TreeMap;
import java.util.logging.Logger;
import javax.annotation.Priority;
+import javax.ws.rs.ConstrainedTo;
import javax.ws.rs.Produces;
+import javax.ws.rs.RuntimeType;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Configuration;
import javax.ws.rs.core.MediaType;
@@ -641,7 +643,7 @@ public abstract class ProviderFactory {
protected abstract void setProviders(boolean custom, boolean busGlobal, Object... providers);
@SuppressWarnings("unchecked")
- protected void setCommonProviders(List<ProviderInfo<? extends Object>> theProviders) {
+ protected void setCommonProviders(List<ProviderInfo<? extends Object>> theProviders, RuntimeType type) {
List<ProviderInfo<ReaderInterceptor>> readInts =
new LinkedList<>();
List<ProviderInfo<WriterInterceptor>> writeInts =
@@ -649,6 +651,11 @@ public abstract class ProviderFactory {
for (ProviderInfo<? extends Object> provider : theProviders) {
Class<?> providerCls = ClassHelper.getRealClass(bus, provider.getProvider());
+ // Check if provider is constrained to runtime type
+ if (!constrainedTo(providerCls, type)) {
+ continue;
+ }
+
if (filterContractSupported(provider, providerCls, MessageBodyReader.class)) {
addProviderToList(messageReaders, provider);
}
@@ -1538,6 +1545,18 @@ public abstract class ProviderFactory {
writerInterceptors = sortedWriterInterceptors;
}
+ /**
+ * Checks the presence of {@link ConstrainedTo} annotation and, if present, applicability to
+ * the runtime type.
+ * @param providerCls provider class
+ * @param type runtime type
+ * @return "true" if provider could be used with runtime type, "false" otherwise
+ */
+ protected static boolean constrainedTo(Class<?> providerCls, RuntimeType type) {
+ final ConstrainedTo constrained = AnnotationUtils.getClassAnnotation(providerCls, ConstrainedTo.class);
+ return constrained == null || constrained.value() == type;
+ }
+
protected static class ParamConverterComparator implements Comparator<ProviderInfo<ParamConverterProvider>> {
@Override