From b4af8a3ffde589e32b56a0683b8da114e58c1dd3 Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Wed, 22 Mar 2023 12:35:09 +1300 Subject: [PATCH 01/28] Update dependencies to Jakarta EE 10 --- distribution/javadoc/pom.xml | 1 - distribution/manifest/pom.xml | 3 - integration/cdi/pom.xml | 1 - integration/spring-boot/autoconfigure/pom.xml | 6 - maven-plugins/codegen-plugin/pom.xml | 1 - parent/pom.xml | 138 ++---------------- rt/frontend/jaxrs/pom.xml | 1 - rt/rs/extensions/search/pom.xml | 1 - rt/rs/security/oauth-parent/oauth2/pom.xml | 2 - rt/rs/security/sso/oidc/pom.xml | 1 - systests/microprofile/client/async/pom.xml | 3 - systests/microprofile/client/nocdi/pom.xml | 3 - systests/microprofile/pom.xml | 11 -- systests/rs-security/pom.xml | 1 - tools/common/pom.xml | 1 - 15 files changed, 9 insertions(+), 165 deletions(-) diff --git a/distribution/javadoc/pom.xml b/distribution/javadoc/pom.xml index a6155815515..aabd8a591f4 100644 --- a/distribution/javadoc/pom.xml +++ b/distribution/javadoc/pom.xml @@ -348,7 +348,6 @@ jakarta.persistence jakarta.persistence-api - ${cxf.persistence-api.version} org.apache.lucene diff --git a/distribution/manifest/pom.xml b/distribution/manifest/pom.xml index 765caf0cece..250d073a06e 100644 --- a/distribution/manifest/pom.xml +++ b/distribution/manifest/pom.xml @@ -320,7 +320,6 @@ jakarta.xml.ws jakarta.xml.ws-api - ${cxf.jakarta.wsapi.version} jakarta.xml.bind @@ -329,12 +328,10 @@ jakarta.jws jakarta.jws-api - ${cxf.jakarta.jwsapi.version} jakarta.xml.soap jakarta.xml.soap-api - ${cxf.jakarta.soapapi.version} diff --git a/integration/cdi/pom.xml b/integration/cdi/pom.xml index 0296b51cbd1..31dfbe0eaea 100644 --- a/integration/cdi/pom.xml +++ b/integration/cdi/pom.xml @@ -52,7 +52,6 @@ jakarta.inject jakarta.inject-api - ${cxf.jakarta.injectapi.version} junit diff --git a/integration/spring-boot/autoconfigure/pom.xml b/integration/spring-boot/autoconfigure/pom.xml index 09c17887d8c..86d09ae7b63 100644 --- a/integration/spring-boot/autoconfigure/pom.xml +++ b/integration/spring-boot/autoconfigure/pom.xml @@ -114,12 +114,6 @@ ${project.version} true - - ${cxf.servlet-api.group} - ${cxf.servlet-api.artifact} - ${cxf.servlet-api.version} - true - jakarta.validation jakarta.validation-api diff --git a/maven-plugins/codegen-plugin/pom.xml b/maven-plugins/codegen-plugin/pom.xml index c608d8ce854..1433a78d314 100644 --- a/maven-plugins/codegen-plugin/pom.xml +++ b/maven-plugins/codegen-plugin/pom.xml @@ -199,7 +199,6 @@ jakarta.xml.bind jakarta.xml.bind-api - ${cxf.jaxb.version} diff --git a/parent/pom.xml b/parent/pom.xml index 96736acd4b8..167cd4735c5 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -112,7 +112,6 @@ 3.2.6 4.2.21 3.10.8 - 3.0.3 3.0.2 2.1.1 1.1.1 @@ -136,23 +135,12 @@ 2.15.3 3.9 1.8.1 - 2.1.2 - 2.1.2 - 2.0.1 + 10.0.0 3.0.0 - 2.0.1 - 3.0.1 - 3.1.0 - 2.0.1 - 4.0.1 - 2.1.0 1.1.4 0.7.2 3.29.2-GA - 2.1.1 - 3.0.0 - 3.0.2 - 3.0.1 + 4.0.2 ${cxf.jaxb.runtime.version} 2.0.0 3.5.3.Final @@ -166,8 +154,6 @@ 3.3 2.10.10 1.2.20 - 2.0.1 - 2.0.0 1.0 4.13.2 5.10.0 @@ -195,7 +181,6 @@ 1.22.0-alpha 0.33.0 2.0.27 - 3.0.0 4.8.0 3.5.1 1.0.4 @@ -207,7 +192,6 @@ 2.0.1 jakarta.servlet-api jakarta.servlet - 5.0.0 2.0.9 2.2 2.3_2 @@ -223,12 +207,6 @@ 10.1.14 1.8 2.2.20.Final - - - [3,4) - 3.0.2 2.3 1.6.0.Final 3.2.0 @@ -766,27 +744,15 @@ logback-classic ${cxf.logback.classic.version} + - jakarta.transaction - jakarta.transaction-api - ${cxf.jakarta.transaction.version} - - - jakarta.ws.rs - jakarta.ws.rs-api - ${cxf.jakarta.ws.rs.version} - - - jakarta.xml.bind - jakarta.xml.bind-api - ${cxf.jaxb.version} - - - com.sun.activation - jakarta.activation - - + jakarta.platform + jakarta.jakartaee-bom + ${cxf.jakarta.ee.version} + pom + import + cglib cglib-nodep @@ -1044,35 +1010,6 @@ - - jakarta.validation - jakarta.validation-api - ${cxf.validation.api.version} - true - - - jakarta.enterprise - jakarta.enterprise.cdi-api - ${cxf.cdi.api.version} - true - - - jakarta.inject - jakarta.inject-api - ${cxf.jakarta.injectapi.version} - true - - - jakarta.json - jakarta.json-api - ${cxf.json.api.version} - true - - - jakarta.json.bind - jakarta.json.bind-api - ${cxf.json.bind-api.version} - org.glassfish jakarta.json @@ -1633,43 +1570,11 @@ - - jakarta.annotation - jakarta.annotation-api - ${cxf.jakarta.annotation-api.version} - - - jakarta.xml.ws - jakarta.xml.ws-api - ${cxf.jakarta.wsapi.version} - - - com.sun.activation - jakarta.activation - - - jakarta.jws jakarta.jws-api ${cxf.jakarta.jwsapi.version} - - jakarta.xml.soap - jakarta.xml.soap-api - ${cxf.jakarta.soapapi.version} - - - com.sun.activation - jakarta.activation - - - - - ${cxf.servlet-api.group} - ${cxf.servlet-api.artifact} - ${cxf.servlet-api.version} - com.sun.xml.messaging.saaj saaj-impl @@ -1681,21 +1586,11 @@ - - jakarta.activation - jakarta.activation-api - ${cxf.jakarta.activation.version} - org.eclipse.angus angus-activation ${cxf.jakarta.angus.activation.version} - - jakarta.mail - jakarta.mail-api - ${cxf.jakarta.mail.version} - org.eclipse.angus angus-mail @@ -1706,21 +1601,6 @@ jakarta.management.j2ee-api ${cxf.jakarta.management.j2ee-api.version} - - jakarta.jms - jakarta.jms-api - ${cxf.jakarta.jms.version} - - - jakarta.resource - jakarta.resource-api - ${cxf.jakarta.resource.version} - - - jakarta.ejb - jakarta.ejb-api - ${cxf.jakarta.ejb.version} - org.apache.activemq artemis-jakarta-server diff --git a/rt/frontend/jaxrs/pom.xml b/rt/frontend/jaxrs/pom.xml index 7a11e12f1ed..3d3bde9b886 100644 --- a/rt/frontend/jaxrs/pom.xml +++ b/rt/frontend/jaxrs/pom.xml @@ -106,7 +106,6 @@ jakarta.servlet jakarta.servlet-api - ${cxf.servlet-api.version} provided true diff --git a/rt/rs/extensions/search/pom.xml b/rt/rs/extensions/search/pom.xml index 79c2e00e90e..5a13dcb6d2c 100644 --- a/rt/rs/extensions/search/pom.xml +++ b/rt/rs/extensions/search/pom.xml @@ -64,7 +64,6 @@ jakarta.persistence jakarta.persistence-api - ${cxf.persistence-api.version} provided true diff --git a/rt/rs/security/oauth-parent/oauth2/pom.xml b/rt/rs/security/oauth-parent/oauth2/pom.xml index 0c00a0e25f6..fce283d3fa6 100644 --- a/rt/rs/security/oauth-parent/oauth2/pom.xml +++ b/rt/rs/security/oauth-parent/oauth2/pom.xml @@ -72,7 +72,6 @@ jakarta.persistence jakarta.persistence-api - ${cxf.persistence-api.version} provided true @@ -270,4 +269,3 @@ - diff --git a/rt/rs/security/sso/oidc/pom.xml b/rt/rs/security/sso/oidc/pom.xml index 4414fd18429..ce96b79368d 100644 --- a/rt/rs/security/sso/oidc/pom.xml +++ b/rt/rs/security/sso/oidc/pom.xml @@ -51,7 +51,6 @@ jakarta.persistence jakarta.persistence-api - ${cxf.persistence-api.version} provided true diff --git a/systests/microprofile/client/async/pom.xml b/systests/microprofile/client/async/pom.xml index 30d46959d64..1076ba6969d 100644 --- a/systests/microprofile/client/async/pom.xml +++ b/systests/microprofile/client/async/pom.xml @@ -49,7 +49,6 @@ jakarta.ws.rs jakarta.ws.rs-api - ${cxf.jakarta.ws.rs.version} org.jboss.weld.se @@ -79,13 +78,11 @@ jakarta.json.bind jakarta.json.bind-api - ${cxf.json.bind-api.version} test jakarta.json jakarta.json-api - ${cxf.json.api.version} test diff --git a/systests/microprofile/client/nocdi/pom.xml b/systests/microprofile/client/nocdi/pom.xml index 4048f2520dc..d9b74f0b4ed 100644 --- a/systests/microprofile/client/nocdi/pom.xml +++ b/systests/microprofile/client/nocdi/pom.xml @@ -49,7 +49,6 @@ jakarta.ws.rs jakarta.ws.rs-api - ${cxf.jakarta.ws.rs.version} org.eclipse.microprofile.rest.client @@ -67,13 +66,11 @@ jakarta.json.bind jakarta.json.bind-api - ${cxf.json.bind-api.version} test jakarta.json jakarta.json-api - ${cxf.json.api.version} test diff --git a/systests/microprofile/pom.xml b/systests/microprofile/pom.xml index 25c8193fe95..00e2a352489 100644 --- a/systests/microprofile/pom.xml +++ b/systests/microprofile/pom.xml @@ -55,11 +55,6 @@ ${cxf.commons-logging.version} test - - jakarta.ws.rs - jakarta.ws.rs-api - ${cxf.jakarta.ws.rs.version} - org.jboss.weld.se weld-se-core @@ -85,12 +80,6 @@ jakarta test - - jakarta.json - jakarta.json-api - ${cxf.json.api.version} - test - org.slf4j slf4j-jdk14 diff --git a/systests/rs-security/pom.xml b/systests/rs-security/pom.xml index 52c6c6e00ef..6a3cc3325ea 100644 --- a/systests/rs-security/pom.xml +++ b/systests/rs-security/pom.xml @@ -206,7 +206,6 @@ jakarta.persistence jakarta.persistence-api - ${cxf.persistence-api.version} test diff --git a/tools/common/pom.xml b/tools/common/pom.xml index 427923942dc..93eb1da06db 100644 --- a/tools/common/pom.xml +++ b/tools/common/pom.xml @@ -41,7 +41,6 @@ jakarta.jws jakarta.jws-api - ${cxf.jakarta.jwsapi.version} org.apache.velocity From f8f3e0d87221242c0b6a187c8ff66afa433ac143 Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Wed, 22 Mar 2023 13:09:04 +1300 Subject: [PATCH 02/28] Remove unnecessary dependency on jakarta.xml.bind-api MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It didn’t respect the Jakarta EE 10 BOM for some reason, and it doesn’t (yet?) appear to be necessary --- maven-plugins/codegen-plugin/pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/maven-plugins/codegen-plugin/pom.xml b/maven-plugins/codegen-plugin/pom.xml index 1433a78d314..6c9da8e7004 100644 --- a/maven-plugins/codegen-plugin/pom.xml +++ b/maven-plugins/codegen-plugin/pom.xml @@ -195,12 +195,6 @@ - - - jakarta.xml.bind - jakarta.xml.bind-api - - From d10f665f06f7d607e83474fadfdd30088d901c4f Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Wed, 22 Mar 2023 13:15:37 +1300 Subject: [PATCH 03/28] Servlet API 6.0.0 --- integration/spring-boot/autoconfigure/pom.xml | 5 +++ .../tl/ThreadLocalHttpServletRequest.java | 26 ++++++++++------ .../tl/ThreadLocalHttpServletResponse.java | 15 --------- .../impl/tl/ThreadLocalServletContext.java | 20 ------------ .../HttpServletRequestAdapter.java | 16 ++++++++++ .../servlet/NettyHttpServletRequest.java | 28 ++++++++++------- .../server/servlet/NettyHttpSession.java | 31 ------------------- .../server/servlet/NettyServletContext.java | 25 --------------- rt/transports/websocket/pom.xml | 10 ++++++ .../jetty/WebSocketVirtualServletRequest.java | 30 +++++++++++------- .../WebSocketVirtualServletResponse.java | 24 -------------- .../WebSocketUndertowServletRequest.java | 28 ++++++++++------- .../WebSocketUndertowServletResponse.java | 24 -------------- 13 files changed, 97 insertions(+), 185 deletions(-) diff --git a/integration/spring-boot/autoconfigure/pom.xml b/integration/spring-boot/autoconfigure/pom.xml index 86d09ae7b63..f44ff9b9fd4 100644 --- a/integration/spring-boot/autoconfigure/pom.xml +++ b/integration/spring-boot/autoconfigure/pom.xml @@ -119,6 +119,11 @@ jakarta.validation-api true + + jakarta.servlet + jakarta.servlet-api + true + io.micrometer micrometer-core diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpServletRequest.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpServletRequest.java index e8174623dbf..27b7bdc79dd 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpServletRequest.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpServletRequest.java @@ -31,6 +31,7 @@ import jakarta.servlet.AsyncContext; import jakarta.servlet.DispatcherType; import jakarta.servlet.RequestDispatcher; +import jakarta.servlet.ServletConnection; import jakarta.servlet.ServletContext; import jakarta.servlet.ServletException; import jakarta.servlet.ServletInputStream; @@ -134,11 +135,6 @@ public boolean isRequestedSessionIdFromURL() { return get().isRequestedSessionIdFromURL(); } - @SuppressWarnings("deprecation") - public boolean isRequestedSessionIdFromUrl() { - return get().isRequestedSessionIdFromUrl(); - } - public boolean isRequestedSessionIdValid() { return get().isRequestedSessionIdValid(); } @@ -215,11 +211,6 @@ public BufferedReader getReader() throws IOException { return get().getReader(); } - @SuppressWarnings("deprecation") - public String getRealPath(String path) { - return get().getRealPath(path); - } - public String getRemoteAddr() { return get().getRemoteAddr(); } @@ -326,4 +317,19 @@ public T upgrade(Class handlerClass) throws IO ServletException { return get().upgrade(handlerClass); } + + @Override + public String getRequestId() { + return get().getRequestId(); + } + + @Override + public String getProtocolRequestId() { + return get().getProtocolRequestId(); + } + + @Override + public ServletConnection getServletConnection() { + return get().getServletConnection(); + } } diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpServletResponse.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpServletResponse.java index 9cf2f944ad5..0b886b1aa6b 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpServletResponse.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpServletResponse.java @@ -58,20 +58,10 @@ public String encodeRedirectURL(String url) { return get().encodeRedirectURL(url); } - @SuppressWarnings("deprecation") - public String encodeRedirectUrl(String url) { - return get().encodeRedirectUrl(url); - } - public String encodeURL(String url) { return get().encodeURL(url); } - @SuppressWarnings("deprecation") - public String encodeUrl(String url) { - return get().encodeUrl(url); - } - public void sendError(int sc) throws IOException { get().sendError(sc); } @@ -102,11 +92,6 @@ public void setStatus(int sc) { } - @SuppressWarnings("deprecation") - public void setStatus(int sc, String sm) { - get().setStatus(sc, sm); - } - public void flushBuffer() throws IOException { get().flushBuffer(); diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalServletContext.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalServletContext.java index 5681cc15ea3..5e204915332 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalServletContext.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalServletContext.java @@ -110,34 +110,14 @@ public String getServerInfo() { return get().getServerInfo(); } - @SuppressWarnings("deprecation") - public Servlet getServlet(String name) throws ServletException { - return get().getServlet(name); - } - public String getServletContextName() { return get().getServletContextName(); } - @SuppressWarnings("deprecation") - public Enumeration getServletNames() { - return get().getServletNames(); - } - - @SuppressWarnings("deprecation") - public Enumeration getServlets() { - return get().getServlets(); - } - public void log(String msg) { get().log(msg); } - @SuppressWarnings("deprecation") - public void log(Exception exception, String msg) { - get().log(exception, msg); - } - public void log(String message, Throwable throwable) { get().log(message, throwable); } diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/transport/http_jaxws_spi/HttpServletRequestAdapter.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/transport/http_jaxws_spi/HttpServletRequestAdapter.java index 74af87b4161..45e6c790e77 100644 --- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/transport/http_jaxws_spi/HttpServletRequestAdapter.java +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/transport/http_jaxws_spi/HttpServletRequestAdapter.java @@ -38,6 +38,7 @@ import jakarta.servlet.DispatcherType; import jakarta.servlet.ReadListener; import jakarta.servlet.RequestDispatcher; +import jakarta.servlet.ServletConnection; import jakarta.servlet.ServletContext; import jakarta.servlet.ServletException; import jakarta.servlet.ServletInputStream; @@ -452,4 +453,19 @@ public String changeSessionId() { public T upgrade(Class cls) throws IOException, ServletException { throw new UnsupportedOperationException(); } + + @Override + public String getRequestId() { + throw new UnsupportedOperationException(); + } + + @Override + public String getProtocolRequestId() { + throw new UnsupportedOperationException(); + } + + @Override + public ServletConnection getServletConnection() { + throw new UnsupportedOperationException(); + } } diff --git a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpServletRequest.java b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpServletRequest.java index e4c3f4819f9..98827bae869 100644 --- a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpServletRequest.java +++ b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpServletRequest.java @@ -40,6 +40,7 @@ import jakarta.servlet.AsyncContext; import jakarta.servlet.DispatcherType; import jakarta.servlet.RequestDispatcher; +import jakarta.servlet.ServletConnection; import jakarta.servlet.ServletContext; import jakarta.servlet.ServletException; import jakarta.servlet.ServletInputStream; @@ -450,12 +451,6 @@ public boolean isRequestedSessionIdFromURL() { "Method 'isRequestedSessionIdFromURL' not yet implemented!"); } - @Override - public boolean isRequestedSessionIdFromUrl() { - throw new IllegalStateException( - "Method 'isRequestedSessionIdFromUrl' not yet implemented!"); - } - @Override public boolean isRequestedSessionIdValid() { return false; @@ -467,12 +462,6 @@ public boolean isUserInRole(String role) { "Method 'isUserInRole' not yet implemented!"); } - @Override - public String getRealPath(String path) { - throw new IllegalStateException( - "Method 'getRealPath' not yet implemented!"); - } - @Override public RequestDispatcher getRequestDispatcher(String path) { throw new IllegalStateException( @@ -555,4 +544,19 @@ public T upgrade(Class handlerClass) throws IOException, ServletException { throw new IllegalStateException("Method 'upgrade' not yet implemented!"); } + + @Override + public String getRequestId() { + throw new IllegalStateException("Method 'getRequestId' not yet implemented!"); + } + + @Override + public String getProtocolRequestId() { + throw new IllegalStateException("Method 'getProtocolRequestId' not yet implemented!"); + } + + @Override + public ServletConnection getServletConnection() { + throw new IllegalStateException("Method 'getServletConnection' not yet implemented!"); + } } diff --git a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpSession.java b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpSession.java index a22f41eb7c6..5b5b79821d8 100644 --- a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpSession.java +++ b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpSession.java @@ -82,27 +82,6 @@ public ServletContext getServletContext() { return null; } - @SuppressWarnings("deprecation") - @Override - public jakarta.servlet.http.HttpSessionContext getSessionContext() { - throw new IllegalStateException( - "As of Version 2.1, this method is deprecated and has no replacement."); - } - - @Override - public Object getValue(String name) { - return getAttribute(name); - } - - @Override - public String[] getValueNames() { - if (attributes == null) { - return null; - } - return attributes.keySet().toArray( - new String[attributes.keySet().size()]); - } - @Override public void invalidate() { if (attributes != null) { @@ -110,11 +89,6 @@ public void invalidate() { } } - @Override - public void putValue(String name, Object value) { - this.setAttribute(name, value); - } - @Override public void removeAttribute(String name) { if (attributes != null) { @@ -128,11 +102,6 @@ public void removeAttribute(String name) { } } - @Override - public void removeValue(String name) { - this.removeAttribute(name); - } - @Override public void setAttribute(String name, Object value) { if (attributes == null) { diff --git a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyServletContext.java b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyServletContext.java index 58570f162ec..3ac36604c2f 100644 --- a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyServletContext.java +++ b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyServletContext.java @@ -130,11 +130,6 @@ public void log(String msg) { LOG.info(msg); } - @Override - public void log(Exception exception, String msg) { - LOG.log(Level.SEVERE, msg, exception); - } - @Override public void log(String message, Throwable throwable) { LOG.log(Level.SEVERE, message, throwable); @@ -164,26 +159,6 @@ void setServletContextName(String servletContextName) { this.servletContextName = servletContextName; } - @Override - public Servlet getServlet(String name) throws ServletException { - throw new IllegalStateException( - "Deprecated as of Java Servlet API 2.1, with no direct replacement!"); - } - - @SuppressWarnings("rawtypes") - @Override - public Enumeration getServletNames() { - throw new IllegalStateException( - "Method 'getServletNames' deprecated as of Java Servlet API 2.0, with no replacement."); - } - - @SuppressWarnings("rawtypes") - @Override - public Enumeration getServlets() { - throw new IllegalStateException( - "Method 'getServlets' deprecated as of Java Servlet API 2.0, with no replacement."); - } - @Override public ServletContext getContext(String uripath) { return this; diff --git a/rt/transports/websocket/pom.xml b/rt/transports/websocket/pom.xml index 7b133288b6f..8730e097edd 100644 --- a/rt/transports/websocket/pom.xml +++ b/rt/transports/websocket/pom.xml @@ -103,6 +103,10 @@ org.eclipse.jetty.orbit jakarta.servlet + + org.eclipse.jetty.toolchain + jetty-jakarta-servlet-api + @@ -144,6 +148,12 @@ org.eclipse.jetty.websocket websocket-jetty-server ${cxf.jetty11.version} + + + org.eclipse.jetty.toolchain + jetty-jakarta-servlet-api + + org.eclipse.jetty.websocket diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletRequest.java b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletRequest.java index c9439375f17..e0035ac6238 100644 --- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletRequest.java +++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletRequest.java @@ -40,6 +40,7 @@ import jakarta.servlet.DispatcherType; import jakarta.servlet.ReadListener; import jakarta.servlet.RequestDispatcher; +import jakarta.servlet.ServletConnection; import jakarta.servlet.ServletContext; import jakarta.servlet.ServletException; import jakarta.servlet.ServletInputStream; @@ -237,12 +238,6 @@ public BufferedReader getReader() throws IOException { return new BufferedReader(new InputStreamReader(in, UTF_8)); } - @Override - public String getRealPath(String path) { - LOG.log(Level.FINE, "getRealPath"); - return null; - } - @Override public String getRemoteAddr() { LOG.log(Level.FINE, "getRemoteAddr"); @@ -513,12 +508,6 @@ public boolean isRequestedSessionIdFromURL() { return false; } - @Override - public boolean isRequestedSessionIdFromUrl() { - LOG.log(Level.FINE, "isRequestedSessionIdFromUrl"); - return false; - } - @Override public boolean isRequestedSessionIdValid() { LOG.log(Level.FINE, "isRequestedSessionIdValid"); @@ -556,4 +545,21 @@ public String changeSessionId() { public T upgrade(Class arg0) throws IOException, ServletException { throw new UnsupportedOperationException(); } + + @Override + public String getRequestId() { + LOG.log(Level.FINE, "getRequestId"); + return null; + } + + @Override + public String getProtocolRequestId() { + LOG.log(Level.FINE, "getProtocolRequestId"); + return null; + } + + @Override + public ServletConnection getServletConnection() { + throw new UnsupportedOperationException(); + } } diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletResponse.java b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletResponse.java index 6084bdac8b6..f8248889665 100644 --- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletResponse.java +++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletResponse.java @@ -192,14 +192,6 @@ public String encodeRedirectURL(String url) { return null; } - @Override - public String encodeRedirectUrl(String url) { - if (LOG.isLoggable(Level.FINE)) { - LOG.log(Level.FINE, "encodeRedirectUrl({0})", url); - } - return null; - } - @Override public String encodeURL(String url) { if (LOG.isLoggable(Level.FINE)) { @@ -208,14 +200,6 @@ public String encodeURL(String url) { return null; } - @Override - public String encodeUrl(String url) { - if (LOG.isLoggable(Level.FINE)) { - LOG.log(Level.FINE, "encodeUrl({0})", url); - } - return null; - } - @Override public String getHeader(String name) { if (LOG.isLoggable(Level.FINE)) { @@ -303,14 +287,6 @@ public void setStatus(int sc) { responseHeaders.put(WebSocketUtils.SC_KEY, Integer.toString(sc)); } - @Override - public void setStatus(int sc, String sm) { - if (LOG.isLoggable(Level.FINE)) { - LOG.log(Level.FINE, "setStatus({0}, {1})", new Object[]{sc, sm}); - } - responseHeaders.put(WebSocketUtils.SC_KEY, Integer.toString(sc)); - } - private ServletOutputStream createOutputStream() { //REVISIT // This output buffering is needed as the server side websocket does diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/undertow/WebSocketUndertowServletRequest.java b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/undertow/WebSocketUndertowServletRequest.java index 74441764688..465ba87ee3b 100644 --- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/undertow/WebSocketUndertowServletRequest.java +++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/undertow/WebSocketUndertowServletRequest.java @@ -42,6 +42,7 @@ import jakarta.servlet.DispatcherType; import jakarta.servlet.ReadListener; import jakarta.servlet.RequestDispatcher; +import jakarta.servlet.ServletConnection; import jakarta.servlet.ServletContext; import jakarta.servlet.ServletException; import jakarta.servlet.ServletInputStream; @@ -260,12 +261,6 @@ public BufferedReader getReader() throws IOException { return new BufferedReader(new InputStreamReader(in, UTF_8)); } - @Override - public String getRealPath(String path) { - LOG.log(Level.FINE, "getRealPath"); - return null; - } - @Override public String getRemoteAddr() { LOG.log(Level.FINE, "getRemoteAddr"); @@ -538,12 +533,6 @@ public boolean isRequestedSessionIdFromURL() { return false; } - @Override - public boolean isRequestedSessionIdFromUrl() { - LOG.log(Level.FINE, "isRequestedSessionIdFromUrl"); - return false; - } - @Override public boolean isRequestedSessionIdValid() { LOG.log(Level.FINE, "isRequestedSessionIdValid"); @@ -581,4 +570,19 @@ public String changeSessionId() { public T upgrade(Class arg0) throws IOException, ServletException { throw new UnsupportedOperationException(); } + + @Override + public String getRequestId() { + throw new UnsupportedOperationException(); + } + + @Override + public String getProtocolRequestId() { + throw new UnsupportedOperationException(); + } + + @Override + public ServletConnection getServletConnection() { + throw new UnsupportedOperationException(); + } } diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/undertow/WebSocketUndertowServletResponse.java b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/undertow/WebSocketUndertowServletResponse.java index 5268bdac736..35a6309e7c4 100644 --- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/undertow/WebSocketUndertowServletResponse.java +++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/undertow/WebSocketUndertowServletResponse.java @@ -196,14 +196,6 @@ public String encodeRedirectURL(String url) { return null; } - @Override - public String encodeRedirectUrl(String url) { - if (LOG.isLoggable(Level.FINE)) { - LOG.log(Level.FINE, "encodeRedirectUrl({0})", url); - } - return null; - } - @Override public String encodeURL(String url) { if (LOG.isLoggable(Level.FINE)) { @@ -212,14 +204,6 @@ public String encodeURL(String url) { return null; } - @Override - public String encodeUrl(String url) { - if (LOG.isLoggable(Level.FINE)) { - LOG.log(Level.FINE, "encodeUrl({0})", url); - } - return null; - } - @Override public String getHeader(String name) { if (LOG.isLoggable(Level.FINE)) { @@ -307,14 +291,6 @@ public void setStatus(int sc) { responseHeaders.put(WebSocketUtils.SC_KEY, Integer.toString(sc)); } - @Override - public void setStatus(int sc, String sm) { - if (LOG.isLoggable(Level.FINE)) { - LOG.log(Level.FINE, "setStatus({0}, {1})", new Object[]{sc, sm}); - } - responseHeaders.put(WebSocketUtils.SC_KEY, Integer.toString(sc)); - } - private ServletOutputStream createOutputStream() { //REVISIT // This output buffering is needed as the server side websocket does From 97561f7383d4c2f64c41f054b894c2888a9d9d8d Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Wed, 22 Mar 2023 14:21:31 +1300 Subject: [PATCH 04/28] Jakarta XML Binding 4.0 --- .../xml/mock/marshaller/MockMarshaller.java | 9 +++----- .../provider/JAXBElementProviderTest.java | 9 +++----- .../provider/CXFJaxbContextResolver.java | 23 ++++--------------- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/core/src/test/java/com/ibm/xml/mock/marshaller/MockMarshaller.java b/core/src/test/java/com/ibm/xml/mock/marshaller/MockMarshaller.java index dc0f6292576..b7349222514 100644 --- a/core/src/test/java/com/ibm/xml/mock/marshaller/MockMarshaller.java +++ b/core/src/test/java/com/ibm/xml/mock/marshaller/MockMarshaller.java @@ -121,23 +121,20 @@ public ValidationEventHandler getEventHandler() throws JAXBException { return null; } - @SuppressWarnings("rawtypes") @Override - public void setAdapter(XmlAdapter adapter) { + public > void setAdapter(A adapter) { // TODO Auto-generated method stub } - @SuppressWarnings("rawtypes") @Override - public void setAdapter(Class type, A adapter) { + public > void setAdapter(Class type, A adapter) { // TODO Auto-generated method stub } - @SuppressWarnings("rawtypes") @Override - public A getAdapter(Class type) { + public > A getAdapter(Class type) { // TODO Auto-generated method stub return null; } diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java index d2c9e14a125..40242c0c75a 100644 --- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java +++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java @@ -1453,8 +1453,7 @@ public Map getProperties() { return props; } - @SuppressWarnings("rawtypes") - public A getAdapter(Class type) { + public > A getAdapter(Class type) { return null; } @@ -1513,13 +1512,11 @@ public void marshal(Object jaxbElement, XMLEventWriter writer) throws JAXBExcept } - @SuppressWarnings("rawtypes") - public void setAdapter(XmlAdapter adapter) { + public > void setAdapter(A adapter) { } - @SuppressWarnings("rawtypes") - public void setAdapter(Class type, A adapter) { + public > void setAdapter(Class type, A adapter) { } diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/provider/CXFJaxbContextResolver.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/provider/CXFJaxbContextResolver.java index 4a17c01f63e..39289efcf81 100644 --- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/provider/CXFJaxbContextResolver.java +++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/provider/CXFJaxbContextResolver.java @@ -51,7 +51,6 @@ import jakarta.xml.bind.Unmarshaller; import jakarta.xml.bind.UnmarshallerHandler; import jakarta.xml.bind.ValidationEventHandler; -import jakarta.xml.bind.Validator; import jakarta.xml.bind.annotation.adapters.XmlAdapter; import jakarta.xml.bind.attachment.AttachmentMarshaller; import jakarta.xml.bind.attachment.AttachmentUnmarshaller; @@ -61,7 +60,7 @@ public class CXFJaxbContextResolver implements ContextResolver { @SuppressWarnings("rawtypes") public static class SomeUnmarshaller implements Unmarshaller { @Override - public A getAdapter(Class type) { + public > A getAdapter(Class type) { return null; } @@ -95,17 +94,12 @@ public UnmarshallerHandler getUnmarshallerHandler() { return null; } - @Override - public boolean isValidating() throws JAXBException { - return false; - } - @Override public void setAdapter(XmlAdapter adapter) { } @Override - public void setAdapter(Class type, A adapter) { + public > void setAdapter(Class type, A adapter) { } @Override @@ -128,10 +122,6 @@ public void setProperty(String name, Object value) throws PropertyException { public void setSchema(Schema schema) { } - @Override - public void setValidating(boolean validating) throws JAXBException { - } - @Override public Object unmarshal(File f) throws JAXBException { return null; @@ -205,7 +195,7 @@ public JAXBElement unmarshal(XMLEventReader reader, Class declaredType @SuppressWarnings("rawtypes") public static class SomeMarshaller implements Marshaller { @Override - public A getAdapter(Class arg0) { + public > A getAdapter(Class arg0) { return null; } @@ -284,7 +274,7 @@ public void setAdapter(XmlAdapter adapter) { } @Override - public void setAdapter(Class type, A adapter) { + public > void setAdapter(Class type, A adapter) { } @Override @@ -308,7 +298,6 @@ public void setSchema(Schema schema) { } } - @SuppressWarnings("deprecation") public static class SomeJaxbContext extends JAXBContext { @Override public Marshaller createMarshaller() throws JAXBException { @@ -320,10 +309,6 @@ public Unmarshaller createUnmarshaller() throws JAXBException { return new SomeUnmarshaller(); } - @Override - public Validator createValidator() throws JAXBException { - return null; - } } @Override From c7dc677a7fd17ec182f755669e3a9c9e487e3d66 Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Wed, 22 Mar 2023 14:23:04 +1300 Subject: [PATCH 05/28] Jakarta Context Dependency Injection 4.0 --- .../src/main/java/org/apache/cxf/cdi/AbstractCXFBean.java | 5 ----- .../org/apache/cxf/cdi/CdiServerConfigurableFactory.java | 2 +- .../main/java/org/apache/cxf/cdi/ContextProducerBean.java | 5 ----- .../java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java | 4 ++-- .../apache/cxf/microprofile/client/cdi/RestClientBean.java | 5 ----- 5 files changed, 3 insertions(+), 18 deletions(-) diff --git a/integration/cdi/src/main/java/org/apache/cxf/cdi/AbstractCXFBean.java b/integration/cdi/src/main/java/org/apache/cxf/cdi/AbstractCXFBean.java index 872a82b6af8..c198b38d520 100644 --- a/integration/cdi/src/main/java/org/apache/cxf/cdi/AbstractCXFBean.java +++ b/integration/cdi/src/main/java/org/apache/cxf/cdi/AbstractCXFBean.java @@ -60,11 +60,6 @@ public boolean isAlternative() { return false; } - @Override - public boolean isNullable() { - return false; - } - @Override public Set getInjectionPoints() { return Collections.emptySet(); diff --git a/integration/cdi/src/main/java/org/apache/cxf/cdi/CdiServerConfigurableFactory.java b/integration/cdi/src/main/java/org/apache/cxf/cdi/CdiServerConfigurableFactory.java index ee6dded54c4..846ef24f41f 100644 --- a/integration/cdi/src/main/java/org/apache/cxf/cdi/CdiServerConfigurableFactory.java +++ b/integration/cdi/src/main/java/org/apache/cxf/cdi/CdiServerConfigurableFactory.java @@ -67,7 +67,7 @@ public Object create(Class cls) { final CreationalContext context = beanManager.createCreationalContext(bean); if (!beanManager.isNormalScope(bean.getScope())) { - beanManager.fireEvent(new DisposableCreationalContext(context)); + beanManager.getEvent().fire(new DisposableCreationalContext(context)); } return beanManager.getReference(bean, cls, context); diff --git a/integration/cdi/src/main/java/org/apache/cxf/cdi/ContextProducerBean.java b/integration/cdi/src/main/java/org/apache/cxf/cdi/ContextProducerBean.java index 84ebe9b8987..b464e1900ee 100644 --- a/integration/cdi/src/main/java/org/apache/cxf/cdi/ContextProducerBean.java +++ b/integration/cdi/src/main/java/org/apache/cxf/cdi/ContextProducerBean.java @@ -64,11 +64,6 @@ public Object create(CreationalContext creationalContext) { return createContextValue(); } - @Override - public boolean isNullable() { - return true; - } - @Override public Set getTypes() { Set types = super.getTypes(); diff --git a/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java b/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java index 75403e3a1e7..ee6c81e7b9e 100644 --- a/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java +++ b/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java @@ -164,7 +164,7 @@ void onStartup(@Observes final BeforeBeanDiscovery beforeBeanDiscovery, final Be "jakarta.servlet.http.HttpServletRequest", "jakarta.servlet.ServletContext")); } - beanManager.fireEvent(this); + beanManager.getEvent().fire(this); } /** @@ -269,7 +269,7 @@ public void injectBus(@Observes final AfterBeanDiscovery event, final BeanManage beanManager.createAnnotatedType(ExtensionManagerBus.class); final InjectionTarget busInjectionTarget = - beanManager.createInjectionTarget(busAnnotatedType); + beanManager.getInjectionTargetFactory(busAnnotatedType).createInjectionTarget(null); event.addBean(new CdiBusBean(busInjectionTarget)); } diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientBean.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientBean.java index 8b9fbf7a7af..f6f87f2a006 100644 --- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientBean.java +++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientBean.java @@ -107,11 +107,6 @@ public Set getInjectionPoints() { return Collections.emptySet(); } - @Override - public boolean isNullable() { - return false; - } - @Override public Object create(CreationalContext creationalContext) { CxfTypeSafeClientBuilder builder = new CxfTypeSafeClientBuilder(); From a41f1ea7ae94379d8b7a567cefc8b9b01ad4f78d Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Wed, 22 Mar 2023 14:24:31 +1300 Subject: [PATCH 06/28] Fix Maven dependencies --- rt/rs/microprofile-client/pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rt/rs/microprofile-client/pom.xml b/rt/rs/microprofile-client/pom.xml index 7b156c8778f..b00d0cdd912 100644 --- a/rt/rs/microprofile-client/pom.xml +++ b/rt/rs/microprofile-client/pom.xml @@ -95,6 +95,14 @@ cxf-rt-rs-extension-providers ${project.version} + + jakarta.inject + jakarta.inject-api + + + jakarta.interceptor + jakarta.interceptor-api + jakarta.json jakarta.json-api From 20354280bcdf50e642652d92f9221e7465a2c8d1 Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Wed, 22 Mar 2023 14:29:12 +1300 Subject: [PATCH 07/28] Jakarta RESTful Web Services 3.1 --- .../cxf/jaxrs/sse/SseBroadcasterImpl.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/SseBroadcasterImpl.java b/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/SseBroadcasterImpl.java index 8a76609ed23..de1ea2dd70c 100644 --- a/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/SseBroadcasterImpl.java +++ b/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/SseBroadcasterImpl.java @@ -108,11 +108,7 @@ public void onError(BiConsumer exceptioner) { @Override public void close() { - if (closed.compareAndSet(false, true)) { - subscribers.forEach(subscriber -> { - subscriber.close(); - }); - } + close(true); } private void assertNotClosed() { @@ -120,4 +116,17 @@ private void assertNotClosed() { throw new IllegalStateException("The SSE broadcaster is already closed"); } } + + @Override + public void close(boolean cascading) { + if (!cascading) { + return; + } + + if (closed.compareAndSet(false, true)) { + subscribers.forEach(subscriber -> { + subscriber.close(); + }); + } + } } From e7f3e9aae65ff0e35893d859f8b2c7f4595a9af5 Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Thu, 23 Mar 2023 10:00:52 +1300 Subject: [PATCH 08/28] Update Jakarta EE dependencies for codegen-plugins integration tests --- .../src/it/jaxb-xjc-runtime-sources/pom.xml | 8 ++++---- .../codegen-plugin/src/it/jdk-cxf-with-toolchain/pom.xml | 8 ++++---- .../codegen-plugin/src/it/mark-generated/pom.xml | 8 ++++---- .../src/it/wsdl-artifact-resolution/pom.xml | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/maven-plugins/codegen-plugin/src/it/jaxb-xjc-runtime-sources/pom.xml b/maven-plugins/codegen-plugin/src/it/jaxb-xjc-runtime-sources/pom.xml index 7388dcb99ef..ea57f60abbe 100644 --- a/maven-plugins/codegen-plugin/src/it/jaxb-xjc-runtime-sources/pom.xml +++ b/maven-plugins/codegen-plugin/src/it/jaxb-xjc-runtime-sources/pom.xml @@ -77,9 +77,9 @@ - java9 + java11 - [9,) + [11,) @@ -90,7 +90,7 @@ jakarta.xml.ws jakarta.xml.ws-api - 3.0.0 + 4.0.0 jakarta.jws @@ -100,7 +100,7 @@ jakarta.xml.bind jakarta.xml.bind-api - 3.0.1 + 4.0.0 diff --git a/maven-plugins/codegen-plugin/src/it/jdk-cxf-with-toolchain/pom.xml b/maven-plugins/codegen-plugin/src/it/jdk-cxf-with-toolchain/pom.xml index d3a7f21a58f..f156353cf8f 100644 --- a/maven-plugins/codegen-plugin/src/it/jdk-cxf-with-toolchain/pom.xml +++ b/maven-plugins/codegen-plugin/src/it/jdk-cxf-with-toolchain/pom.xml @@ -112,9 +112,9 @@ - java9 + java11 - [9,) + [11,) @@ -125,7 +125,7 @@ jakarta.xml.ws jakarta.xml.ws-api - 3.0.0 + 4.0.0 jakarta.jws @@ -135,7 +135,7 @@ jakarta.xml.bind jakarta.xml.bind-api - 3.0.1 + 4.0.0 diff --git a/maven-plugins/codegen-plugin/src/it/mark-generated/pom.xml b/maven-plugins/codegen-plugin/src/it/mark-generated/pom.xml index d91b5b619ac..b115a62caa2 100644 --- a/maven-plugins/codegen-plugin/src/it/mark-generated/pom.xml +++ b/maven-plugins/codegen-plugin/src/it/mark-generated/pom.xml @@ -75,9 +75,9 @@ - java9 + java11 - [9,) + [11,) @@ -88,7 +88,7 @@ jakarta.xml.ws jakarta.xml.ws-api - 3.0.0 + 4.0.0 jakarta.jws @@ -98,7 +98,7 @@ jakarta.xml.bind jakarta.xml.bind-api - 3.0.1 + 4.0.0 diff --git a/maven-plugins/codegen-plugin/src/it/wsdl-artifact-resolution/pom.xml b/maven-plugins/codegen-plugin/src/it/wsdl-artifact-resolution/pom.xml index 9d84c21ef56..7bdc64e0ae3 100644 --- a/maven-plugins/codegen-plugin/src/it/wsdl-artifact-resolution/pom.xml +++ b/maven-plugins/codegen-plugin/src/it/wsdl-artifact-resolution/pom.xml @@ -77,9 +77,9 @@ - java9 + java11 - [9,) + [11,) @@ -90,7 +90,7 @@ jakarta.xml.ws jakarta.xml.ws-api - 3.0.0 + 4.0.0 jakarta.jws @@ -100,7 +100,7 @@ jakarta.xml.bind jakarta.xml.bind-api - 3.0.1 + 4.0.0 From 6328865bf6dc1c4d5d8d87b32d3a26c48217822e Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Thu, 23 Mar 2023 10:01:24 +1300 Subject: [PATCH 09/28] Add missing jakarta.xml.bind-api dependencies for codegen-plugin maven-invoker-plugin --- maven-plugins/codegen-plugin/pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/maven-plugins/codegen-plugin/pom.xml b/maven-plugins/codegen-plugin/pom.xml index 6c9da8e7004..a9b7c7c59d5 100644 --- a/maven-plugins/codegen-plugin/pom.xml +++ b/maven-plugins/codegen-plugin/pom.xml @@ -195,6 +195,13 @@ + + + jakarta.xml.bind + jakarta.xml.bind-api + 4.0.0 + + From 49e3e175288be8a1055bdf73d8bf01d0697db753 Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Fri, 24 Mar 2023 09:04:51 +1300 Subject: [PATCH 10/28] Correct RetryAfterHeaderProviderTest not accounting for host daylight time getRawOffset() returns the offset for standard time, which means these tests fail when the default timezone is observing daylight time. [ERROR] Failures: [ERROR] org.apache.cxf.jaxrs.impl.RetryAfterHeaderProviderTest.test[retry after Sun Nov 03 08:49:37 2002 is duration of PT24884H49M37S from 2000-01-01 00:00:00.000] [ERROR] Run 1: RetryAfterHeaderProviderTest.test:73 Expected: is but: was [ERROR] Run 2: RetryAfterHeaderProviderTest.test:73 Expected: is but: was [ERROR] Run 3: RetryAfterHeaderProviderTest.test:73 Expected: is but: was [ERROR] Run 4: RetryAfterHeaderProviderTest.test:73 Expected: is but: was [INFO] [ERROR] org.apache.cxf.jaxrs.impl.RetryAfterHeaderProviderTest.test[retry after Sun Nov 3 08:49:37 2002 is duration of PT24884H49M37S from 2000-01-01 00:00:00.000] [ERROR] Run 1: RetryAfterHeaderProviderTest.test:73 Expected: is but: was [ERROR] Run 2: RetryAfterHeaderProviderTest.test:73 Expected: is but: was [ERROR] Run 3: RetryAfterHeaderProviderTest.test:73 Expected: is but: was [ERROR] Run 4: RetryAfterHeaderProviderTest.test:73 Expected: is but: was --- .../cxf/jaxrs/impl/RetryAfterHeaderProviderTest.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RetryAfterHeaderProviderTest.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RetryAfterHeaderProviderTest.java index c49730011f0..0c2e9809115 100644 --- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RetryAfterHeaderProviderTest.java +++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RetryAfterHeaderProviderTest.java @@ -19,6 +19,8 @@ package org.apache.cxf.jaxrs.impl; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.time.Clock; import java.time.Duration; import java.time.OffsetDateTime; @@ -26,6 +28,7 @@ import java.time.ZoneOffset; import java.util.Arrays; import java.util.Collection; +import java.util.Locale; import java.util.TimeZone; import org.junit.Test; @@ -50,9 +53,7 @@ public RetryAfterHeaderProviderTest(String date, Duration delay) { } @Parameterized.Parameters(name = "retry after {0} is duration of {1} from 2000-01-01 00:00:00.000") - public static Collection data() { - final int offset = TimeZone.getDefault().getRawOffset() / 1000; - + public static Collection data() throws ParseException { return Arrays.asList( new Object[] {"", Duration.ZERO}, new Object[] {null, Duration.ZERO}, @@ -61,8 +62,8 @@ public static Collection data() { new Object[] {"Sun, 03 Nov 2002 08:49:37 EST", Duration.ofSeconds(89646577)}, new Object[] {"Sat, 01 Jan 2000 01:00:00 GMT", Duration.ofSeconds(3600)}, new Object[] {"Sunday, 03-Nov-02 08:49:37 GMT", Duration.ofSeconds(89628577)}, - new Object[] {"Sun Nov 3 08:49:37 2002", Duration.ofSeconds(89628577 - offset)}, - new Object[] {"Sun Nov 03 08:49:37 2002", Duration.ofSeconds(89628577 - offset)}, + new Object[] {"Sun Nov 3 08:49:37 2002", Duration.ofSeconds(89628577 - TimeZone.getDefault().getOffset(new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy", Locale.US).parse("Sun Nov 3 08:49:37 2002").getTime()) / 1000)}, + new Object[] {"Sun Nov 03 08:49:37 2002", Duration.ofSeconds(89628577 - TimeZone.getDefault().getOffset(new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy", Locale.US).parse("Sun Nov 03 08:49:37 2002").getTime()) / 1000)}, new Object[] {"Sun, 06 Nov 1994 08:49:37 EST", Duration.ZERO} ); From e6b6d9a45b1ab905ccd9817a95f80cfd77d920f8 Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Mon, 3 Apr 2023 08:23:13 +1200 Subject: [PATCH 11/28] Upgrade saaj-impl --- parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index 167cd4735c5..37c93816094 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -189,7 +189,7 @@ 1.3.8 2.2.21 3.1.8 - 2.0.1 + 3.0.0 jakarta.servlet-api jakarta.servlet 2.0.9 From 391e6fe66e74a01739b463f687d09ffd6b709541 Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Mon, 3 Apr 2023 10:59:27 +1200 Subject: [PATCH 12/28] Upgrade undertow --- distribution/javadoc/pom.xml | 2 +- .../src/main/release/samples/jax_rs/sse_client/pom.xml | 2 +- parent/pom.xml | 4 ++-- rt/transports/http-undertow/pom.xml | 2 +- systests/rs-sse/rs-sse-undertow/pom.xml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/distribution/javadoc/pom.xml b/distribution/javadoc/pom.xml index aabd8a591f4..da516bebeaa 100644 --- a/distribution/javadoc/pom.xml +++ b/distribution/javadoc/pom.xml @@ -419,7 +419,7 @@ io.undertow - undertow-servlet-jakarta + undertow-servlet org.eclipse.jetty diff --git a/distribution/src/main/release/samples/jax_rs/sse_client/pom.xml b/distribution/src/main/release/samples/jax_rs/sse_client/pom.xml index 4ae2512a214..9bbce8b639c 100644 --- a/distribution/src/main/release/samples/jax_rs/sse_client/pom.xml +++ b/distribution/src/main/release/samples/jax_rs/sse_client/pom.xml @@ -47,7 +47,7 @@ io.undertow - undertow-servlet-jakarta + undertow-servlet diff --git a/parent/pom.xml b/parent/pom.xml index 37c93816094..49d1099470e 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -206,7 +206,7 @@ 2.7.0 10.1.14 1.8 - 2.2.20.Final + 2.3.5.Final 2.3 1.6.0.Final 3.2.0 @@ -1175,7 +1175,7 @@ io.undertow - undertow-servlet-jakarta + undertow-servlet ${cxf.undertow.version} diff --git a/rt/transports/http-undertow/pom.xml b/rt/transports/http-undertow/pom.xml index f2c83793926..835e30d8b20 100644 --- a/rt/transports/http-undertow/pom.xml +++ b/rt/transports/http-undertow/pom.xml @@ -58,7 +58,7 @@ io.undertow - undertow-servlet-jakarta + undertow-servlet org.jboss.xnio diff --git a/systests/rs-sse/rs-sse-undertow/pom.xml b/systests/rs-sse/rs-sse-undertow/pom.xml index 0bf8e8b1888..892f95b2006 100644 --- a/systests/rs-sse/rs-sse-undertow/pom.xml +++ b/systests/rs-sse/rs-sse-undertow/pom.xml @@ -42,7 +42,7 @@ io.undertow - undertow-servlet-jakarta + undertow-servlet test From d61f8f088452bbfa5d9be922c9def2dedf70871f Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Mon, 3 Apr 2023 11:00:01 +1200 Subject: [PATCH 13/28] Upgrade istack --- parent/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parent/pom.xml b/parent/pom.xml index 49d1099470e..7fb5528ee11 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -229,7 +229,7 @@ 2.1.3_1 1.2.18_1 1.2.4 - 3.0.7 + 4.1.1 1.0.0 2.0.1 1.9.3_1 @@ -1557,7 +1557,7 @@ com.sun.istack istack-commons-tools - 3.0.11 + ${cxf.istack.bundle.version} org.glassfish.jaxb From e66177f1535abbe19e584d3310ac9657e50f2a52 Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Thu, 13 Apr 2023 07:21:35 +1200 Subject: [PATCH 14/28] Placeholders for bootstrap API --- .../cxf/jaxrs/impl/RuntimeDelegateImpl.java | 17 +++++++ .../bootstrap/ConfigurationBuilderImpl.java | 46 +++++++++++++++++++ .../impl/bootstrap/ConfigurationImpl.java | 20 ++++++++ .../cxf/jaxrs/impl/ResponseImplTest.java | 20 ++++++++ 4 files changed, 103 insertions(+) create mode 100644 rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/bootstrap/ConfigurationBuilderImpl.java create mode 100644 rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/bootstrap/ConfigurationImpl.java diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java index 5cc8a607626..8d50c1c5bda 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java @@ -22,7 +22,9 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.CompletionStage; +import jakarta.ws.rs.SeBootstrap; import jakarta.ws.rs.core.Application; import jakarta.ws.rs.core.CacheControl; import jakarta.ws.rs.core.Cookie; @@ -36,6 +38,7 @@ import jakarta.ws.rs.ext.RuntimeDelegate; import org.apache.cxf.endpoint.Server; import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; +import org.apache.cxf.jaxrs.impl.bootstrap.ConfigurationBuilderImpl; import org.apache.cxf.jaxrs.utils.ResourceUtils; @@ -125,5 +128,19 @@ public Link.Builder createLinkBuilder() { return new LinkBuilderImpl(); } + @Override + public SeBootstrap.Configuration.Builder createConfigurationBuilder() { + return new ConfigurationBuilderImpl(); + } + + @Override + public CompletionStage bootstrap(Application application, SeBootstrap.Configuration configuration) { + throw new UnsupportedOperationException("Bootstrap API not yet supported"); + } + + @Override + public CompletionStage bootstrap(Class clazz, SeBootstrap.Configuration configuration) { + throw new UnsupportedOperationException("Bootstrap API not yet supported"); + } } diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/bootstrap/ConfigurationBuilderImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/bootstrap/ConfigurationBuilderImpl.java new file mode 100644 index 00000000000..ed797358562 --- /dev/null +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/bootstrap/ConfigurationBuilderImpl.java @@ -0,0 +1,46 @@ +package org.apache.cxf.jaxrs.impl.bootstrap; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.function.BiFunction; + +import javax.net.ssl.SSLContext; + +import jakarta.ws.rs.SeBootstrap; +import jakarta.ws.rs.SeBootstrap.Configuration.SSLClientAuthentication; + +public class ConfigurationBuilderImpl implements SeBootstrap.Configuration.Builder { + + private final Map properties = new HashMap<>(); + + @Override + public SeBootstrap.Configuration build() { + return new ConfigurationImpl(properties); + } + + @Override + public SeBootstrap.Configuration.Builder property(String name, Object value) { + properties.put(name, value); + return this; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public SeBootstrap.Configuration.Builder from(BiFunction, Optional> propertiesProvider) { + final BiFunction, Optional> stringPropertiesProvider = (BiFunction) propertiesProvider; + final BiFunction, Optional> integerPropertiesProvider = (BiFunction) propertiesProvider; + final BiFunction, Optional> sslContextPropertiesProvider = (BiFunction) propertiesProvider; + final BiFunction, Optional> sslClientAuthenticationPropertiesProvider = (BiFunction) propertiesProvider; + + stringPropertiesProvider.apply(SeBootstrap.Configuration.PROTOCOL, String.class).ifPresent(this::protocol); + stringPropertiesProvider.apply(SeBootstrap.Configuration.HOST, String.class).ifPresent(this::host); + integerPropertiesProvider.apply(SeBootstrap.Configuration.PORT, Integer.class).ifPresent(this::port); + stringPropertiesProvider.apply(SeBootstrap.Configuration.ROOT_PATH, String.class).ifPresent(this::rootPath); + sslContextPropertiesProvider.apply(SeBootstrap.Configuration.SSL_CONTEXT, SSLContext.class).ifPresent(this::sslContext); + sslClientAuthenticationPropertiesProvider.apply(SeBootstrap.Configuration.SSL_CLIENT_AUTHENTICATION, SSLClientAuthentication.class).ifPresent(this::sslClientAuthentication); + + return this; + } + +} diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/bootstrap/ConfigurationImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/bootstrap/ConfigurationImpl.java new file mode 100644 index 00000000000..5e29bb7fceb --- /dev/null +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/bootstrap/ConfigurationImpl.java @@ -0,0 +1,20 @@ +package org.apache.cxf.jaxrs.impl.bootstrap; + +import java.util.Map; + +import jakarta.ws.rs.SeBootstrap; + +public class ConfigurationImpl implements SeBootstrap.Configuration { + + private final Map properties; + + ConfigurationImpl(Map properties) { + this.properties = properties; + } + + @Override + public Object property(String name) { + return properties.get(name); + } + +} diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java index 5017d1eeb6f..a97cda07dce 100644 --- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java +++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java @@ -33,6 +33,7 @@ import java.util.Locale; import java.util.Map; import java.util.Set; +import java.util.concurrent.CompletionStage; import javax.xml.transform.Source; import javax.xml.transform.Transformer; @@ -43,6 +44,8 @@ import jakarta.activation.DataSource; import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.SeBootstrap.Configuration; +import jakarta.ws.rs.SeBootstrap.Instance; import jakarta.ws.rs.WebApplicationException; import jakarta.ws.rs.client.ResponseProcessingException; import jakarta.ws.rs.core.Application; @@ -67,6 +70,7 @@ import jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate; import org.apache.cxf.endpoint.Endpoint; import org.apache.cxf.helpers.IOUtils; +import org.apache.cxf.jaxrs.impl.bootstrap.ConfigurationBuilderImpl; import org.apache.cxf.jaxrs.provider.ProviderFactory; import org.apache.cxf.jaxrs.provider.ServerProviderFactory; import org.apache.cxf.jaxrs.resources.Book; @@ -844,6 +848,22 @@ public static final void assertNotStringBeanRuntimeDelegate(RuntimeDelegate dele public Builder createLinkBuilder() { return original.createLinkBuilder(); } + + @Override + public jakarta.ws.rs.SeBootstrap.Configuration.Builder createConfigurationBuilder() { + return new ConfigurationBuilderImpl(); + } + + @Override + public CompletionStage bootstrap(Application application, Configuration configuration) { + throw new UnsupportedOperationException("Unimplemented method 'bootstrap'"); + } + + @Override + public CompletionStage bootstrap(Class clazz, Configuration configuration) { + throw new UnsupportedOperationException("Unimplemented method 'bootstrap'"); + } + } public static class StringBeanHeaderDelegate implements HeaderDelegate { From e0f10cc2aa34a1d61953f0e64f96f7ead6150283 Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Thu, 13 Apr 2023 07:21:52 +1200 Subject: [PATCH 15/28] EntityPart --- .../cxf/jaxrs/impl/EntityPartBuilderImpl.java | 120 ++++++++++++++++++ .../apache/cxf/jaxrs/impl/EntityPartImpl.java | 74 +++++++++++ .../cxf/jaxrs/impl/RuntimeDelegateImpl.java | 5 + .../cxf/jaxrs/impl/ResponseImplTest.java | 4 + 4 files changed, 203 insertions(+) create mode 100644 rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartBuilderImpl.java create mode 100644 rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartBuilderImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartBuilderImpl.java new file mode 100644 index 00000000000..deff726dfe6 --- /dev/null +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartBuilderImpl.java @@ -0,0 +1,120 @@ +package org.apache.cxf.jaxrs.impl; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Objects; + +import org.apache.cxf.jaxrs.provider.ProviderFactory; + +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.EntityPart; +import jakarta.ws.rs.core.EntityPart.Builder; +import jakarta.ws.rs.ext.MessageBodyWriter; +import jakarta.ws.rs.core.GenericType; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedHashMap; +import jakarta.ws.rs.core.MultivaluedMap; + +public class EntityPartBuilderImpl implements EntityPart.Builder { + + private final String name; + private MediaType mediaType; + private MultivaluedMap headers = new MultivaluedHashMap<>(); + private String fileName; + private InputStream content; + + public EntityPartBuilderImpl(String name) { + this.name = name; + } + + @Override + public Builder mediaType(MediaType mediaType) throws IllegalArgumentException { + this.mediaType = mediaType; + return this; + } + + @Override + public Builder mediaType(String mediaTypeString) throws IllegalArgumentException { + this.mediaType = MediaType.valueOf(mediaTypeString); + return this; + } + + @Override + public Builder header(String headerName, String... headerValues) throws IllegalArgumentException { + headers.addAll(headerName, headerValues); + return this; + } + + @Override + public Builder headers(MultivaluedMap newHeaders) throws IllegalArgumentException { + headers.clear(); + headers.putAll(newHeaders); + return this; + } + + @Override + public Builder fileName(String fileName) throws IllegalArgumentException { + this.fileName = fileName; + return this; + } + + @Override + public Builder content(InputStream content) throws IllegalArgumentException { + this.content = content; + return this; + } + + @Override + public Builder content(T content, Class type) throws IllegalArgumentException { + final MediaType mediaTypeForWrite = Objects.requireNonNullElse(mediaType, MediaType.APPLICATION_OCTET_STREAM_TYPE); + + @SuppressWarnings({ "unchecked", "rawtypes" }) + final MessageBodyWriter writer = (MessageBodyWriter) ProviderFactory.getInstance(null).createMessageBodyWriter(type, null, null, mediaTypeForWrite, null); + + @SuppressWarnings({ "unchecked", "rawtypes" }) + final MultivaluedMap headersForWrite = (MultivaluedMap) headers; + + try { + final ByteArrayOutputStream out = new ByteArrayOutputStream(); + writer.writeTo(content, type, null, null, mediaType, headersForWrite, out); + content(new ByteArrayInputStream(out.toByteArray())); + } catch (WebApplicationException e) { + throw new IllegalArgumentException(e); + } catch (IOException e) { + throw new IllegalArgumentException(e); + } + + return this; + } + + @Override + public Builder content(T content, GenericType type) throws IllegalArgumentException { + final MediaType mediaTypeForWrite = Objects.requireNonNullElse(mediaType, MediaType.APPLICATION_OCTET_STREAM_TYPE); + + @SuppressWarnings({ "unchecked", "rawtypes" }) + final MessageBodyWriter writer = (MessageBodyWriter) ProviderFactory.getInstance(null).createMessageBodyWriter(type.getRawType(), type.getType(), null, mediaTypeForWrite, null); + + @SuppressWarnings({ "unchecked", "rawtypes" }) + final MultivaluedMap headersForWrite = (MultivaluedMap) headers; + + try { + final ByteArrayOutputStream out = new ByteArrayOutputStream(); + writer.writeTo(content, type.getRawType(), type.getType(), null, mediaType, headersForWrite, out); + content(new ByteArrayInputStream(out.toByteArray())); + } catch (WebApplicationException e) { + throw new IllegalArgumentException(e); + } catch (IOException e) { + throw new IllegalArgumentException(e); + } + + return this; + } + + @Override + public EntityPart build() throws IllegalStateException, IOException, WebApplicationException { + return new EntityPartImpl(name, fileName, content, headers, mediaType); + } + +} diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java new file mode 100644 index 00000000000..de4181201de --- /dev/null +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java @@ -0,0 +1,74 @@ +package org.apache.cxf.jaxrs.impl; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Optional; + +import org.apache.cxf.jaxrs.provider.ProviderFactory; + +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.EntityPart; +import jakarta.ws.rs.core.GenericType; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.ext.MessageBodyReader; + +public class EntityPartImpl implements EntityPart { + + private final String name; + private final String fileName; + private final InputStream content; + private final MultivaluedMap headers; + private final MediaType mediaType; + + EntityPartImpl(String name, String fileName, InputStream content, MultivaluedMap headers, MediaType mediaType) { + this.name = name; + this.fileName = fileName; + this.content = content; + this.headers = headers; + this.mediaType = mediaType; + } + + @Override + public String getName() { + return name; + } + + @Override + public Optional getFileName() { + return Optional.ofNullable(fileName); + } + + @Override + public InputStream getContent() { + return content; + } + + @Override + public T getContent(Class type) throws IllegalArgumentException, IllegalStateException, IOException, WebApplicationException { + @SuppressWarnings({ "unchecked", "rawtypes" }) + final MessageBodyReader reader = (MessageBodyReader) ProviderFactory.getInstance(null).createMessageBodyReader(type, null, null, mediaType, null); + + return reader.readFrom(type, null, null, mediaType, headers, content); + } + + @SuppressWarnings("unchecked") + @Override + public T getContent(GenericType type) throws IllegalArgumentException, IllegalStateException, IOException, WebApplicationException { + @SuppressWarnings("rawtypes") + final MessageBodyReader reader = (MessageBodyReader) ProviderFactory.getInstance(null).createMessageBodyReader(type.getRawType(), type.getType(), null, mediaType, null); + + return reader.readFrom((Class) type.getRawType(), type.getType(), null, mediaType, headers, content); + } + + @Override + public MultivaluedMap getHeaders() { + return headers; + } + + @Override + public MediaType getMediaType() { + return mediaType; + } + +} diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java index 8d50c1c5bda..b5882f81708 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java @@ -143,4 +143,9 @@ public CompletionStage bootstrap(Class bootstrap(Class clazz, C throw new UnsupportedOperationException("Unimplemented method 'bootstrap'"); } + @Override + public jakarta.ws.rs.core.EntityPart.Builder createEntityPartBuilder(String partName) throws IllegalArgumentException { + return new EntityPartBuilderImpl(partName); + } } public static class StringBeanHeaderDelegate implements HeaderDelegate { From b87e742f9fee866509a12658eeb810af43198c9d Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Tue, 4 Apr 2023 16:37:54 -0400 Subject: [PATCH 16/28] Implement RuntimeDelegateImpl --- .../release/samples/jax_rs/sse_client/pom.xml | 6 +- maven-plugins/codegen-plugin/pom.xml | 2 +- parent/pom.xml | 3 +- .../bootstrap/ConfigurationBuilderImpl.java | 79 ++++++ .../jaxrs/bootstrap/ConfigurationImpl.java | 37 +++ .../cxf/jaxrs/bootstrap/InstanceImpl.java | 60 +++++ .../cxf/jaxrs/impl/EntityPartBuilderImpl.java | 235 ++++++++++-------- .../apache/cxf/jaxrs/impl/EntityPartImpl.java | 115 +++++---- .../cxf/jaxrs/impl/RuntimeDelegateImpl.java | 51 ++-- .../bootstrap/ConfigurationBuilderImpl.java | 46 ---- .../impl/bootstrap/ConfigurationImpl.java | 20 -- .../cxf/jaxrs/impl/ResponseImplTest.java | 11 +- 12 files changed, 422 insertions(+), 243 deletions(-) create mode 100644 rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/bootstrap/ConfigurationBuilderImpl.java create mode 100644 rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/bootstrap/ConfigurationImpl.java create mode 100644 rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/bootstrap/InstanceImpl.java delete mode 100644 rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/bootstrap/ConfigurationBuilderImpl.java delete mode 100644 rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/bootstrap/ConfigurationImpl.java diff --git a/distribution/src/main/release/samples/jax_rs/sse_client/pom.xml b/distribution/src/main/release/samples/jax_rs/sse_client/pom.xml index 9bbce8b639c..762e8e2a4f2 100644 --- a/distribution/src/main/release/samples/jax_rs/sse_client/pom.xml +++ b/distribution/src/main/release/samples/jax_rs/sse_client/pom.xml @@ -44,11 +44,11 @@ io.undertow undertow-core - + io.undertow - undertow-servlet - + undertow-servlet + diff --git a/maven-plugins/codegen-plugin/pom.xml b/maven-plugins/codegen-plugin/pom.xml index a9b7c7c59d5..0d8cf97cf4d 100644 --- a/maven-plugins/codegen-plugin/pom.xml +++ b/maven-plugins/codegen-plugin/pom.xml @@ -199,7 +199,7 @@ jakarta.xml.bind jakarta.xml.bind-api - 4.0.0 + ${cxf.jaxb.version} diff --git a/parent/pom.xml b/parent/pom.xml index 7fb5528ee11..f1a7053e6cc 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -121,7 +121,7 @@ 32.1.3-jre 2.2 5.3.5 - 6.1.7.Final + 6.2.3.Final 7.0.5.Final 2.7.2 [4.0,4.2) @@ -141,6 +141,7 @@ 0.7.2 3.29.2-GA 4.0.2 + 4.0.0 ${cxf.jaxb.runtime.version} 2.0.0 3.5.3.Final diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/bootstrap/ConfigurationBuilderImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/bootstrap/ConfigurationBuilderImpl.java new file mode 100644 index 00000000000..7f890d91477 --- /dev/null +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/bootstrap/ConfigurationBuilderImpl.java @@ -0,0 +1,79 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.cxf.jaxrs.bootstrap; + +import java.util.AbstractMap.SimpleEntry; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.function.BiFunction; +import java.util.function.Consumer; + +import javax.net.ssl.SSLContext; + +import jakarta.ws.rs.SeBootstrap; +import jakarta.ws.rs.SeBootstrap.Configuration.SSLClientAuthentication; + +public class ConfigurationBuilderImpl implements SeBootstrap.Configuration.Builder { + private final Map, Consumer>> supported = new HashMap<>(); + private final Map properties = new HashMap<>(); + + public ConfigurationBuilderImpl() { + supported.put(SeBootstrap.Configuration.PROTOCOL, + entry(String.class, this::protocol)); + supported.put(SeBootstrap.Configuration.HOST, + entry(String.class, this::host)); + supported.put(SeBootstrap.Configuration.PORT, + entry(Integer.class, this::port)); + supported.put(SeBootstrap.Configuration.ROOT_PATH, + entry(String.class, this::rootPath)); + supported.put(SeBootstrap.Configuration.SSL_CONTEXT, + entry(SSLContext.class, this::sslContext)); + supported.put(SeBootstrap.Configuration.SSL_CLIENT_AUTHENTICATION, + entry(SSLClientAuthentication.class, this::sslClientAuthentication)); + } + + private SimpleEntry, Consumer> entry(Class clazz, Consumer consumer) { + return new SimpleEntry, Consumer>(clazz, consumer); + } + + @Override + public SeBootstrap.Configuration build() { + return new ConfigurationImpl(properties); + } + + @Override + public SeBootstrap.Configuration.Builder property(String name, Object value) { + properties.put(name, value); + return this; + } + + @SuppressWarnings("unchecked") + @Override + public SeBootstrap.Configuration.Builder from(BiFunction, Optional> propertiesProvider) { + for (Map.Entry, Consumer>> entry: supported.entrySet()) { + propertiesProvider + .apply(entry.getKey(), (Class)entry.getValue().getKey()) + .ifPresent((Consumer)entry.getValue().getValue()); + } + return this; + } + +} diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/bootstrap/ConfigurationImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/bootstrap/ConfigurationImpl.java new file mode 100644 index 00000000000..543fd1a2c56 --- /dev/null +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/bootstrap/ConfigurationImpl.java @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.cxf.jaxrs.bootstrap; + +import java.util.Map; + +import jakarta.ws.rs.SeBootstrap; + +class ConfigurationImpl implements SeBootstrap.Configuration { + private final Map properties; + + ConfigurationImpl(Map properties) { + this.properties = properties; + } + + @Override + public Object property(String name) { + return properties.get(name); + } +} diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/bootstrap/InstanceImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/bootstrap/InstanceImpl.java new file mode 100644 index 00000000000..6134813b24d --- /dev/null +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/bootstrap/InstanceImpl.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.cxf.jaxrs.bootstrap; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import jakarta.ws.rs.SeBootstrap.Configuration; +import jakarta.ws.rs.SeBootstrap.Instance; +import org.apache.cxf.endpoint.Server; + +public class InstanceImpl implements Instance { + private final Server server; + private final Configuration configuration; + + public InstanceImpl(Server server, Configuration configuration) { + this.server = server; + this.configuration = configuration; + } + + @Override + public Configuration configuration() { + return configuration; + } + + @Override + public CompletionStage stop() { + return CompletableFuture + .runAsync(() -> server.stop()) + .thenApply(f -> new StopResult() { + @Override + public T unwrap(final Class nativeClass) { + return nativeClass.cast(Void.class); + } + }); + } + + @Override + public T unwrap(Class nativeClass) { + return nativeClass.cast(Server.class); + } + +} diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartBuilderImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartBuilderImpl.java index deff726dfe6..ceb4d64fea6 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartBuilderImpl.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartBuilderImpl.java @@ -1,3 +1,22 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.cxf.jaxrs.impl; import java.io.ByteArrayInputStream; @@ -6,115 +25,127 @@ import java.io.InputStream; import java.util.Objects; -import org.apache.cxf.jaxrs.provider.ProviderFactory; - import jakarta.ws.rs.WebApplicationException; import jakarta.ws.rs.core.EntityPart; import jakarta.ws.rs.core.EntityPart.Builder; -import jakarta.ws.rs.ext.MessageBodyWriter; import jakarta.ws.rs.core.GenericType; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.MultivaluedHashMap; import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.ext.MessageBodyWriter; +import org.apache.cxf.jaxrs.provider.ProviderFactory; +import org.apache.cxf.jaxrs.utils.JAXRSUtils; +import org.apache.cxf.message.Message; public class EntityPartBuilderImpl implements EntityPart.Builder { - - private final String name; - private MediaType mediaType; - private MultivaluedMap headers = new MultivaluedHashMap<>(); - private String fileName; - private InputStream content; - - public EntityPartBuilderImpl(String name) { - this.name = name; - } - - @Override - public Builder mediaType(MediaType mediaType) throws IllegalArgumentException { - this.mediaType = mediaType; - return this; - } - - @Override - public Builder mediaType(String mediaTypeString) throws IllegalArgumentException { - this.mediaType = MediaType.valueOf(mediaTypeString); - return this; - } - - @Override - public Builder header(String headerName, String... headerValues) throws IllegalArgumentException { - headers.addAll(headerName, headerValues); - return this; - } - - @Override - public Builder headers(MultivaluedMap newHeaders) throws IllegalArgumentException { - headers.clear(); - headers.putAll(newHeaders); - return this; - } - - @Override - public Builder fileName(String fileName) throws IllegalArgumentException { - this.fileName = fileName; - return this; - } - - @Override - public Builder content(InputStream content) throws IllegalArgumentException { - this.content = content; - return this; - } - - @Override - public Builder content(T content, Class type) throws IllegalArgumentException { - final MediaType mediaTypeForWrite = Objects.requireNonNullElse(mediaType, MediaType.APPLICATION_OCTET_STREAM_TYPE); - - @SuppressWarnings({ "unchecked", "rawtypes" }) - final MessageBodyWriter writer = (MessageBodyWriter) ProviderFactory.getInstance(null).createMessageBodyWriter(type, null, null, mediaTypeForWrite, null); - - @SuppressWarnings({ "unchecked", "rawtypes" }) - final MultivaluedMap headersForWrite = (MultivaluedMap) headers; - - try { - final ByteArrayOutputStream out = new ByteArrayOutputStream(); - writer.writeTo(content, type, null, null, mediaType, headersForWrite, out); - content(new ByteArrayInputStream(out.toByteArray())); - } catch (WebApplicationException e) { - throw new IllegalArgumentException(e); - } catch (IOException e) { - throw new IllegalArgumentException(e); - } - - return this; - } - - @Override - public Builder content(T content, GenericType type) throws IllegalArgumentException { - final MediaType mediaTypeForWrite = Objects.requireNonNullElse(mediaType, MediaType.APPLICATION_OCTET_STREAM_TYPE); - - @SuppressWarnings({ "unchecked", "rawtypes" }) - final MessageBodyWriter writer = (MessageBodyWriter) ProviderFactory.getInstance(null).createMessageBodyWriter(type.getRawType(), type.getType(), null, mediaTypeForWrite, null); - - @SuppressWarnings({ "unchecked", "rawtypes" }) - final MultivaluedMap headersForWrite = (MultivaluedMap) headers; - - try { - final ByteArrayOutputStream out = new ByteArrayOutputStream(); - writer.writeTo(content, type.getRawType(), type.getType(), null, mediaType, headersForWrite, out); - content(new ByteArrayInputStream(out.toByteArray())); - } catch (WebApplicationException e) { - throw new IllegalArgumentException(e); - } catch (IOException e) { - throw new IllegalArgumentException(e); - } - - return this; - } - - @Override - public EntityPart build() throws IllegalStateException, IOException, WebApplicationException { - return new EntityPartImpl(name, fileName, content, headers, mediaType); - } - + private final String name; + private MediaType mediaType; + private MultivaluedMap headers = new MultivaluedHashMap<>(); + private String fileName; + private Object content; + private GenericType genericType; + private Class type; + + public EntityPartBuilderImpl(String name) { + this.name = name; + } + + @Override + public Builder mediaType(MediaType mediaType) throws IllegalArgumentException { + this.mediaType = mediaType; + return this; + } + + @Override + public Builder mediaType(String mediaTypeString) throws IllegalArgumentException { + this.mediaType = MediaType.valueOf(mediaTypeString); + return this; + } + + @Override + public Builder header(String headerName, String... headerValues) throws IllegalArgumentException { + headers.addAll(headerName, headerValues); + return this; + } + + @Override + public Builder headers(MultivaluedMap newHeaders) throws IllegalArgumentException { + headers.clear(); + headers.putAll(newHeaders); + return this; + } + + @Override + public Builder fileName(String fileName) throws IllegalArgumentException { + this.fileName = fileName; + return this; + } + + @Override + public Builder content(InputStream content) throws IllegalArgumentException { + this.content = content; + return this; + } + + @Override + public Builder content(T content, Class type) throws IllegalArgumentException { + this.content = content; + this.type = type; + this.genericType = null; + return this; + } + + @Override + public Builder content(T content, GenericType type) throws IllegalArgumentException { + this.content = content; + this.genericType = type; + this.type = null; + return this; + } + + @Override + public EntityPart build() throws IllegalStateException, IOException, WebApplicationException { + final MediaType mt = Objects.requireNonNullElse(mediaType, MediaType.APPLICATION_OCTET_STREAM_TYPE); + final Message message = JAXRSUtils.getCurrentMessage(); + + if (genericType != null) { + try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) { + writeTo(genericType, mt, message, out); + return new EntityPartImpl(name, fileName, new ByteArrayInputStream(out.toByteArray()), headers, mt); + } + } else if (type != null) { + try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) { + writeTo(type, mt, message, out); + return new EntityPartImpl(name, fileName, new ByteArrayInputStream(out.toByteArray()), headers, mt); + } + } else { + throw new IllegalStateException("Either type or genericType is expected for the content"); + } + } + + @SuppressWarnings("unchecked") + private void writeTo(final GenericType type, final MediaType mt, final Message message, + final ByteArrayOutputStream out) throws IOException { + + final MessageBodyWriter writer = (MessageBodyWriter) ProviderFactory + .getInstance(message) + .createMessageBodyWriter(genericType.getRawType(), genericType.getType(), null, mt, message); + + writer.writeTo((T) content, type.getRawType(), type.getType(), null, mt, cast(headers), out); + } + + @SuppressWarnings("unchecked") + private void writeTo(final Class type, final MediaType mt, final Message message, + final ByteArrayOutputStream out) throws IOException { + + final MessageBodyWriter writer = (MessageBodyWriter) ProviderFactory + .getInstance(message) + .createMessageBodyWriter(type, null, null, mt, message); + + writer.writeTo((T) content, type, null, null, mt, cast(headers), out); + } + + private static MultivaluedMap cast(MultivaluedMap p) { + return (MultivaluedMap)p; + } } diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java index de4181201de..e2e38f68f8d 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java @@ -1,74 +1,89 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.cxf.jaxrs.impl; import java.io.IOException; import java.io.InputStream; import java.util.Optional; -import org.apache.cxf.jaxrs.provider.ProviderFactory; - import jakarta.ws.rs.WebApplicationException; import jakarta.ws.rs.core.EntityPart; import jakarta.ws.rs.core.GenericType; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.MultivaluedMap; import jakarta.ws.rs.ext.MessageBodyReader; +import org.apache.cxf.jaxrs.provider.ProviderFactory; public class EntityPartImpl implements EntityPart { + private final String name; + private final String fileName; + private final InputStream content; + private final MultivaluedMap headers; + private final MediaType mediaType; - private final String name; - private final String fileName; - private final InputStream content; - private final MultivaluedMap headers; - private final MediaType mediaType; - - EntityPartImpl(String name, String fileName, InputStream content, MultivaluedMap headers, MediaType mediaType) { - this.name = name; - this.fileName = fileName; - this.content = content; - this.headers = headers; - this.mediaType = mediaType; - } - - @Override - public String getName() { - return name; - } + EntityPartImpl(String name, String fileName, InputStream content, MultivaluedMap headers, MediaType mediaType) { + this.name = name; + this.fileName = fileName; + this.content = content; + this.headers = headers; + this.mediaType = mediaType; + } - @Override - public Optional getFileName() { - return Optional.ofNullable(fileName); - } + @Override + public String getName() { + return name; + } - @Override - public InputStream getContent() { - return content; - } + @Override + public Optional getFileName() { + return Optional.ofNullable(fileName); + } - @Override - public T getContent(Class type) throws IllegalArgumentException, IllegalStateException, IOException, WebApplicationException { - @SuppressWarnings({ "unchecked", "rawtypes" }) - final MessageBodyReader reader = (MessageBodyReader) ProviderFactory.getInstance(null).createMessageBodyReader(type, null, null, mediaType, null); + @Override + public InputStream getContent() { + return content; + } - return reader.readFrom(type, null, null, mediaType, headers, content); - } + @Override + public T getContent(Class type) throws IllegalArgumentException, IllegalStateException, IOException, WebApplicationException { + @SuppressWarnings({ "unchecked", "rawtypes" }) + final MessageBodyReader reader = (MessageBodyReader) ProviderFactory.getInstance(null).createMessageBodyReader(type, null, null, mediaType, null); - @SuppressWarnings("unchecked") - @Override - public T getContent(GenericType type) throws IllegalArgumentException, IllegalStateException, IOException, WebApplicationException { - @SuppressWarnings("rawtypes") - final MessageBodyReader reader = (MessageBodyReader) ProviderFactory.getInstance(null).createMessageBodyReader(type.getRawType(), type.getType(), null, mediaType, null); + return reader.readFrom(type, null, null, mediaType, headers, content); + } - return reader.readFrom((Class) type.getRawType(), type.getType(), null, mediaType, headers, content); - } + @SuppressWarnings("unchecked") + @Override + public T getContent(GenericType type) throws IllegalArgumentException, IllegalStateException, IOException, WebApplicationException { + @SuppressWarnings("rawtypes") + final MessageBodyReader reader = (MessageBodyReader) ProviderFactory.getInstance(null).createMessageBodyReader(type.getRawType(), type.getType(), null, mediaType, null); + return reader.readFrom((Class) type.getRawType(), type.getType(), null, mediaType, headers, content); + } - @Override - public MultivaluedMap getHeaders() { - return headers; - } + @Override + public MultivaluedMap getHeaders() { + return headers; + } - @Override - public MediaType getMediaType() { - return mediaType; - } - + @Override + public MediaType getMediaType() { + return mediaType; + } } diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java index b5882f81708..062897d1b8b 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java @@ -19,15 +19,22 @@ package org.apache.cxf.jaxrs.impl; +import java.net.URI; +import java.security.AccessController; +import java.security.PrivilegedExceptionAction; import java.util.Date; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; -import jakarta.ws.rs.SeBootstrap; +import jakarta.ws.rs.SeBootstrap.Configuration; +import jakarta.ws.rs.SeBootstrap.Configuration.Builder; +import jakarta.ws.rs.SeBootstrap.Instance; import jakarta.ws.rs.core.Application; import jakarta.ws.rs.core.CacheControl; import jakarta.ws.rs.core.Cookie; +import jakarta.ws.rs.core.EntityPart; import jakarta.ws.rs.core.EntityTag; import jakarta.ws.rs.core.Link; import jakarta.ws.rs.core.MediaType; @@ -38,14 +45,12 @@ import jakarta.ws.rs.ext.RuntimeDelegate; import org.apache.cxf.endpoint.Server; import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; -import org.apache.cxf.jaxrs.impl.bootstrap.ConfigurationBuilderImpl; +import org.apache.cxf.jaxrs.bootstrap.ConfigurationBuilderImpl; +import org.apache.cxf.jaxrs.bootstrap.InstanceImpl; import org.apache.cxf.jaxrs.utils.ResourceUtils; - - public class RuntimeDelegateImpl extends RuntimeDelegate { - protected Map, HeaderDelegate> headerProviders - = new HashMap<>(); + protected Map, HeaderDelegate> headerProviders = new HashMap<>(); public RuntimeDelegateImpl() { headerProviders.put(MediaType.class, new MediaTypeHeaderProvider()); @@ -121,31 +126,47 @@ public T createEndpoint(Application app, Class endpointType) return endpointType.cast(server); } - - @Override public Link.Builder createLinkBuilder() { return new LinkBuilderImpl(); } @Override - public SeBootstrap.Configuration.Builder createConfigurationBuilder() { + public Builder createConfigurationBuilder() { return new ConfigurationBuilderImpl(); } @Override - public CompletionStage bootstrap(Application application, SeBootstrap.Configuration configuration) { - throw new UnsupportedOperationException("Bootstrap API not yet supported"); + public CompletionStage bootstrap(Application application, Configuration configuration) { + final JAXRSServerFactoryBean factory = ResourceUtils.createApplication(application, false, false, false, null); + final URI address = configuration.baseUriBuilder().path(factory.getAddress()).build(); + factory.setAddress(address.toString()); + factory.setStart(true); + + return CompletableFuture + .supplyAsync(() -> factory.create()) + .thenApply(s -> new InstanceImpl(s, configuration)); } @Override - public CompletionStage bootstrap(Class clazz, SeBootstrap.Configuration configuration) { - throw new UnsupportedOperationException("Bootstrap API not yet supported"); + public CompletionStage bootstrap(Class clazz, Configuration configuration) { + try { + final Application application = AccessController.doPrivileged( + new PrivilegedExceptionAction() { + @Override + public Application run() throws Exception { + return clazz.getDeclaredConstructor().newInstance(); + } + } + ); + return bootstrap(application, configuration); + } catch (final Exception ex) { + return CompletableFuture.failedStage(ex); + } } @Override - public jakarta.ws.rs.core.EntityPart.Builder createEntityPartBuilder(String partName) throws IllegalArgumentException { + public EntityPart.Builder createEntityPartBuilder(String partName) throws IllegalArgumentException { return new EntityPartBuilderImpl(partName); } - } diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/bootstrap/ConfigurationBuilderImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/bootstrap/ConfigurationBuilderImpl.java deleted file mode 100644 index ed797358562..00000000000 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/bootstrap/ConfigurationBuilderImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.apache.cxf.jaxrs.impl.bootstrap; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.function.BiFunction; - -import javax.net.ssl.SSLContext; - -import jakarta.ws.rs.SeBootstrap; -import jakarta.ws.rs.SeBootstrap.Configuration.SSLClientAuthentication; - -public class ConfigurationBuilderImpl implements SeBootstrap.Configuration.Builder { - - private final Map properties = new HashMap<>(); - - @Override - public SeBootstrap.Configuration build() { - return new ConfigurationImpl(properties); - } - - @Override - public SeBootstrap.Configuration.Builder property(String name, Object value) { - properties.put(name, value); - return this; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public SeBootstrap.Configuration.Builder from(BiFunction, Optional> propertiesProvider) { - final BiFunction, Optional> stringPropertiesProvider = (BiFunction) propertiesProvider; - final BiFunction, Optional> integerPropertiesProvider = (BiFunction) propertiesProvider; - final BiFunction, Optional> sslContextPropertiesProvider = (BiFunction) propertiesProvider; - final BiFunction, Optional> sslClientAuthenticationPropertiesProvider = (BiFunction) propertiesProvider; - - stringPropertiesProvider.apply(SeBootstrap.Configuration.PROTOCOL, String.class).ifPresent(this::protocol); - stringPropertiesProvider.apply(SeBootstrap.Configuration.HOST, String.class).ifPresent(this::host); - integerPropertiesProvider.apply(SeBootstrap.Configuration.PORT, Integer.class).ifPresent(this::port); - stringPropertiesProvider.apply(SeBootstrap.Configuration.ROOT_PATH, String.class).ifPresent(this::rootPath); - sslContextPropertiesProvider.apply(SeBootstrap.Configuration.SSL_CONTEXT, SSLContext.class).ifPresent(this::sslContext); - sslClientAuthenticationPropertiesProvider.apply(SeBootstrap.Configuration.SSL_CLIENT_AUTHENTICATION, SSLClientAuthentication.class).ifPresent(this::sslClientAuthentication); - - return this; - } - -} diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/bootstrap/ConfigurationImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/bootstrap/ConfigurationImpl.java deleted file mode 100644 index 5e29bb7fceb..00000000000 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/bootstrap/ConfigurationImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.apache.cxf.jaxrs.impl.bootstrap; - -import java.util.Map; - -import jakarta.ws.rs.SeBootstrap; - -public class ConfigurationImpl implements SeBootstrap.Configuration { - - private final Map properties; - - ConfigurationImpl(Map properties) { - this.properties = properties; - } - - @Override - public Object property(String name) { - return properties.get(name); - } - -} diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java index 6b0f77ea1e8..3cb011c9225 100644 --- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java +++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java @@ -49,6 +49,7 @@ import jakarta.ws.rs.WebApplicationException; import jakarta.ws.rs.client.ResponseProcessingException; import jakarta.ws.rs.core.Application; +import jakarta.ws.rs.core.EntityPart; import jakarta.ws.rs.core.EntityTag; import jakarta.ws.rs.core.GenericEntity; import jakarta.ws.rs.core.HttpHeaders; @@ -70,7 +71,7 @@ import jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate; import org.apache.cxf.endpoint.Endpoint; import org.apache.cxf.helpers.IOUtils; -import org.apache.cxf.jaxrs.impl.bootstrap.ConfigurationBuilderImpl; +import org.apache.cxf.jaxrs.bootstrap.ConfigurationBuilderImpl; import org.apache.cxf.jaxrs.provider.ProviderFactory; import org.apache.cxf.jaxrs.provider.ServerProviderFactory; import org.apache.cxf.jaxrs.resources.Book; @@ -856,17 +857,17 @@ public jakarta.ws.rs.SeBootstrap.Configuration.Builder createConfigurationBuilde @Override public CompletionStage bootstrap(Application application, Configuration configuration) { - throw new UnsupportedOperationException("Unimplemented method 'bootstrap'"); + return original.bootstrap(application, configuration); } @Override public CompletionStage bootstrap(Class clazz, Configuration configuration) { - throw new UnsupportedOperationException("Unimplemented method 'bootstrap'"); + return original.bootstrap(clazz, configuration); } @Override - public jakarta.ws.rs.core.EntityPart.Builder createEntityPartBuilder(String partName) throws IllegalArgumentException { - return new EntityPartBuilderImpl(partName); + public EntityPart.Builder createEntityPartBuilder(String partName) throws IllegalArgumentException { + return original.createEntityPartBuilder(partName); } } From 434236aba0295b0ab2dcc161634507be8bd22a1f Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Thu, 13 Apr 2023 21:16:38 -0400 Subject: [PATCH 17/28] Partially implement TLS/SSL in SE bootstrap (needs some work on CXF engines) --- .../cxf/jaxrs/impl/RuntimeDelegateImpl.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java index 062897d1b8b..025ea25824e 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java @@ -28,8 +28,11 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; +import javax.net.ssl.SSLContext; + import jakarta.ws.rs.SeBootstrap.Configuration; import jakarta.ws.rs.SeBootstrap.Configuration.Builder; +import jakarta.ws.rs.SeBootstrap.Configuration.SSLClientAuthentication; import jakarta.ws.rs.SeBootstrap.Instance; import jakarta.ws.rs.core.Application; import jakarta.ws.rs.core.CacheControl; @@ -43,6 +46,9 @@ import jakarta.ws.rs.core.UriBuilder; import jakarta.ws.rs.core.Variant.VariantListBuilder; import jakarta.ws.rs.ext.RuntimeDelegate; + +import org.apache.cxf.configuration.jsse.TLSServerParameters; +import org.apache.cxf.configuration.security.ClientAuthentication; import org.apache.cxf.endpoint.Server; import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; import org.apache.cxf.jaxrs.bootstrap.ConfigurationBuilderImpl; @@ -142,6 +148,30 @@ public CompletionStage bootstrap(Application application, Configuratio final URI address = configuration.baseUriBuilder().path(factory.getAddress()).build(); factory.setAddress(address.toString()); factory.setStart(true); + + if ("https".equalsIgnoreCase(configuration.protocol())) { + final TLSServerParameters parameters = new TLSServerParameters(); + + final SSLClientAuthentication sslClientAuthentication = configuration.sslClientAuthentication(); + if (sslClientAuthentication != null) { + final ClientAuthentication clientAuthentication = new ClientAuthentication(); + + if (sslClientAuthentication == SSLClientAuthentication.OPTIONAL) { + clientAuthentication.setWant(true); + } else if (sslClientAuthentication == SSLClientAuthentication.MANDATORY) { + clientAuthentication.setRequired(true); + } + + parameters.setClientAuthentication(clientAuthentication); + } + + final SSLContext sslContext = configuration.sslContext(); + if (sslContext != null) { + parameters.setSecureSocketProtocol(sslContext.getProtocol()); + } + + // TODO: Support SSL context propagation down to HTTP engine + } return CompletableFuture .supplyAsync(() -> factory.create()) From 50342d406ca87c5cb8bf9083d6185aff76f81d0f Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Sun, 14 May 2023 10:39:44 -0400 Subject: [PATCH 18/28] Fix cxf-tools-wadlto-jaxrs test cases --- .../test/resources/wadl/bookstoreDigit.xml | 52 +++++++++---------- .../test/resources/wadl/bookstoreHyphen.xml | 34 ++++++------ .../wadl/resourceSchemaNoTargetNamespace.xml | 38 +++++++------- 3 files changed, 62 insertions(+), 62 deletions(-) diff --git a/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreDigit.xml b/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreDigit.xml index 8c90fb5f153..b7c811ffc14 100644 --- a/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreDigit.xml +++ b/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreDigit.xml @@ -17,10 +17,10 @@ specific language governing permissions and limitations under the License. --> - - - + + @@ -30,27 +30,27 @@ - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + diff --git a/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreHyphen.xml b/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreHyphen.xml index f040db08d37..da3172ed301 100644 --- a/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreHyphen.xml +++ b/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreHyphen.xml @@ -17,10 +17,10 @@ specific language governing permissions and limitations under the License. --> - - - + + @@ -30,17 +30,17 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/tools/wadlto/jaxrs/src/test/resources/wadl/resourceSchemaNoTargetNamespace.xml b/tools/wadlto/jaxrs/src/test/resources/wadl/resourceSchemaNoTargetNamespace.xml index 5682e2d8ad2..ff70b48e698 100644 --- a/tools/wadlto/jaxrs/src/test/resources/wadl/resourceSchemaNoTargetNamespace.xml +++ b/tools/wadlto/jaxrs/src/test/resources/wadl/resourceSchemaNoTargetNamespace.xml @@ -1,8 +1,8 @@ - - - + + @@ -12,19 +12,19 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + From 24c079f3500f56304e319b432c65f3fefe856ecf Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Sat, 20 May 2023 15:05:21 -0400 Subject: [PATCH 19/28] Update Spring Boot to 3.1.0, Spring LDAP to 3.1.0, Spring Security to 6.1.0 --- distribution/src/main/release/samples/pom.xml | 2 +- parent/pom.xml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/distribution/src/main/release/samples/pom.xml b/distribution/src/main/release/samples/pom.xml index cc733b1efed..ad7c568bda8 100644 --- a/distribution/src/main/release/samples/pom.xml +++ b/distribution/src/main/release/samples/pom.xml @@ -31,7 +31,7 @@ true UTF-8 - 3.0.12 + 3.1.4 4.0.3 11.0.17 4.1.100.Final diff --git a/parent/pom.xml b/parent/pom.xml index f1a7053e6cc..a9fabd00c11 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -196,10 +196,10 @@ 2.0.9 2.2 2.3_2 - 3.0.12 - 3.0.6 + 3.1.4 + 3.1.0 spring-test - 6.0.8 + 6.1.2 6.0.13 1.8.3 5.9.0 From 1a3086dfbb54d828d514c24b456fee1925af3dab Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Tue, 4 Jul 2023 13:10:21 +1200 Subject: [PATCH 20/28] docs: Fix BUILDING.txt fastinstall line --- BUILDING.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILDING.txt b/BUILDING.txt index ad84d0efedf..2a74253b22a 100644 --- a/BUILDING.txt +++ b/BUILDING.txt @@ -29,7 +29,7 @@ Building $> mvn This will compile Apache CXF and run all of the tests in the Apache CXF source distribution. Alternatively, you can run - $> mvn -Pfastinstall. + $> mvn -Pfastinstall This will compile Apache CXF without running the tests and takes less time to build. Depending on the load of remote Maven repositories, you may have From 1f96a35b813b4e0c47595842f7c4e41ec6826a1a Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Mon, 18 Sep 2023 22:53:50 -0400 Subject: [PATCH 21/28] Fix compilation and checkstyle issues --- .../cxf/jaxrs/impl/EntityPartBuilderImpl.java | 44 +++++++++---------- .../apache/cxf/jaxrs/impl/EntityPartImpl.java | 18 +++++--- .../cxf/jaxrs/impl/RuntimeDelegateImpl.java | 1 - .../impl/RetryAfterHeaderProviderTest.java | 10 ++++- .../jetty/WebSocketVirtualServletRequest.java | 17 +++---- .../WebSocketVirtualServletResponse.java | 20 +++++++++ .../WebSocketUndertowServletRequest.java | 15 +++---- .../WebSocketUndertowServletResponse.java | 20 +++++++++ 8 files changed, 93 insertions(+), 52 deletions(-) diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartBuilderImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartBuilderImpl.java index ceb4d64fea6..a861b55aa43 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartBuilderImpl.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartBuilderImpl.java @@ -51,14 +51,14 @@ public EntityPartBuilderImpl(String name) { } @Override - public Builder mediaType(MediaType mediaType) throws IllegalArgumentException { - this.mediaType = mediaType; + public Builder mediaType(MediaType mt) throws IllegalArgumentException { + this.mediaType = mt; return this; } @Override - public Builder mediaType(String mediaTypeString) throws IllegalArgumentException { - this.mediaType = MediaType.valueOf(mediaTypeString); + public Builder mediaType(String mts) throws IllegalArgumentException { + this.mediaType = MediaType.valueOf(mts); return this; } @@ -76,29 +76,29 @@ public Builder headers(MultivaluedMap newHeaders) throws Illegal } @Override - public Builder fileName(String fileName) throws IllegalArgumentException { - this.fileName = fileName; + public Builder fileName(String fn) throws IllegalArgumentException { + this.fileName = fn; return this; } @Override - public Builder content(InputStream content) throws IllegalArgumentException { - this.content = content; + public Builder content(InputStream in) throws IllegalArgumentException { + this.content = in; return this; } @Override - public Builder content(T content, Class type) throws IllegalArgumentException { - this.content = content; - this.type = type; + public Builder content(T c, Class t) throws IllegalArgumentException { + this.content = c; + this.type = t; this.genericType = null; return this; } @Override - public Builder content(T content, GenericType type) throws IllegalArgumentException { - this.content = content; - this.genericType = type; + public Builder content(T c, GenericType t) throws IllegalArgumentException { + this.content = c; + this.genericType = t; this.type = null; return this; } @@ -109,12 +109,12 @@ public EntityPart build() throws IllegalStateException, IOException, WebApplicat final Message message = JAXRSUtils.getCurrentMessage(); if (genericType != null) { - try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) { + try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { writeTo(genericType, mt, message, out); return new EntityPartImpl(name, fileName, new ByteArrayInputStream(out.toByteArray()), headers, mt); } } else if (type != null) { - try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) { + try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { writeTo(type, mt, message, out); return new EntityPartImpl(name, fileName, new ByteArrayInputStream(out.toByteArray()), headers, mt); } @@ -124,25 +124,25 @@ public EntityPart build() throws IllegalStateException, IOException, WebApplicat } @SuppressWarnings("unchecked") - private void writeTo(final GenericType type, final MediaType mt, final Message message, + private void writeTo(final GenericType t, final MediaType mt, final Message message, final ByteArrayOutputStream out) throws IOException { final MessageBodyWriter writer = (MessageBodyWriter) ProviderFactory .getInstance(message) - .createMessageBodyWriter(genericType.getRawType(), genericType.getType(), null, mt, message); + .createMessageBodyWriter(t.getRawType(), t.getType(), null, mt, message); - writer.writeTo((T) content, type.getRawType(), type.getType(), null, mt, cast(headers), out); + writer.writeTo((T) content, t.getRawType(), t.getType(), null, mt, cast(headers), out); } @SuppressWarnings("unchecked") - private void writeTo(final Class type, final MediaType mt, final Message message, + private void writeTo(final Class t, final MediaType mt, final Message message, final ByteArrayOutputStream out) throws IOException { final MessageBodyWriter writer = (MessageBodyWriter) ProviderFactory .getInstance(message) - .createMessageBodyWriter(type, null, null, mt, message); + .createMessageBodyWriter(t, null, null, mt, message); - writer.writeTo((T) content, type, null, null, mt, cast(headers), out); + writer.writeTo((T) content, t, null, null, mt, cast(headers), out); } private static MultivaluedMap cast(MultivaluedMap p) { diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java index e2e38f68f8d..24eb88a2e7c 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java @@ -38,7 +38,8 @@ public class EntityPartImpl implements EntityPart { private final MultivaluedMap headers; private final MediaType mediaType; - EntityPartImpl(String name, String fileName, InputStream content, MultivaluedMap headers, MediaType mediaType) { + EntityPartImpl(String name, String fileName, InputStream content, + MultivaluedMap headers, MediaType mediaType) { this.name = name; this.fileName = fileName; this.content = content; @@ -62,18 +63,25 @@ public InputStream getContent() { } @Override - public T getContent(Class type) throws IllegalArgumentException, IllegalStateException, IOException, WebApplicationException { + public T getContent(Class type) + throws IllegalArgumentException, IllegalStateException, IOException, WebApplicationException { @SuppressWarnings({ "unchecked", "rawtypes" }) - final MessageBodyReader reader = (MessageBodyReader) ProviderFactory.getInstance(null).createMessageBodyReader(type, null, null, mediaType, null); + final MessageBodyReader reader = (MessageBodyReader) ProviderFactory + .getInstance(null) + .createMessageBodyReader(type, null, null, mediaType, null); return reader.readFrom(type, null, null, mediaType, headers, content); } @SuppressWarnings("unchecked") @Override - public T getContent(GenericType type) throws IllegalArgumentException, IllegalStateException, IOException, WebApplicationException { + public T getContent(GenericType type) + throws IllegalArgumentException, IllegalStateException, IOException, WebApplicationException { @SuppressWarnings("rawtypes") - final MessageBodyReader reader = (MessageBodyReader) ProviderFactory.getInstance(null).createMessageBodyReader(type.getRawType(), type.getType(), null, mediaType, null); + final MessageBodyReader reader = (MessageBodyReader) ProviderFactory + .getInstance(null) + .createMessageBodyReader(type.getRawType(), type.getType(), null, mediaType, null); + return reader.readFrom((Class) type.getRawType(), type.getType(), null, mediaType, headers, content); } diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java index 025ea25824e..4bd9bb0e5db 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java @@ -46,7 +46,6 @@ import jakarta.ws.rs.core.UriBuilder; import jakarta.ws.rs.core.Variant.VariantListBuilder; import jakarta.ws.rs.ext.RuntimeDelegate; - import org.apache.cxf.configuration.jsse.TLSServerParameters; import org.apache.cxf.configuration.security.ClientAuthentication; import org.apache.cxf.endpoint.Server; diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RetryAfterHeaderProviderTest.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RetryAfterHeaderProviderTest.java index 0c2e9809115..e7dd914abb4 100644 --- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RetryAfterHeaderProviderTest.java +++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RetryAfterHeaderProviderTest.java @@ -62,8 +62,14 @@ public static Collection data() throws ParseException { new Object[] {"Sun, 03 Nov 2002 08:49:37 EST", Duration.ofSeconds(89646577)}, new Object[] {"Sat, 01 Jan 2000 01:00:00 GMT", Duration.ofSeconds(3600)}, new Object[] {"Sunday, 03-Nov-02 08:49:37 GMT", Duration.ofSeconds(89628577)}, - new Object[] {"Sun Nov 3 08:49:37 2002", Duration.ofSeconds(89628577 - TimeZone.getDefault().getOffset(new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy", Locale.US).parse("Sun Nov 3 08:49:37 2002").getTime()) / 1000)}, - new Object[] {"Sun Nov 03 08:49:37 2002", Duration.ofSeconds(89628577 - TimeZone.getDefault().getOffset(new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy", Locale.US).parse("Sun Nov 03 08:49:37 2002").getTime()) / 1000)}, + new Object[] {"Sun Nov 3 08:49:37 2002", Duration.ofSeconds(89628577 - TimeZone.getDefault() + .getOffset( + new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy", Locale.US) + .parse("Sun Nov 3 08:49:37 2002").getTime()) / 1000)}, + new Object[] {"Sun Nov 03 08:49:37 2002", Duration.ofSeconds(89628577 - TimeZone.getDefault() + .getOffset( + new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy", Locale.US) + .parse("Sun Nov 03 08:49:37 2002").getTime()) / 1000)}, new Object[] {"Sun, 06 Nov 1994 08:49:37 EST", Duration.ZERO} ); diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletRequest.java b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletRequest.java index e0035ac6238..c85205c5ac1 100644 --- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletRequest.java +++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletRequest.java @@ -40,7 +40,6 @@ import jakarta.servlet.DispatcherType; import jakarta.servlet.ReadListener; import jakarta.servlet.RequestDispatcher; -import jakarta.servlet.ServletConnection; import jakarta.servlet.ServletContext; import jakarta.servlet.ServletException; import jakarta.servlet.ServletInputStream; @@ -547,19 +546,13 @@ public T upgrade(Class arg0) throws IOExceptio } @Override - public String getRequestId() { - LOG.log(Level.FINE, "getRequestId"); - return null; + public String getRealPath(String path) { + return path; } @Override - public String getProtocolRequestId() { - LOG.log(Level.FINE, "getProtocolRequestId"); - return null; - } - - @Override - public ServletConnection getServletConnection() { - throw new UnsupportedOperationException(); + public boolean isRequestedSessionIdFromUrl() { + LOG.log(Level.FINE, "isRequestedSessionIdFromUrl"); + return false; } } diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletResponse.java b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletResponse.java index f8248889665..000047e478c 100644 --- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletResponse.java +++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty/WebSocketVirtualServletResponse.java @@ -22,6 +22,8 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintWriter; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.Locale; import java.util.Map; @@ -360,4 +362,22 @@ public void setContentLengthLong(long arg0) { throw new UnsupportedOperationException(); } + + @Override + public String encodeUrl(String url) { + return URLEncoder.encode(url, StandardCharsets.UTF_8); + } + + @Override + public String encodeRedirectUrl(String url) { + return URLEncoder.encode(url, StandardCharsets.UTF_8); + } + + @Override + public void setStatus(int sc, String sm) { + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "setStatus({0})", sc); + } + responseHeaders.put(WebSocketUtils.SC_KEY, Integer.toString(sc)); + } } diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/undertow/WebSocketUndertowServletRequest.java b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/undertow/WebSocketUndertowServletRequest.java index 465ba87ee3b..864ade3132c 100644 --- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/undertow/WebSocketUndertowServletRequest.java +++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/undertow/WebSocketUndertowServletRequest.java @@ -42,7 +42,6 @@ import jakarta.servlet.DispatcherType; import jakarta.servlet.ReadListener; import jakarta.servlet.RequestDispatcher; -import jakarta.servlet.ServletConnection; import jakarta.servlet.ServletContext; import jakarta.servlet.ServletException; import jakarta.servlet.ServletInputStream; @@ -572,17 +571,13 @@ public T upgrade(Class arg0) throws IOExceptio } @Override - public String getRequestId() { - throw new UnsupportedOperationException(); + public String getRealPath(String path) { + return path; } @Override - public String getProtocolRequestId() { - throw new UnsupportedOperationException(); - } - - @Override - public ServletConnection getServletConnection() { - throw new UnsupportedOperationException(); + public boolean isRequestedSessionIdFromUrl() { + LOG.log(Level.FINE, "isRequestedSessionIdFromUrl"); + return false; } } diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/undertow/WebSocketUndertowServletResponse.java b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/undertow/WebSocketUndertowServletResponse.java index 35a6309e7c4..1e64fbfc886 100644 --- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/undertow/WebSocketUndertowServletResponse.java +++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/undertow/WebSocketUndertowServletResponse.java @@ -22,7 +22,9 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintWriter; +import java.net.URLEncoder; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.Locale; import java.util.Map; @@ -364,4 +366,22 @@ public void setContentLengthLong(long arg0) { throw new UnsupportedOperationException(); } + + @Override + public String encodeUrl(String url) { + return URLEncoder.encode(url, StandardCharsets.UTF_8); + } + + @Override + public String encodeRedirectUrl(String url) { + return URLEncoder.encode(url, StandardCharsets.UTF_8); + } + + @Override + public void setStatus(int sc, String sm) { + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "setStatus({0})", sc); + } + responseHeaders.put(WebSocketUtils.SC_KEY, Integer.toString(sc)); + } } From dd19b3ce1dfd4e8946c61271941485b11f278283 Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Tue, 3 Oct 2023 22:09:53 -0400 Subject: [PATCH 22/28] Update Hibernate to 6.2.9.Final --- parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index a9fabd00c11..1b2b74178ff 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -121,7 +121,7 @@ 32.1.3-jre 2.2 5.3.5 - 6.2.3.Final + 6.2.9.Final 7.0.5.Final 2.7.2 [4.0,4.2) From 24bcaf1ac7f95163c8235467a9e3c0a087163478 Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Tue, 3 Oct 2023 22:31:58 -0400 Subject: [PATCH 23/28] Update Hibernate to 6.3.1.Final --- parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index 1b2b74178ff..9bc0f85b44c 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -121,7 +121,7 @@ 32.1.3-jre 2.2 5.3.5 - 6.2.9.Final + 6.3.1.Final 7.0.5.Final 2.7.2 [4.0,4.2) From b06c530a4e4a7abdd02042e6b7141d2fdbaff2b9 Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Tue, 31 Oct 2023 10:43:38 -0400 Subject: [PATCH 24/28] Refactor EntityPartBuilderImpl & EntityPartImpl --- .../cxf/jaxrs/impl/EntityPartBuilderImpl.java | 31 ++++++++++--------- .../apache/cxf/jaxrs/impl/EntityPartImpl.java | 20 +++++++----- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartBuilderImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartBuilderImpl.java index a861b55aa43..c5d0e48afe4 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartBuilderImpl.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartBuilderImpl.java @@ -34,6 +34,7 @@ import jakarta.ws.rs.core.MultivaluedMap; import jakarta.ws.rs.ext.MessageBodyWriter; import org.apache.cxf.jaxrs.provider.ProviderFactory; +import org.apache.cxf.jaxrs.provider.ServerProviderFactory; import org.apache.cxf.jaxrs.utils.JAXRSUtils; import org.apache.cxf.message.Message; @@ -46,7 +47,7 @@ public class EntityPartBuilderImpl implements EntityPart.Builder { private GenericType genericType; private Class type; - public EntityPartBuilderImpl(String name) { + public EntityPartBuilderImpl(final String name) { this.name = name; } @@ -107,16 +108,19 @@ public Builder content(T c, GenericType t) throws IllegalArgumentExceptio public EntityPart build() throws IllegalStateException, IOException, WebApplicationException { final MediaType mt = Objects.requireNonNullElse(mediaType, MediaType.APPLICATION_OCTET_STREAM_TYPE); final Message message = JAXRSUtils.getCurrentMessage(); - + final ProviderFactory factory = ServerProviderFactory.getInstance(message); + if (genericType != null) { try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { - writeTo(genericType, mt, message, out); - return new EntityPartImpl(name, fileName, new ByteArrayInputStream(out.toByteArray()), headers, mt); + writeTo(factory, genericType, mt, message, out); + return new EntityPartImpl(factory, name, fileName, new ByteArrayInputStream(out.toByteArray()), + headers, mt); } } else if (type != null) { try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { - writeTo(type, mt, message, out); - return new EntityPartImpl(name, fileName, new ByteArrayInputStream(out.toByteArray()), headers, mt); + writeTo(factory, type, mt, message, out); + return new EntityPartImpl(factory, name, fileName, new ByteArrayInputStream(out.toByteArray()), + headers, mt); } } else { throw new IllegalStateException("Either type or genericType is expected for the content"); @@ -124,27 +128,26 @@ public EntityPart build() throws IllegalStateException, IOException, WebApplicat } @SuppressWarnings("unchecked") - private void writeTo(final GenericType t, final MediaType mt, final Message message, - final ByteArrayOutputStream out) throws IOException { + private void writeTo(final ProviderFactory providers, final GenericType t, final MediaType mt, + final Message message, final ByteArrayOutputStream out) throws IOException { - final MessageBodyWriter writer = (MessageBodyWriter) ProviderFactory - .getInstance(message) + final MessageBodyWriter writer = (MessageBodyWriter) providers .createMessageBodyWriter(t.getRawType(), t.getType(), null, mt, message); writer.writeTo((T) content, t.getRawType(), t.getType(), null, mt, cast(headers), out); } @SuppressWarnings("unchecked") - private void writeTo(final Class t, final MediaType mt, final Message message, - final ByteArrayOutputStream out) throws IOException { + private void writeTo(final ProviderFactory providers, final Class t, final MediaType mt, + final Message message, final ByteArrayOutputStream out) throws IOException { - final MessageBodyWriter writer = (MessageBodyWriter) ProviderFactory - .getInstance(message) + final MessageBodyWriter writer = (MessageBodyWriter) providers .createMessageBodyWriter(t, null, null, mt, message); writer.writeTo((T) content, t, null, null, mt, cast(headers), out); } + @SuppressWarnings("unchecked") private static MultivaluedMap cast(MultivaluedMap p) { return (MultivaluedMap)p; } diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java index 24eb88a2e7c..d302768b668 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java @@ -30,6 +30,8 @@ import jakarta.ws.rs.core.MultivaluedMap; import jakarta.ws.rs.ext.MessageBodyReader; import org.apache.cxf.jaxrs.provider.ProviderFactory; +import org.apache.cxf.jaxrs.utils.JAXRSUtils; +import org.apache.cxf.message.Message; public class EntityPartImpl implements EntityPart { private final String name; @@ -37,9 +39,11 @@ public class EntityPartImpl implements EntityPart { private final InputStream content; private final MultivaluedMap headers; private final MediaType mediaType; + private final ProviderFactory providers; - EntityPartImpl(String name, String fileName, InputStream content, + EntityPartImpl(final ProviderFactory providers, String name, String fileName, InputStream content, MultivaluedMap headers, MediaType mediaType) { + this.providers = providers; this.name = name; this.fileName = fileName; this.content = content; @@ -65,10 +69,11 @@ public InputStream getContent() { @Override public T getContent(Class type) throws IllegalArgumentException, IllegalStateException, IOException, WebApplicationException { + final Message message = JAXRSUtils.getCurrentMessage(); + @SuppressWarnings({ "unchecked", "rawtypes" }) - final MessageBodyReader reader = (MessageBodyReader) ProviderFactory - .getInstance(null) - .createMessageBodyReader(type, null, null, mediaType, null); + final MessageBodyReader reader = (MessageBodyReader) providers + .createMessageBodyReader(type, null, null, mediaType, message); return reader.readFrom(type, null, null, mediaType, headers, content); } @@ -77,10 +82,11 @@ public T getContent(Class type) @Override public T getContent(GenericType type) throws IllegalArgumentException, IllegalStateException, IOException, WebApplicationException { + final Message message = JAXRSUtils.getCurrentMessage(); + @SuppressWarnings("rawtypes") - final MessageBodyReader reader = (MessageBodyReader) ProviderFactory - .getInstance(null) - .createMessageBodyReader(type.getRawType(), type.getType(), null, mediaType, null); + final MessageBodyReader reader = (MessageBodyReader) providers + .createMessageBodyReader(type.getRawType(), type.getType(), null, mediaType, message); return reader.readFrom((Class) type.getRawType(), type.getType(), null, mediaType, headers, content); } From 181f7e6993b5f6362e71a8560984ce678feb93cb Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Tue, 31 Oct 2023 17:49:49 -0400 Subject: [PATCH 25/28] Replace JakarteEE 10 BOM with indvidual component versions to simplify patching and minor updates --- distribution/javadoc/pom.xml | 1 + distribution/manifest/pom.xml | 3 + integration/cdi/pom.xml | 1 + integration/spring-boot/autoconfigure/pom.xml | 1 + parent/pom.xml | 140 ++++++++++++++++-- rt/frontend/jaxrs/pom.xml | 1 + rt/rs/extensions/search/pom.xml | 1 + rt/rs/microprofile-client/pom.xml | 2 + rt/rs/security/oauth-parent/oauth2/pom.xml | 1 + rt/rs/security/sso/oidc/pom.xml | 1 + systests/microprofile/client/async/pom.xml | 3 + systests/microprofile/client/nocdi/pom.xml | 3 + systests/rs-security/pom.xml | 1 + tools/common/pom.xml | 1 + 14 files changed, 150 insertions(+), 10 deletions(-) diff --git a/distribution/javadoc/pom.xml b/distribution/javadoc/pom.xml index da516bebeaa..cdebd80268b 100644 --- a/distribution/javadoc/pom.xml +++ b/distribution/javadoc/pom.xml @@ -348,6 +348,7 @@ jakarta.persistence jakarta.persistence-api + ${cxf.persistence-api.version} org.apache.lucene diff --git a/distribution/manifest/pom.xml b/distribution/manifest/pom.xml index 250d073a06e..765caf0cece 100644 --- a/distribution/manifest/pom.xml +++ b/distribution/manifest/pom.xml @@ -320,6 +320,7 @@ jakarta.xml.ws jakarta.xml.ws-api + ${cxf.jakarta.wsapi.version} jakarta.xml.bind @@ -328,10 +329,12 @@ jakarta.jws jakarta.jws-api + ${cxf.jakarta.jwsapi.version} jakarta.xml.soap jakarta.xml.soap-api + ${cxf.jakarta.soapapi.version} diff --git a/integration/cdi/pom.xml b/integration/cdi/pom.xml index 31dfbe0eaea..0296b51cbd1 100644 --- a/integration/cdi/pom.xml +++ b/integration/cdi/pom.xml @@ -52,6 +52,7 @@ jakarta.inject jakarta.inject-api + ${cxf.jakarta.injectapi.version} junit diff --git a/integration/spring-boot/autoconfigure/pom.xml b/integration/spring-boot/autoconfigure/pom.xml index f44ff9b9fd4..11b0292a107 100644 --- a/integration/spring-boot/autoconfigure/pom.xml +++ b/integration/spring-boot/autoconfigure/pom.xml @@ -122,6 +122,7 @@ jakarta.servlet jakarta.servlet-api + ${cxf.servlet-api.version} true diff --git a/parent/pom.xml b/parent/pom.xml index 9bc0f85b44c..48ba9b1f5a8 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -98,7 +98,7 @@ 3.0.3 1.70 5.16.0 - 3.0.0 + 4.0.1 4.8.25 1.5.1 1.16.0 @@ -112,6 +112,7 @@ 3.2.6 4.2.21 3.10.8 + 5.0.1 3.0.2 2.1.1 1.1.1 @@ -135,13 +136,24 @@ 2.15.3 3.9 1.8.1 - 10.0.0 + 2.1.2 + 2.1.2 + 2.0.1 + 2.1.0 3.0.0 + 3.0.1 + 4.0.1 + 3.1.0 + 2.0.1 + 4.0.1 + 2.1.0 1.1.4 0.7.2 3.29.2-GA + 2.1.1 + 3.1.0 4.0.2 - 4.0.0 + 4.0.1 ${cxf.jaxb.runtime.version} 2.0.0 3.5.3.Final @@ -155,6 +167,8 @@ 3.3 2.10.10 1.2.20 + 2.1.3 + 3.0.0 1.0 4.13.2 5.10.0 @@ -182,6 +196,7 @@ 1.22.0-alpha 0.33.0 2.0.27 + 3.1.0 4.8.0 3.5.1 1.0.4 @@ -193,6 +208,7 @@ 3.0.0 jakarta.servlet-api jakarta.servlet + 6.0.0 2.0.9 2.2 2.3_2 @@ -208,6 +224,12 @@ 10.1.14 1.8 2.3.5.Final + + + [3,4) + 3.0.2 2.3 1.6.0.Final 3.2.0 @@ -745,15 +767,27 @@ logback-classic ${cxf.logback.classic.version} - - jakarta.platform - jakarta.jakartaee-bom - ${cxf.jakarta.ee.version} - pom - import + jakarta.transaction + jakarta.transaction-api + ${cxf.jakarta.transaction.version} + + + jakarta.ws.rs + jakarta.ws.rs-api + ${cxf.jakarta.ws.rs.version} + + + jakarta.xml.bind + jakarta.xml.bind-api + ${cxf.jaxb.version} + + + com.sun.activation + jakarta.activation + + - cglib cglib-nodep @@ -1011,6 +1045,35 @@ + + jakarta.validation + jakarta.validation-api + ${cxf.validation.api.version} + true + + + jakarta.enterprise + jakarta.enterprise.cdi-api + ${cxf.cdi.api.version} + true + + + jakarta.inject + jakarta.inject-api + ${cxf.jakarta.injectapi.version} + true + + + jakarta.json + jakarta.json-api + ${cxf.json.api.version} + true + + + jakarta.json.bind + jakarta.json.bind-api + ${cxf.json.bind-api.version} + org.glassfish jakarta.json @@ -1571,11 +1634,43 @@ + + jakarta.annotation + jakarta.annotation-api + ${cxf.jakarta.annotation-api.version} + + + jakarta.xml.ws + jakarta.xml.ws-api + ${cxf.jakarta.wsapi.version} + + + com.sun.activation + jakarta.activation + + + jakarta.jws jakarta.jws-api ${cxf.jakarta.jwsapi.version} + + jakarta.xml.soap + jakarta.xml.soap-api + ${cxf.jakarta.soapapi.version} + + + com.sun.activation + jakarta.activation + + + + + ${cxf.servlet-api.group} + ${cxf.servlet-api.artifact} + ${cxf.servlet-api.version} + com.sun.xml.messaging.saaj saaj-impl @@ -1587,11 +1682,21 @@ + + jakarta.activation + jakarta.activation-api + ${cxf.jakarta.activation.version} + org.eclipse.angus angus-activation ${cxf.jakarta.angus.activation.version} + + jakarta.mail + jakarta.mail-api + ${cxf.jakarta.mail.version} + org.eclipse.angus angus-mail @@ -1602,6 +1707,21 @@ jakarta.management.j2ee-api ${cxf.jakarta.management.j2ee-api.version} + + jakarta.jms + jakarta.jms-api + ${cxf.jakarta.jms.version} + + + jakarta.resource + jakarta.resource-api + ${cxf.jakarta.resource.version} + + + jakarta.ejb + jakarta.ejb-api + ${cxf.jakarta.ejb.version} + org.apache.activemq artemis-jakarta-server diff --git a/rt/frontend/jaxrs/pom.xml b/rt/frontend/jaxrs/pom.xml index 3d3bde9b886..7a11e12f1ed 100644 --- a/rt/frontend/jaxrs/pom.xml +++ b/rt/frontend/jaxrs/pom.xml @@ -106,6 +106,7 @@ jakarta.servlet jakarta.servlet-api + ${cxf.servlet-api.version} provided true diff --git a/rt/rs/extensions/search/pom.xml b/rt/rs/extensions/search/pom.xml index 5a13dcb6d2c..79c2e00e90e 100644 --- a/rt/rs/extensions/search/pom.xml +++ b/rt/rs/extensions/search/pom.xml @@ -64,6 +64,7 @@ jakarta.persistence jakarta.persistence-api + ${cxf.persistence-api.version} provided true diff --git a/rt/rs/microprofile-client/pom.xml b/rt/rs/microprofile-client/pom.xml index b00d0cdd912..2e8aed11b27 100644 --- a/rt/rs/microprofile-client/pom.xml +++ b/rt/rs/microprofile-client/pom.xml @@ -98,10 +98,12 @@ jakarta.inject jakarta.inject-api + ${cxf.jakarta.injectapi.version} jakarta.interceptor jakarta.interceptor-api + ${cxf.jakarta.interceptorapi.version} jakarta.json diff --git a/rt/rs/security/oauth-parent/oauth2/pom.xml b/rt/rs/security/oauth-parent/oauth2/pom.xml index fce283d3fa6..1f32110b2b2 100644 --- a/rt/rs/security/oauth-parent/oauth2/pom.xml +++ b/rt/rs/security/oauth-parent/oauth2/pom.xml @@ -72,6 +72,7 @@ jakarta.persistence jakarta.persistence-api + ${cxf.persistence-api.version} provided true diff --git a/rt/rs/security/sso/oidc/pom.xml b/rt/rs/security/sso/oidc/pom.xml index ce96b79368d..4414fd18429 100644 --- a/rt/rs/security/sso/oidc/pom.xml +++ b/rt/rs/security/sso/oidc/pom.xml @@ -51,6 +51,7 @@ jakarta.persistence jakarta.persistence-api + ${cxf.persistence-api.version} provided true diff --git a/systests/microprofile/client/async/pom.xml b/systests/microprofile/client/async/pom.xml index 1076ba6969d..30d46959d64 100644 --- a/systests/microprofile/client/async/pom.xml +++ b/systests/microprofile/client/async/pom.xml @@ -49,6 +49,7 @@ jakarta.ws.rs jakarta.ws.rs-api + ${cxf.jakarta.ws.rs.version} org.jboss.weld.se @@ -78,11 +79,13 @@ jakarta.json.bind jakarta.json.bind-api + ${cxf.json.bind-api.version} test jakarta.json jakarta.json-api + ${cxf.json.api.version} test diff --git a/systests/microprofile/client/nocdi/pom.xml b/systests/microprofile/client/nocdi/pom.xml index d9b74f0b4ed..4048f2520dc 100644 --- a/systests/microprofile/client/nocdi/pom.xml +++ b/systests/microprofile/client/nocdi/pom.xml @@ -49,6 +49,7 @@ jakarta.ws.rs jakarta.ws.rs-api + ${cxf.jakarta.ws.rs.version} org.eclipse.microprofile.rest.client @@ -66,11 +67,13 @@ jakarta.json.bind jakarta.json.bind-api + ${cxf.json.bind-api.version} test jakarta.json jakarta.json-api + ${cxf.json.api.version} test diff --git a/systests/rs-security/pom.xml b/systests/rs-security/pom.xml index 6a3cc3325ea..52c6c6e00ef 100644 --- a/systests/rs-security/pom.xml +++ b/systests/rs-security/pom.xml @@ -206,6 +206,7 @@ jakarta.persistence jakarta.persistence-api + ${cxf.persistence-api.version} test diff --git a/tools/common/pom.xml b/tools/common/pom.xml index 93eb1da06db..427923942dc 100644 --- a/tools/common/pom.xml +++ b/tools/common/pom.xml @@ -41,6 +41,7 @@ jakarta.jws jakarta.jws-api + ${cxf.jakarta.jwsapi.version} org.apache.velocity From c26ffb46aba2fa179acc918d786c9825ec0a2558 Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Tue, 31 Oct 2023 22:09:36 -0400 Subject: [PATCH 26/28] Fixed CDI and Security test cases --- .../cdi/src/main/java/org/apache/cxf/cdi/CdiBusBean.java | 5 +++-- .../java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java | 5 +---- .../org/apache/cxf/cdi/JAXRSCdiResourceExtensionTest.java | 7 ++++++- .../security/oauth2/grants/code/JPACodeDataProvider.java | 6 ++++-- .../src/test/resources/META-INF/persistence.xml | 4 ++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/integration/cdi/src/main/java/org/apache/cxf/cdi/CdiBusBean.java b/integration/cdi/src/main/java/org/apache/cxf/cdi/CdiBusBean.java index 9e952167db7..a0705033e47 100644 --- a/integration/cdi/src/main/java/org/apache/cxf/cdi/CdiBusBean.java +++ b/integration/cdi/src/main/java/org/apache/cxf/cdi/CdiBusBean.java @@ -24,6 +24,7 @@ import jakarta.enterprise.context.spi.CreationalContext; import jakarta.enterprise.inject.spi.InjectionPoint; import jakarta.enterprise.inject.spi.InjectionTarget; +import jakarta.enterprise.inject.spi.InjectionTargetFactory; import org.apache.cxf.Bus; import org.apache.cxf.BusFactory; import org.apache.cxf.bus.extension.ExtensionManagerBus; @@ -35,8 +36,8 @@ final class CdiBusBean extends AbstractCXFBean< ExtensionManagerBus > { private final InjectionTarget injectionTarget; - CdiBusBean(final InjectionTarget injectionTarget) { - this.injectionTarget = injectionTarget; + CdiBusBean(final InjectionTargetFactory injectionTargetFactory) { + this.injectionTarget = injectionTargetFactory.createInjectionTarget(this); } @Override diff --git a/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java b/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java index ee6c81e7b9e..cc0bb96a1f5 100644 --- a/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java +++ b/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java @@ -43,7 +43,6 @@ import jakarta.enterprise.inject.spi.BeforeBeanDiscovery; import jakarta.enterprise.inject.spi.BeforeShutdown; import jakarta.enterprise.inject.spi.Extension; -import jakarta.enterprise.inject.spi.InjectionTarget; import jakarta.enterprise.inject.spi.ProcessAnnotatedType; import jakarta.enterprise.inject.spi.ProcessBean; import jakarta.enterprise.inject.spi.ProcessProducerField; @@ -268,9 +267,7 @@ public void injectBus(@Observes final AfterBeanDiscovery event, final BeanManage final AnnotatedType< ExtensionManagerBus > busAnnotatedType = beanManager.createAnnotatedType(ExtensionManagerBus.class); - final InjectionTarget busInjectionTarget = - beanManager.getInjectionTargetFactory(busAnnotatedType).createInjectionTarget(null); - event.addBean(new CdiBusBean(busInjectionTarget)); + event.addBean(new CdiBusBean(beanManager.getInjectionTargetFactory(busAnnotatedType))); } if (applicationBeans.isEmpty() && !serviceBeans.isEmpty()) { diff --git a/integration/cdi/src/test/java/org/apache/cxf/cdi/JAXRSCdiResourceExtensionTest.java b/integration/cdi/src/test/java/org/apache/cxf/cdi/JAXRSCdiResourceExtensionTest.java index f3a82d4332e..0a41024b88a 100644 --- a/integration/cdi/src/test/java/org/apache/cxf/cdi/JAXRSCdiResourceExtensionTest.java +++ b/integration/cdi/src/test/java/org/apache/cxf/cdi/JAXRSCdiResourceExtensionTest.java @@ -22,6 +22,7 @@ import jakarta.enterprise.inject.spi.Annotated; import jakarta.enterprise.inject.spi.Bean; import jakarta.enterprise.inject.spi.BeanManager; +import jakarta.enterprise.inject.spi.InjectionTargetFactory; import jakarta.enterprise.inject.spi.ProcessBean; import jakarta.ws.rs.Path; import org.apache.cxf.Bus; @@ -49,9 +50,12 @@ public class JAXRSCdiResourceExtensionTest { private ProcessBean processBean; @Mock private Annotated annotated; - + @Mock + private InjectionTargetFactory factory; + @Test public void shouldNotAddDefaultApplicationWhenNoResourcesDefined() { + when(beanManager.getInjectionTargetFactory(any())).thenReturn(factory); extension.injectBus(event, beanManager); verify(event).addBean(any(CdiBusBean.class)); @@ -80,6 +84,7 @@ public void shouldAddApplicationBeanWhenResourcesProvided() { when(annotated.isAnnotationPresent(Path.class)).thenReturn(true); extension.collect(processBean, beanManager); + when(beanManager.getInjectionTargetFactory(any())).thenReturn(factory); extension.injectBus(event, beanManager); verify(event).addBean(any(DefaultApplicationBean.class)); diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACodeDataProvider.java b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACodeDataProvider.java index d4847ed645e..082cacf2bbc 100644 --- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACodeDataProvider.java +++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACodeDataProvider.java @@ -96,9 +96,11 @@ public ServerAuthorizationCodeGrant removeCodeGrant(final String code) throws OA } private ServerAuthorizationCodeGrant removeCodeGrant(String code, EntityManager em) throws OAuthServiceException { - ServerAuthorizationCodeGrant grant = em.getReference(ServerAuthorizationCodeGrant.class, code); + ServerAuthorizationCodeGrant grant = em.find(ServerAuthorizationCodeGrant.class, code); try { - em.remove(grant); + if (grant != null) { + em.remove(grant); + } } catch (EntityNotFoundException e) { } return grant; diff --git a/systests/rs-security/src/test/resources/META-INF/persistence.xml b/systests/rs-security/src/test/resources/META-INF/persistence.xml index ddab4c47789..28ae22b7198 100644 --- a/systests/rs-security/src/test/resources/META-INF/persistence.xml +++ b/systests/rs-security/src/test/resources/META-INF/persistence.xml @@ -1,7 +1,7 @@ + xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd" + version="3.1"> org.hibernate.jpa.HibernatePersistenceProvider From 1f30514ae529483e08e22e9c27aa1468068ce279 Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Tue, 31 Oct 2023 22:36:49 -0400 Subject: [PATCH 27/28] Update Weld to 5.1.2.Final --- parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index 48ba9b1f5a8..e84a655674b 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -157,7 +157,7 @@ ${cxf.jaxb.runtime.version} 2.0.0 3.5.3.Final - 4.0.3.Final + 5.1.2.Final 5.13.1.Final 1.1.1 1.0 From d4fa37f681121f0ef6c9827bc1b76559ee5daed0 Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Wed, 1 Nov 2023 09:33:09 -0400 Subject: [PATCH 28/28] Switch JSON-P/JSON-B implementation and fix test cases --- .../pom.xml | 9 ++++++--- .../demo/jaxrs/openapi/server/AppConfig.java | 4 ++-- parent/pom.xml | 14 +++++++++++++- rt/rs/extensions/providers/pom.xml | 18 +++++------------- .../provider/jsrjsonb/JsrJsonbProvider.java | 3 ++- systests/jaxrs/pom.xml | 11 ++++------- 6 files changed, 32 insertions(+), 27 deletions(-) diff --git a/distribution/src/main/release/samples/jax_rs/description_openapi_microprofile_spring/pom.xml b/distribution/src/main/release/samples/jax_rs/description_openapi_microprofile_spring/pom.xml index d8be876c842..fb083d8f415 100644 --- a/distribution/src/main/release/samples/jax_rs/description_openapi_microprofile_spring/pom.xml +++ b/distribution/src/main/release/samples/jax_rs/description_openapi_microprofile_spring/pom.xml @@ -78,9 +78,12 @@ cxf-rt-rs-service-description-microprofile-openapi - org.apache.johnzon - johnzon-jsonb - jakarta + org.apache.cxf + cxf-rt-rs-extension-providers + + + org.eclipse + yasson org.springframework diff --git a/distribution/src/main/release/samples/jax_rs/description_openapi_microprofile_spring/src/main/java/demo/jaxrs/openapi/server/AppConfig.java b/distribution/src/main/release/samples/jax_rs/description_openapi_microprofile_spring/src/main/java/demo/jaxrs/openapi/server/AppConfig.java index 0d6c33a914c..0a5fb809541 100644 --- a/distribution/src/main/release/samples/jax_rs/description_openapi_microprofile_spring/src/main/java/demo/jaxrs/openapi/server/AppConfig.java +++ b/distribution/src/main/release/samples/jax_rs/description_openapi_microprofile_spring/src/main/java/demo/jaxrs/openapi/server/AppConfig.java @@ -4,7 +4,7 @@ import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; import org.apache.cxf.jaxrs.microprofile.openapi.OpenApiFeature; -import org.apache.johnzon.jaxrs.jsonb.jaxrs.JsonbJaxrsProvider; +import org.apache.cxf.jaxrs.provider.jsrjsonb.JsrJsonbProvider; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -29,7 +29,7 @@ org.apache.cxf.endpoint.Server server() { factory.setFeatures(Arrays.asList(openApiFeature())); factory.setServiceBean(sampleResource()); factory.setAddress("http://localhost:9000/"); - factory.setProvider(new JsonbJaxrsProvider<>()); + factory.setProvider(new JsrJsonbProvider()); return factory.create(); } } diff --git a/parent/pom.xml b/parent/pom.xml index e84a655674b..14f684129fe 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -182,7 +182,7 @@ 1.0.11 3.0.3 3.0.1 - 3.0 + 3.1.1 2.2.1 5.6.0 2022.7 @@ -196,6 +196,7 @@ 1.22.0-alpha 0.33.0 2.0.27 + 1.1.5 3.1.0 4.8.0 3.5.1 @@ -224,6 +225,7 @@ 10.1.14 1.8 2.3.5.Final + 3.0.3