Skip to content

Commit

Permalink
[#1802] Switch pax-web-spi from javax to jakarta
Browse files Browse the repository at this point in the history
  • Loading branch information
grgrzybek committed Jun 12, 2023
1 parent a6e033c commit c431380
Show file tree
Hide file tree
Showing 80 changed files with 596 additions and 663 deletions.
62 changes: 40 additions & 22 deletions pax-web-spi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
Expand All @@ -58,6 +59,7 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
Expand Down Expand Up @@ -86,31 +88,31 @@
<configuration>
<instructions>
<Import-Package>
<!-- ranges indicate Servlet API 3.1+ (JavaEE 7+) -->
javax.servlet;version="[3.1,5)",
javax.servlet.annotation;version="[3.1,5)",
javax.servlet.descriptor;version="[3.1,5)",
javax.servlet.http;version="[3.1,5)",

javax.websocket;version="[1.1,2)";resolution:=optional,
javax.websocket.server;version="[1.1,2)";resolution:=optional,

<!-- ranges indicate we can work with OSGi Core R6+ -->
org.osgi.dto;version="[1.0,2)",
org.osgi.framework;version="[1.8,2)",
org.osgi.framework.dto;version="[1.0,2)",
<!-- ranges indicate Servlet API 6.0+ (JakartaEE 10+) -->
jakarta.servlet;version="[6,7)",
jakarta.servlet.annotation;version="[6,7)",
jakarta.servlet.descriptor;version="[6,7)",
jakarta.servlet.http;version="[6,7)",

jakarta.websocket;version="[2.1,3)";resolution:=optional,
jakarta.websocket.server;version="[2.1,3)";resolution:=optional,

<!-- OSGi Core R8+ -->
org.osgi.dto;version="[1.1,2)",
org.osgi.framework;version="[1.10,2)",
org.osgi.framework.dto;version="[1.8,2)",
org.osgi.framework.wiring;version="[1.2,2)",
org.osgi.util.tracker;version="[1.5,2)",

<!-- OSGi cmpn -->
org.osgi.service.http;version="[1.2,2)",
org.osgi.service.http.context;version="[1.1,2)",
org.osgi.service.http.whiteboard;version="[1.1,2)",
org.osgi.service.http.runtime;version="[1.1,2)",
org.osgi.service.http.runtime.dto;version="[1.1,2)",
org.osgi.service.servlet.context;version="[1.1,2)",
org.osgi.service.servlet.whiteboard;version="[1.1,2)",
org.osgi.service.servlet.runtime;version="[1.1,2)",
org.osgi.service.servlet.runtime.dto;version="[1.1,2)",

<!-- from pax-web-api -->
org.ops4j.pax.web.service;version="${pax-web.osgi.version}",
org.ops4j.pax.web.service.http;version="${pax-web.osgi.version}",
org.ops4j.pax.web.service.views;version="${pax-web.osgi.version}",
org.ops4j.pax.web.utils;version="${pax-web.osgi.version}",

Expand Down Expand Up @@ -168,13 +170,18 @@
<artifactId>osgi.core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.servlet</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.utils</artifactId>
</dependency>

<!-- JavaEE -->
<!-- JakartaEE -->

<dependency>
<groupId>jakarta.servlet</groupId>
Expand All @@ -187,6 +194,12 @@
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>jakarta.websocket</groupId>
<artifactId>jakarta.websocket-client-api</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>

<!-- Logging -->

Expand All @@ -197,7 +210,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<artifactId>log4j-slf4j2-impl</artifactId>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -227,8 +240,13 @@
<!-- Testing -->

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.ops4j.pax.web.service.spi;

import java.net.URL;
import javax.servlet.Servlet;
import jakarta.servlet.Servlet;

import org.ops4j.pax.web.service.spi.config.Configuration;
import org.ops4j.pax.web.service.spi.model.events.ServerListener;
Expand Down Expand Up @@ -103,16 +103,16 @@ public interface ServerController {
* directory</li>
* <li>{@code base} - if the "base" is not an absolute file: directory URL, this parameter will be treated
* as prefix for the resource access as defined in Http/Whiteboard Service specifications (access via
* {@link org.osgi.service.http.HttpContext#getResource(String)} or
* {@link org.osgi.service.http.context.ServletContextHelper#getResource(String)}.</li>
* {@link org.ops4j.pax.web.service.http.HttpContext#getResource(String)} or
* {@link org.osgi.service.servlet.context.ServletContextHelper#getResource(String)}.</li>
* </ul>
*
* @param urlBase if the "base" is found to be proper, accessible {@code file:} based directory, it is passed
* to this creation method and {@code base} can be safely ignored
* @param base According to HttpService and Whiteboard specifications, this is the <em>base</em> location for
* resource fetching. By default this <em>base</em> is prepended to a path and (combined) used as argument
* to {@link org.osgi.service.http.HttpContext#getResource(String)} or
* {@link org.osgi.service.http.context.ServletContextHelper#getResource(String)}. It should not end with
* to {@link org.ops4j.pax.web.service.http.HttpContext#getResource(String)} or
* {@link org.osgi.service.servlet.context.ServletContextHelper#getResource(String)}. It should not end with
* slash ({@code /}) and can be an empty string (meaning root of the bundle).
* @return
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @author Hiram Chirino
*/
@Review("Extend and integrate with org.osgi.service.http.runtime.HttpServiceRuntime for Karaf commands/services"
@Review("Extend and integrate with org.osgi.service.servlet.runtime.HttpServiceRuntime for Karaf commands/services"
+ " like org.apache.karaf.web.WebContainerService and org.apache.karaf.http.core.ServletService")
public interface WarManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public interface ServerConfiguration {

/**
* Returns the temporary directory, directory that will be set as {@link javax.servlet.ServletContext#TEMPDIR}.
* Returns the temporary directory, directory that will be set as {@link jakarta.servlet.ServletContext#TEMPDIR}.
*
* @return the temporary directory
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
package org.ops4j.pax.web.service.spi.config;

import java.io.File;
import javax.servlet.SessionCookieConfig;
import jakarta.servlet.SessionCookieConfig;

/**
* <p>While some session configuration parameters (those specified in {@code web.xml} and
* {@link javax.servlet.SessionCookieConfig}) can be specified through {@link org.ops4j.pax.web.service.WebContainer}
* {@link jakarta.servlet.SessionCookieConfig}) can be specified through {@link org.ops4j.pax.web.service.WebContainer}
* and during WAR deployment, some server-specific options can be configured only globally through
* {@link org.ops4j.pax.web.service.PaxWebConstants#PID}.</p>
*
* <p>Global (this) configuration is also used when no context-specific session configuration is defined.</p>
*/
public interface SessionConfiguration {

// --- configuration that matches web.xml and javax.servlet.SessionCookieConfig
// --- configuration that matches web.xml and jakarta.servlet.SessionCookieConfig

/**
* {@code <session-config>/<session-timeout>} - returns the time in minutes after which an inative settion times out.
Expand Down Expand Up @@ -85,7 +85,7 @@ public interface SessionConfiguration {
*/
String getSessionCookieSameSite();

// --- configuration that's not related to web.xml or javax.servlet.SessionCookieConfig
// --- configuration that's not related to web.xml or jakarta.servlet.SessionCookieConfig

/**
* Allows configuration of Jetty's SessionHandler.SessionIdPathParameterName. By default it's {@code jsessionid}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Set;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.ops4j.pax.web.service.PaxWebConstants;
import org.ops4j.pax.web.service.WebContainerContext;
import org.ops4j.pax.web.service.spi.util.Path;
import org.osgi.framework.Bundle;
import org.osgi.service.http.HttpContext;
import org.osgi.service.http.HttpService;
import org.ops4j.pax.web.service.http.HttpContext;
import org.ops4j.pax.web.service.http.HttpService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -172,7 +172,7 @@ public int hashCode() {
* @return
*/
protected URL getResource(Bundle bundle, String name) {
// "name" is passed from javax.servlet.ServletContext.getResource() which always should start with a slash
// "name" is passed from jakarta.servlet.ServletContext.getResource() which always should start with a slash
final String normalizedName = Path.normalizeResourcePath(name);
LOG.trace("Searching bundle [" + bundle + "] for resource [" + normalizedName + "]");
return bundle.getResource(normalizedName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.ops4j.pax.web.service.MultiBundleWebContainerContext;
import org.osgi.framework.Bundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import java.io.IOException;
import java.net.URL;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.osgi.framework.Bundle;
import org.osgi.service.http.context.ServletContextHelper;
import org.osgi.service.servlet.context.ServletContextHelper;

/**
* Default {@link ServletContextHelper} as specified in "140.2 The Servlet Context". Actually there's no need
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import java.io.IOException;
import java.net.URL;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.ops4j.pax.web.service.WebContainerContext;
import org.osgi.framework.Bundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
import java.io.IOException;
import java.net.URL;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.ops4j.pax.web.service.WebContainerContext;
import org.osgi.framework.Bundle;
import org.osgi.service.http.HttpContext;
import org.osgi.service.http.context.ServletContextHelper;
import org.ops4j.pax.web.service.http.HttpContext;
import org.osgi.service.servlet.context.ServletContextHelper;

/**
* A simple wrapper to enclose custom {@link HttpContext http contexts} (which gets registered directly to the
* {@link org.osgi.service.http.HttpService}) or {@link ServletContextHelper} (registered via Whiteboard service)
* {@link org.ops4j.pax.web.service.http.HttpService}) or {@link ServletContextHelper} (registered via Whiteboard service)
* in an implementation of {@link org.ops4j.pax.web.service.WebContainerContext}.
*/
public class WebContainerContextWrapper extends DefaultHttpContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

/**
* <p>This package provides various implementations of {@link org.osgi.service.http.HttpContext} and
* <p>This package provides various implementations of {@link org.ops4j.pax.web.service.http.HttpContext} and
* {@link org.ops4j.pax.web.service.WebContainerContext} to be used in:<ul>
* <li>Http Service implementation in pax-web-runtime bundle</li>
* <li>Whiteboard Service implementation in pax-web-extender-whiteboard bundle</li>
Expand All @@ -24,7 +24,7 @@
* <p><em>Unique</em> implementations are wrappers for existing instances of
* {@link org.ops4j.pax.web.service.WebContainerContext} and
* {@link org.ops4j.pax.web.service.MultiBundleWebContainerContext} because Http Service specification says
* that {@link org.osgi.service.http.HttpService#createDefaultHttpContext()} returns new instance on each call,
* that {@link org.ops4j.pax.web.service.http.HttpService#createDefaultHttpContext()} returns new instance on each call,
* however we don't want these new instances to refer to different internal representations of the <em>contexts</em>.
* </p>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.ops4j.pax.web.service.WebContainerContext;
import org.ops4j.pax.web.service.spi.context.WebContainerContextWrapper;
import org.osgi.framework.Bundle;
import org.osgi.service.http.HttpContext;
import org.ops4j.pax.web.service.http.HttpContext;

public class ContextKey {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package org.ops4j.pax.web.service.spi.model;

import javax.servlet.ServletException;
import jakarta.servlet.ServletException;

import org.osgi.service.http.NamespaceException;
import org.ops4j.pax.web.service.http.NamespaceException;

/**
* Special {@link RuntimeException} to handle checked exceptions thrown from {@link ModelRegistrationTask}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package org.ops4j.pax.web.service.spi.model;

import javax.servlet.ServletException;
import jakarta.servlet.ServletException;

import org.osgi.service.http.NamespaceException;
import org.ops4j.pax.web.service.http.NamespaceException;

/**
* A task that can be passed to {@link ServerModel#run(ModelRegistrationTask)} to ensure running it in
Expand Down
Loading

0 comments on commit c431380

Please sign in to comment.