Skip to content

Commit a6e033c

Browse files
committed
[#1802] Switch pax-web-api from javax to jakarta
1 parent fea4948 commit a6e033c

25 files changed

+762
-261
lines changed

pax-web-api/pom.xml

+69-46
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@
8787
<executions>
8888
<execution>
8989
<!--
90-
copy javax/servlet/resources and javax/servlet/jsp/resources which will be
90+
copy jakarta/servlet/resources and jakarta/servlet/jsp/resources which will be
9191
available to slightly modified org.apache.tomcat.util.descriptor.DigesterFactory
9292
Originally Tomcat load these resources through java.lang.Class.getResource() method
93-
of javax.servlet.ServletContext and javax.servlet.jsp.JspContext classes
93+
of jakarta.servlet.ServletContext and jakarta.servlet.jsp.JspContext classes
9494
-->
9595
<id>copy-selected-resources</id>
9696
<phase>process-resources</phase>
@@ -101,14 +101,14 @@
101101
<outputDirectory>${project.build.outputDirectory}/META-INF/resources</outputDirectory>
102102
<resources>
103103
<resource>
104-
<directory>${project.build.directory}/unpack-deps/tomcat-servlet-api/javax/servlet/resources</directory>
104+
<directory>${project.build.directory}/unpack-deps/tomcat-servlet-api/jakarta/servlet/resources</directory>
105105
<includes>
106106
<include>*.xsd</include>
107107
<include>*.dtd</include>
108108
</includes>
109109
</resource>
110110
<resource>
111-
<directory>${project.build.directory}/unpack-deps/tomcat-jsp-api/javax/servlet/jsp/resources</directory>
111+
<directory>${project.build.directory}/unpack-deps/tomcat-jsp-api/jakarta/servlet/jsp/resources</directory>
112112
<includes>
113113
<include>*.xsd</include>
114114
<include>*.dtd</include>
@@ -126,18 +126,26 @@
126126
<configuration>
127127
<instructions>
128128
<Import-Package>
129-
<!-- ranges indicate Servlet API 3.1+ (JavaEE 7+) -->
130-
javax.servlet;version="[3.1,5)",
131-
javax.servlet.annotation;version="[3.1,5)",
132-
javax.servlet.http;version="[3.1,5)",
129+
<!-- ranges indicate Servlet API 6.0+ (JakartaEE 10+) -->
130+
jakarta.servlet;version="[6,7)",
131+
jakarta.servlet.annotation;version="[6,7)",
132+
jakarta.servlet.http;version="[6,7)",
133133

134-
<!-- ranges indicate we can work with OSGi Core R6+ -->
135-
org.osgi.dto;version="[1.0,2)",
136-
org.osgi.framework;version="[1.8,2)",
134+
<!-- OSGi Core R8+ -->
135+
org.osgi.dto;version="[1.1,2)",
136+
org.osgi.framework;version="[1.10,2)",
137137
org.osgi.framework.wiring;version="[1.2,2)",
138138

139+
<!-- OSGi CMPN R8.1 140 Jakarta Servlet packages (formerly known as Whiteboard) -->
140+
org.osgi.service.servlet.context;version="2.0.0",
141+
org.osgi.service.servlet.runtime;version="2.0.0",
142+
org.osgi.service.servlet.runtime.dto;version="2.0.0",
143+
org.osgi.service.servlet.whiteboard;version="2.0.0",
144+
org.osgi.service.servlet.whiteboard.annotations;version="2.0.0",
145+
org.osgi.service.servlet.whiteboard.propertytypes;version="2.0.0",
146+
139147
<!-- from pax-logging-api -->
140-
org.slf4j;version="[1.7,2)"
148+
org.slf4j;version="[2,3)"
141149
</Import-Package>
142150
<Export-Package>
143151
<!-- pax-web-api -->
@@ -146,18 +154,7 @@
146154
org.ops4j.pax.web.service.whiteboard;version="${pax-web.osgi.version}",
147155
org.ops4j.pax.web.utils;version="${pax-web.osgi.version}",
148156
<!-- Special export for org.keycloak:keycloak-osgi-adapter:18.0.x -->
149-
org.ops4j.pax.web.service;version="7.4",
150-
151-
<!-- re-export OSGi CMPN R7 102 HTTP Service packages -->
152-
org.osgi.service.http;version="1.2.1",
153-
154-
<!-- re-export OSGi CMPN R7 140 HTTP Whiteboard packages -->
155-
org.osgi.service.http.context;version="1.1",
156-
org.osgi.service.http.runtime;version="1.1",
157-
org.osgi.service.http.runtime.dto;version="1.1",
158-
org.osgi.service.http.whiteboard;version="1.1",
159-
org.osgi.service.http.whiteboard.annotations;version="1.1",
160-
org.osgi.service.http.whiteboard.propertytypes;version="1.1"
157+
<!-- org.ops4j.pax.web.service;version="7.4",-->
161158
</Export-Package>
162159
<Include-Resource>
163160
{maven-resources},
@@ -216,8 +213,23 @@
216213
<artifactId>osgi.core</artifactId>
217214
<scope>provided</scope>
218215
</dependency>
216+
<dependency>
217+
<groupId>org.osgi</groupId>
218+
<artifactId>org.osgi.namespace.extender</artifactId>
219+
<scope>provided</scope>
220+
</dependency>
221+
<dependency>
222+
<groupId>org.osgi</groupId>
223+
<artifactId>org.osgi.service.http</artifactId>
224+
<scope>provided</scope>
225+
</dependency>
226+
<dependency>
227+
<groupId>org.osgi</groupId>
228+
<artifactId>org.osgi.service.servlet</artifactId>
229+
<scope>provided</scope>
230+
</dependency>
219231

220-
<!-- JavaEE -->
232+
<!-- JakartaEE -->
221233

222234
<dependency>
223235
<groupId>jakarta.servlet</groupId>
@@ -234,38 +246,49 @@
234246
</dependency>
235247
<dependency>
236248
<groupId>org.apache.logging.log4j</groupId>
237-
<artifactId>log4j-slf4j-impl</artifactId>
249+
<artifactId>log4j-slf4j2-impl</artifactId>
238250
<scope>test</scope>
239251
</dependency>
240252

241253
<!-- Tomcat -->
242254

243-
<!-- <dependency>-->
244-
<!-- &lt;!&ndash;-->
245-
<!-- This dependency is used to take javax.servlet.resources package with XSDs/DTDs into pax-web-tomcat-common-->
246-
<!-- to satisfy the DigesterFactory-->
247-
<!-- &ndash;&gt;-->
248-
<!-- <groupId>org.apache.tomcat</groupId>-->
249-
<!-- <artifactId>tomcat-servlet-api</artifactId>-->
250-
<!-- <scope>provided</scope>-->
251-
<!-- </dependency>-->
252-
<!-- <dependency>-->
253-
<!-- &lt;!&ndash;-->
254-
<!-- This dependency is used to take javax.servlet.jsp.resources package with XSDs/DTDs into pax-web-tomcat-common-->
255-
<!-- to satisfy the DigesterFactory-->
256-
<!-- &ndash;&gt;-->
257-
<!-- <groupId>org.apache.tomcat</groupId>-->
258-
<!-- <artifactId>tomcat-jsp-api</artifactId>-->
259-
<!-- <scope>provided</scope>-->
260-
<!-- </dependency>-->
255+
<dependency>
256+
<!--
257+
This dependency is used to take jakarta.servlet.resources package with XSDs/DTDs into pax-web-api
258+
to satisfy the DigesterFactory
259+
-->
260+
<groupId>org.apache.tomcat</groupId>
261+
<artifactId>tomcat-servlet-api</artifactId>
262+
<scope>provided</scope>
263+
</dependency>
264+
<dependency>
265+
<!--
266+
This dependency is used to take jakarta.servlet.jsp.resources package with XSDs/DTDs into pax-web-api
267+
to satisfy the DigesterFactory
268+
-->
269+
<groupId>org.apache.tomcat</groupId>
270+
<artifactId>tomcat-jsp-api</artifactId>
271+
<scope>provided</scope>
272+
</dependency>
261273

262274
<!-- Testing -->
263275

276+
277+
<dependency>
278+
<groupId>org.junit.jupiter</groupId>
279+
<artifactId>junit-jupiter-api</artifactId>
280+
<scope>test</scope>
281+
</dependency>
264282
<dependency>
265-
<groupId>junit</groupId>
266-
<artifactId>junit</artifactId>
283+
<groupId>org.junit.jupiter</groupId>
284+
<artifactId>junit-jupiter-engine</artifactId>
267285
<scope>test</scope>
268286
</dependency>
287+
<dependency>
288+
<groupId>org.assertj</groupId>
289+
<artifactId>assertj-core</artifactId>
290+
<version>${dependency.org.assertj}</version>
291+
</dependency>
269292
<dependency>
270293
<groupId>org.springframework</groupId>
271294
<artifactId>spring-core</artifactId>

pax-web-api/readme.adoc

+21-21
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
This bundle has these purposes:
44

55
* re-export packages specified in OSGi CMPN R7 102 "Http Service Specification"
6-
** `org.osgi.service.http` 1.2
6+
** `org.osgi.service.servlet` 1.2
77
* re-export packages specified in OSGi CMPN R7 140 "Http Whiteboard Specification"
8-
** `org.osgi.service.http.context` 1.1
9-
** `org.osgi.service.http.runtime` 1.1
10-
** `org.osgi.service.http.runtime.dto` 1.1
11-
** `org.osgi.service.http.whiteboard` 1.1
12-
** `org.osgi.service.http.whiteboard.annotations` 1.1
13-
** `org.osgi.service.http.whiteboard.propertytypes` 1.1
8+
** `org.osgi.service.servlet.context` 1.1
9+
** `org.osgi.service.servlet.runtime` 1.1
10+
** `org.osgi.service.servlet.runtime.dto` 1.1
11+
** `org.osgi.service.servlet.whiteboard` 1.1
12+
** `org.osgi.service.servlet.whiteboard.annotations` 1.1
13+
** `org.osgi.service.servlet.whiteboard.propertytypes` 1.1
1414
* provide additional interfaces (like `org.ops4j.pax.web.service.WebContainer`) extending standard specification
1515
* provide some utilities used throughout PAX WEB (`org.ops4j.pax.web.utils` package)
1616
@@ -295,19 +295,19 @@ Since OSGi CMPN R6, Http Whiteboard is an official specification and Pax Web (wh
295295

296296
CMPN R7 Http Whiteboard Specification allows registration (as OSGi services) of the following services:
297297

298-
* 140.4 Registering Servlets: `javax.servlet.Servlet` services
298+
* 140.4 Registering Servlets: `jakarta.servlet.Servlet` services
299299
* 140.5 Registering Servlet Filters:
300-
** `javax.servlet.Filter` services
301-
** `org.osgi.service.http.whiteboard.Preprocessor` services handled before security processing
300+
** `jakarta.servlet.Filter` services
301+
** `org.osgi.service.servlet.whiteboard.Preprocessor` services handled before security processing
302302
* 140.6 Registering Resources: any objects with `osgi.http.whiteboard.resource.pattern` and `osgi.http.whiteboard.resource.prefix` service properties. Actual service is irrelevant
303303
* 140.7 Registering Listeners: services with these subinterfaces of `java.util.EventListener`:
304-
** `javax.servlet.ServletContextListener`
305-
** `javax.servlet.ServletContextAttributeListener`
306-
** `javax.servlet.ServletRequestListener`
307-
** `javax.servlet.ServletRequestAttributeListener`
308-
** `javax.servlet.http.HttpSessionListener`
309-
** `javax.servlet.http.HttpSessionAttributeListener`
310-
** `javax.servlet.http.HttpSessionIdListener`
304+
** `jakarta.servlet.ServletContextListener`
305+
** `jakarta.servlet.ServletContextAttributeListener`
306+
** `jakarta.servlet.ServletRequestListener`
307+
** `jakarta.servlet.ServletRequestAttributeListener`
308+
** `jakarta.servlet.http.HttpSessionListener`
309+
** `jakarta.servlet.http.HttpSessionAttributeListener`
310+
** `jakarta.servlet.http.HttpSessionIdListener`
311311

312312
When registering the above servives, all additional and required information should be specified as OSGi service properties and/or Java annotations on the services. Annotations where specified only in R7 Whiteboard specification. Version R6 specified only service registration properties.
313313

@@ -319,11 +319,11 @@ This may be called _explicit whiteboard approach_ (where registration parameters
319319

320320
=== Context
321321

322-
Java Servlet API specification defines `javax.servlet.ServletContext` interface which roughly means a distinguished namespace (with _context path_) where servlets, filters and other _web elements_ may be specified.
322+
Java Servlet API specification defines `jakarta.servlet.ServletContext` interface which roughly means a distinguished namespace (with _context path_) where servlets, filters and other _web elements_ may be specified.
323323

324-
OSGi CMPN Http Service specification defines `org.osgi.service.http.HttpContext` interface that should _influence_ the `javax.servlet.ServletContext` associated with the servlets (and resources) being registered.
324+
OSGi CMPN Http Service specification defines `org.ops4j.pax.web.service.http.HttpContext` interface that should _influence_ the `jakarta.servlet.ServletContext` associated with the servlets (and resources) being registered.
325325

326-
OSGi CMPN Whiteboard specification defines `org.osgi.service.http.context.ServletContextHelper` interface that plays the same role as the above `HttpContext`, but which is dedicated for Whiteboard specification.
326+
OSGi CMPN Whiteboard specification defines `org.osgi.service.servlet.context.ServletContextHelper` interface that plays the same role as the above `HttpContext`, but which is dedicated for Whiteboard specification.
327327
This `ServletContextHelper` is explicitly associated with _context path_ (using `osgi.http.whiteboard.context.path` service registration property) - unlike `HttpContext` which doesn't have a _context path_.
328328

329329
OSGi CMPN HTTP Service specification (102.2 Registering servlets) mentions:
@@ -333,7 +333,7 @@ OSGi CMPN HTTP Service specification (102.2 Registering servlets) mentions:
333333
[...]. Thus, Servlet objects registered with the same HttpContext object must also share the same ServletContext object.
334334
----
335335

336-
Without actually specifying what _the same_ means. `felix.http` implements `org.osgi.service.http.HttpService.createDefaultHttpContext()` by returning _new_ instance of `org.apache.felix.http.base.internal.service.DefaultHttpContext` on each call...
336+
Without actually specifying what _the same_ means. `felix.http` implements `org.ops4j.pax.web.service.http.HttpService.createDefaultHttpContext()` by returning _new_ instance of `org.apache.felix.http.base.internal.service.DefaultHttpContext` on each call...
337337

338338
OSGi CMPN Whiteboard specification (140.10 Integration with Http Service contexts) says:
339339

pax-web-api/src/main/java/org/ops4j/pax/web/service/PaxWebConfig.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import java.security.cert.CertStoreParameters;
1919
import javax.net.ssl.SSLContext;
20-
import javax.servlet.ServletContext;
20+
import jakarta.servlet.ServletContext;
2121

2222
/**
2323
* <p>Dedicated interface with constants related to configuration. Other constants reside
@@ -65,28 +65,28 @@ public interface PaxWebConfig {
6565
* This property specifies the port used for servlets and resources accessible via HTTP.
6666
* The default value for this property is {@code 80} according to specification, but we'll use {@code 8080}.
6767
*/
68-
String PID_CFG_HTTP_PORT = "org.osgi.service.http.port";
68+
String PID_CFG_HTTP_PORT = "org.osgi.service.servlet.port";
6969

7070
/**
7171
* This property specifies the port used for servlets and resources accessible via HTTPS.
7272
* The default value for this property is {@code 443} according to specificaton, but we'll use {@code 8443}.
7373
*/
74-
String PID_CFG_HTTP_PORT_SECURE = "org.osgi.service.http.port.secure";
74+
String PID_CFG_HTTP_PORT_SECURE = "org.osgi.service.servlet.port.secure";
7575

7676
/** Should the default non-secure port be enabled? */
77-
String PID_CFG_HTTP_ENABLED = "org.osgi.service.http.enabled";
77+
String PID_CFG_HTTP_ENABLED = "org.osgi.service.servlet.enabled";
7878

7979
/** Should the default secure port be enabled? */
80-
String PID_CFG_HTTP_SECURE_ENABLED = "org.osgi.service.http.secure.enabled";
80+
String PID_CFG_HTTP_SECURE_ENABLED = "org.osgi.service.servlet.secure.enabled";
8181

8282
/** Comma-separated list of addresses to bind listeners/connectors to. Defaults to {@code 0.0.0.0} */
8383
String PID_CFG_LISTENING_ADDRESSES = "org.ops4j.pax.web.listening.addresses";
8484

8585
/** Name to use as <em>default</em> (non-secure) connector, defaults to {@code default}. */
86-
String PID_CFG_HTTP_CONNECTOR_NAME = "org.osgi.service.http.connector.name";
86+
String PID_CFG_HTTP_CONNECTOR_NAME = "org.osgi.service.servlet.connector.name";
8787

8888
/** Name to use as <em>secure</em> connector, defaults to {@code secureDefault}. */
89-
String PID_CFG_HTTP_SECURE_CONNECTOR_NAME = "org.osgi.service.http.secure.connector.name";
89+
String PID_CFG_HTTP_SECURE_CONNECTOR_NAME = "org.osgi.service.servlet.secure.connector.name";
9090

9191
/**
9292
* Jetty: {@code org.eclipse.jetty.server.AbstractConnector#setIdleTimeout(long)}
@@ -119,7 +119,7 @@ public interface PaxWebConfig {
119119
/**
120120
* Jetty: adds {@code org.eclipse.jetty.server.ForwardedRequestCustomizer} to {@code HttpConfiguration}
121121
*/
122-
String PID_CFG_HTTP_CHECK_FORWARDED_HEADERS = "org.osgi.service.http.checkForwardedHeaders";
122+
String PID_CFG_HTTP_CHECK_FORWARDED_HEADERS = "org.osgi.service.servlet.checkForwardedHeaders";
123123

124124
/**
125125
* Comma-separated list of virtual hosts to set on <em>every deployed context</em> if the context itself
@@ -162,7 +162,7 @@ public interface PaxWebConfig {
162162
String BUNDLE_CONTEXT_PROPERTY_WAR_EXTENDER_JARS_TO_SCAN = "org.ops4j.pax.web.extender.war.jarsToScan";
163163

164164
/**
165-
* <p>Defines the type of TCCL that should be set for service methods (like {@link javax.servlet.Servlet#service}).
165+
* <p>Defines the type of TCCL that should be set for service methods (like {@link jakarta.servlet.Servlet#service}).
166166
* It can take two values:<ul>
167167
* <li>{@code servlet} (the default, assumed value) - {@link ServletContext#getClassLoader()} returns
168168
* only the bundle's class loader for given servlet/filter, but TCCL is set to servlet context's classloader</li>

0 commit comments

Comments
 (0)