Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [servlet-dev] Big ticket items for Servlet 6 / Jakarta EE 10?

Hi,

On Wed, Sep 2, 2020 at 3:21 AM Stuart Douglas <sdouglas@xxxxxxxxxx> wrote:

Wouldn't it make more sense to just allow traditional Servlet's to be CDI beans? We do this in Quarkus, which means that scopes, interceptors etc work as you would expect. In Quarkus you can just add @Transactional to a Servlet and it will just work.

Having thought about this on and off for the last 3 months, what about a single extra addition to allowing traditional Servlets to be CDI beans, and that's to make the methods in the base Servlet interface default methods?

That would allow us to have a Servlet just implementing that base interface, avoiding the service() method that calls the doGet etc methods directly, which could circumvent the interceptors.

That would give us:

@WebServlet("/foo/bar")
public class MyServlet implements Servlet {
        
    public void doGet(HttpServletRequest req, HttpServletResponse res) {
        // ...
    }

That would require no new API. Only a convention that the container calls the Java method with name ["do" + http method].

Thoughts?

Kind regards,
Arjan Tijms


 

Back to the top