Skip to content

Commit

Permalink
Jakartize & cleanup after 2.x merge
Browse files Browse the repository at this point in the history
Signed-off-by: jansupol <jan.supol@oracle.com>
  • Loading branch information
jansupol committed May 6, 2024
1 parent bf9e4d3 commit 95f63e4
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 19 deletions.
8 changes: 4 additions & 4 deletions docs/src/main/docbook/appendix-properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@
<entry>
<para>
If set to &lit.true; then XML root element tag name for collections will
be derived from <literal>javax.xml.bind.annotation.XmlRootElement</literal>
be derived from <literal>jakarta.xml.bind.annotation.XmlRootElement</literal>
annotation value and won't be de-capitalized.
</para>
<para>
Expand Down Expand Up @@ -1384,12 +1384,12 @@
<entry>
<para>
If &lit.true;, the &lit.jersey.client.HttpUrlConnector; (if used) will assume the content length
from the value of <literal>javax.ws.rs.core.HttpHeaders#CONTENT_LENGTH</literal> request
from the value of <literal>jakarta.ws.rs.core.HttpHeaders#CONTENT_LENGTH</literal> request
header (if present).
</para>
<para>
When this property is enabled and the request has a valid non-zero content length
value specified in its <literal>javax.ws.rs.core.HttpHeaders#CONTENT_LENGTH</literal> request
value specified in its <literal>jakarta.ws.rs.core.HttpHeaders#CONTENT_LENGTH</literal> request
header, that this value will be used as an input to the
<literal>java.net.HttpURLConnection#setFixedLengthStreamingMode(int)</literal> method call
invoked on the underlying <literal>java.net.HttpURLConnection</literal>.
Expand All @@ -1398,7 +1398,7 @@
</para>
<para>
Note that the content length value defined in the request header must exactly match
the real size of the entity. If the <literal>javax.ws.rs.core.HttpHeaders#CONTENT_LENGTH</literal>
the real size of the entity. If the <literal>jakarta.ws.rs.core.HttpHeaders#CONTENT_LENGTH</literal>
header is explicitly specified in a request, this property will be ignored and the
request entity will be still buffered by the underlying <literal>HttpURLConnection</literal> infrastructure.
</para>
Expand Down
12 changes: 6 additions & 6 deletions docs/src/main/docbook/custom-di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public class MyApplication extends ResourceConfig {
<para>
To make the <literal>HttpSession</literal> injection work without using HK2 API,
we will need to create a custom supplier that knows how to extract
&lit.jee6.servlet.HttpSession; out of given &lit.jee6.servlet.HttpServletRequest;.
&lit.jee9.servlet.HttpSession; out of given &lit.jee9.servlet.HttpServletRequest;.

<programlisting language="java">import java.util.function.Supplier
...
Expand All @@ -245,7 +245,7 @@ public class HttpSessionSupplier implements Supplier&lt;HttpSession&gt; {
}</programlisting>

Once implemented, the supplier can be used in a custom Jersey &jersey.common.internal.inject.AbstractBinder;
to define the new injection binding for &lit.jee6.servlet.HttpSession;. Finally, the implemented binder
to define the new injection binding for &lit.jee9.servlet.HttpSession;. Finally, the implemented binder
can be registered in your &jersey.server.ResourceConfig;:

<programlisting language="java">import org.glassfish.jersey.internal.inject.AbstractBinder;
Expand Down Expand Up @@ -435,9 +435,9 @@ public class MyApplication extends ResourceConfig {
</para>
<para>
The SessionInjectResolver then looks as follows:
<programlisting language="java">import javax.inject.Inject;
<programlisting language="java">import jakarta.inject.Inject;

import javax.servlet.http.HttpSession;
import jakarta.servlet.http.HttpSession;

import org.glassfish.jersey.internal.inject.InjectionResolver;

Expand Down Expand Up @@ -488,14 +488,14 @@ public class SessionInjectResolver implements InjectionResolver&lt;SessionInject
The &jersey.common.internal.inject.InjectionResolver; can be registered in the with Jersey application
&lit.jersey.server.ResourceConfig; as follows:

<programlisting language="java">import javax.ws.rs.core.Feature;
<programlisting language="java">import jakarta.ws.rs.core.Feature;

import org.glassfish.jersey.InjectionManagerProvider;
import org.glassfish.jersey.internal.inject.AbstractBinder;
import org.glassfish.jersey.internal.inject.InjectionManager;


import javax.inject.Singleton;
import jakarta.inject.Singleton;

...

Expand Down
44 changes: 37 additions & 7 deletions docs/src/main/docbook/dependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,50 @@
<title>Java SE Compatibility</title>

<para>
<emphasis>3.x branch: </emphasis>
<emphasis>3.0.x branch: </emphasis>
<itemizedlist>
<listitem>
<para>This user guide refers only to version 3 and above of Jersey, its compatibility is described below</para>
<para>This user guide refers only to version 3.0.x of Jersey, its compatibility is described below.</para>
</listitem>
<listitem>
<para>Since version 3.0.0* all Jersey components are compiled with Java SE 1.8 target.
It means, that you will need at least Java SE 1.8 to be able to compile and run your application
which uses the latest Jersey 3.x.
All modules however are fully compatible with JDK 11 and above. So, it's possible to use JDK 11+ to
build your app.
<para>Jersey 3.0.x components are compiled with Java SE 1.8 target.
It means, that you will need at least Java SE 1.8 to be able to compile and run your application
which uses the latest Jersey 3.0.x. All modules are also fully compatible with JDK 11 and above - depending on Jersey version.
</para>
</listitem>
</itemizedlist>
<table pgwide="1" frame='all' xml:id="jersey-jdk-compatibility">
<title>Jersey 3.0.x JDK compatibility</title>
<tgroup cols='3' align='center' colsep='1' rowsep='1'>
<colspec colname='c1'/>
<colspec colname='c2'/>
<colspec colname='c3'/>
<thead>
<row>
<entry>Jersey version</entry>
<entry>JDK min version</entry>
<entry>JDK max version</entry>
</row>
</thead>
<tbody>
<row><entry>3.0.0</entry><entry>1.8</entry><entry>16</entry></row>
<row><entry>3.0.1</entry><entry>1.8</entry><entry>16</entry></row>
<row><entry>3.0.2</entry><entry>1.8</entry><entry>17</entry></row>
<row><entry>3.0.3</entry><entry>1.8</entry><entry>18</entry></row>
<row><entry>3.0.4</entry><entry>1.8</entry><entry>18</entry></row>
<row><entry>3.0.5</entry><entry>1.8</entry><entry>19</entry></row>
<row><entry>3.0.6</entry><entry>1.8</entry><entry>19</entry></row>
<row><entry>3.0.7</entry><entry>1.8</entry><entry>19</entry></row>
<row><entry>3.0.8</entry><entry>1.8</entry><entry>19</entry></row>
<row><entry>3.0.9</entry><entry>1.8</entry><entry>20</entry></row>
<row><entry>3.0.10</entry><entry>1.8</entry><entry>20</entry></row>
<row><entry>3.0.11</entry><entry>1.8</entry><entry>21</entry></row>
<row><entry>3.0.12</entry><entry>1.8</entry><entry>22</entry></row>
<row><entry>3.0.13</entry><entry>1.8</entry><entry>23</entry></row>
<row><entry>3.0.14</entry><entry>1.8</entry><entry>23</entry></row>
</tbody>
</tgroup>
</table>
</para>
</section>
<section>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/docbook/jersey.ent
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<!ENTITY jaxrs.release.uri "https://github.com/eclipse-ee4j/jaxrs-api">
<!ENTITY jaxrs.javadoc.uri "https://jakartaee.github.io/rest/apidocs/&jax-rs.version;/jakarta/ws/rs">
<!ENTITY jaxrs21.javadoc.uri "https://jakartaee.github.io/rest/apidocs/&jax-rs21.version;/javax/ws/rs">
<!ENTITY jsonb.javadoc.uri "https://javaee.github.io/javaee-spec/javadocs/javax/json/bind">
<!ENTITY jsonb.javadoc.uri "https://jakarta.ee/specifications/jsonb/2.0/apidocs/jakarta/json/bind">
<!ENTITY jersey.documentation.uri "https://eclipse-ee4j.github.io/jersey.github.io">

<!ENTITY jersey.ext.bean-validation.deps.link "<link xlink:href='&jersey.project-info.uri.prefix;/jersey-bean-validation/dependencies.html'>jersey-bean-validation</link>" >
Expand Down
10 changes: 9 additions & 1 deletion docs/src/main/docbook/modules.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2013, 2024 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -484,6 +484,14 @@
</entry>
<entry>Jersey extension module providing support for Mustache templates.</entry>
</row>
<row>
<entry>
<link xlink:href="https://eclipse-ee4j.github.io/jersey.github.io/project-info/&version;/jersey/project/jersey-mvc-thymeleaf/dependencies.html">
jersey-mvc-thymeleaf
</link>
</entry>
<entry>Jersey extension module providing support for Thymeleaf templates.</entry>
</row>
<row>
<entry>
<link xlink:href="https://eclipse-ee4j.github.io/jersey.github.io/project-info/&version;/jersey/project/jersey-proxy-client/dependencies.html">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.jersey.server.spring.filter;

import org.glassfish.jersey.internal.inject.AbstractBinder;
import org.glassfish.jersey.internal.inject.InjectionManager;
import org.glassfish.jersey.internal.inject.Injections;
import org.glassfish.jersey.server.spring.scope.RequestContextFilter;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.WebApplicationContext;

import jakarta.ws.rs.container.ContainerRequestContext;
import jakarta.ws.rs.container.ContainerResponseContext;
import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class SpringRequestContextFilterTest {
@Test
public void testMissingAttributes() throws IOException {
WebApplicationContext webAppCtx = (WebApplicationContext) Proxy.newProxyInstance(
WebApplicationContext.class.getClassLoader(),
new Class[]{WebApplicationContext.class},
new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return null;
}
});

InjectionManager injectionManager = Injections.createInjectionManager();
injectionManager.register(new AbstractBinder() {
@Override
protected void configure() {
bind(webAppCtx).to(ApplicationContext.class);
}
});
injectionManager.completeRegistration();

ContainerRequestContext requestContext = (ContainerRequestContext) Proxy.newProxyInstance(
ContainerRequestContext.class.getClassLoader(),
new Class[]{ContainerRequestContext.class},
new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return null;
}
});

RequestContextFilter filter = new RequestContextFilter(injectionManager);
filter.filter(requestContext, (ContainerResponseContext) null);
}
}

0 comments on commit 95f63e4

Please sign in to comment.