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 Tue, Dec 15, 2020 at 1:55 AM Stuart Douglas <sdouglas@xxxxxxxxxx> wrote:
So the real issue here is that if you don't have self interception (i.e. if interceptors are implemented via proxies rather than subclassing) the doGet() method would not be intercepted? 

Yes, that's the main issue indeed.

It would be nice-to-have to only have to implement an interface and not inherit from an abstract class, but that's not the key problem really.

 
If that is the case then we could just add something to the spec that says that if the HttpServlet is a CDI bean and does not override the service() method then interception must be supported for these methods, and leave it
as an implementation detail as to how it is actually implemented. The easiest way would just be to install some kind of proxy Servlet, where each doX method delegates directly to the actual method on the underlying Servlet bean.

Indeed, that would get us there. A simple (reflective) check using getDeclaringClass() would easily give you back whether the service() method was overriden or not.

Thanks for this idea!

Kind regards,
Arjan


 

Stuart


Kind regards,
Arjan


 

Stuart

On Mon, 14 Dec 2020 at 11:30, arjan tijms <arjan.tijms@xxxxxxxxx> wrote:
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


 
_______________________________________________
servlet-dev mailing list
servlet-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/servlet-dev
_______________________________________________
servlet-dev mailing list
servlet-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/servlet-dev
_______________________________________________
servlet-dev mailing list
servlet-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/servlet-dev

Back to the top