pippo-java / pippo

Micro Java Web Framework
http://www.pippo.ro
Apache License 2.0
787 stars 128 forks source link

Upgrade to Jakarta EE #624

Open gkresic opened 1 year ago

gkresic commented 1 year ago

This is an extension to #490 (first half of it, anyway). Over there it was proposed to to upgrade to servlet 4 spec, but nothing is said on javax -> jakarta namespace migration that is part of spec 4.

So I propose migration in 2 steps:

  1. migrate to Servlet 4 spec, but keep javax.servlet namespace
  2. switch namespace to jakarta.servlet (this will imply switching implementations, but all currently supported implementations supports this in parallel releases: Jetty 10/11, Tomcat 9/10 and Undertow with io.undertow:undertow-servlet-jakartaee9 dependency

If Pippo doesn't have to support parallel versions for JavaEE and JakartaEE, then those two steps could be squashed into one and leave JavaEE compatibility behind.

Depends on #613

gkresic commented 1 year ago

I may submit a pull request for this one, but would like first to clarify the strategy for getting there among the two described above.

Since Pippo 1.x supports javax namespace, it's stable and can be used in legacy apps as is, my suggestion would be to go with Pippo 2.x straight to jakarta namespace.

decebals commented 1 year ago

my suggestion would be to go with Pippo 2.x straight to jakarta namespace

I agree.

gkresic commented 1 year ago

Working on it and I'm almost done, but have one question.

Due to the changes in the way Jetty handles WebSockets, I need an access to Jetty Server instance from within JettyWebSocketFilter.init

What would be the best was to access it from there? Provided FilterConfig does not hold any reference to Server.

gkresic commented 1 year ago

Here's my work so far:

https://github.com/gkresic/pippo/tree/jakarta

Notice hardcoded server access in ro.pippo.jetty.websocket.JettyWebSocketFilter: https://github.com/gkresic/pippo/blob/jakarta/pippo-server-parent/pippo-jetty/src/main/java/ro/pippo/jetty/websocket/JettyWebSocketFilter.java

Tests confirm that WebSocket endpoints are working.

Unrelated, notice that my initial assumptions about servlet versions were incorrect: servlet specs 4 and 5 are the same, only difference being javax/jakarta namespace difference. So this, when implemented will move Pippo to servlet version 5 spec. Version 6 will have to wait until Jetty 12 (currently in alpha) since it's the only server of three (Jetty/Tomcat/Undertow) that doesn't support v6.

decebals commented 1 year ago

@gkresic When you have something functional please create a PR fore review and comments. It's more easy to compare the impact of the changes using the diffs view.

gkresic commented 1 year ago

Created WIP PR #639