Objectify variant for Jakarta EE 9/10

61 views
Skip to first unread message

healthy-interac

unread,
Sep 7, 2023, 8:28:30 PM9/7/23
to objectify-appengine
Hi Jeff,

Are there any plans to create Objectify variant compatible with Jakarta EE 9/10?
Essentially we need Objectify to replace javax dependencies with corresponding jakarta ones to be able to migrate from SpringBoot 2.7.x to 3.0.x.


Thanks!
Dmitry

Jeff Schnitzer

unread,
Sep 7, 2023, 9:22:21 PM9/7/23
to objectify...@googlegroups.com
Objectify doesn't use the javax annotations (at least, as far as I can remember). I guess there's the ObjectifyFilter, but you could replace that with your own version? ObjectifyFilter is pretty close to a one-liner, take a look at the source.

I'm honestly not sure when the right time is to replace the HttpServlet interface of ObjectifyFilter. Seems like I'm going to get complaints from someone no matter what.

I guess I could add an ObjectifyFilter2? I wonder what kind of trouble will we get in if both the new interfaces and the old interfaces are on the build path?

Jeff

--
You received this message because you are subscribed to the Google Groups "objectify-appengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectify-appen...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/objectify-appengine/1d669b10-9e3e-47c3-a562-b56079f56e27n%40googlegroups.com.

healthy-interac

unread,
Sep 8, 2023, 2:04:32 PM9/8/23
to objectify-appengine
Thanks for the tip Jeff! I definitely can replace ObjectifyFilter with my own implementation, just replacing servlet-api references from javax with corresponding ones from jakarta.

To your question: it's worth trying if jakarta-based ObjectifyFilter2 will cause any troubles being on the same build path with javax-based one. They'll be differentiated by the namespase, so calling application will import either one or another (although it will still be confusing and error-prone). I think moving to a new EE 9/10 based version of Objectify is your safest bet.

Cheers,
Dmitry

Tony Park

unread,
Sep 23, 2023, 6:20:01 PM9/23/23
to objectify-appengine
I'm also migrating to Spring Boot 3. This worked for me:

import com.googlecode.objectify.ObjectifyService;
import com.googlecode.objectify.util.Closeable;
import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;

import java.io.IOException;

@WebFilter(urlPatterns = {"/*" })
public class ObjectifyWebFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        Filter.super.init(filterConfig);
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        // Per Jeff's suggestion, this is from ObjectifyFilter
        try (Closeable closeable = ObjectifyService.begin()) {
            chain.doFilter(request, response);
        }
    }

    @Override
    public void destroy() {
        Filter.super.destroy();
    }
}

Reply all
Reply to author
Forward
0 new messages