Hi Arjan,
Further to our discussion on the platform call, I don't think making Servlet CDI Bean has much usage as I have not got any use case to say that you need to inject Servlet to another class. Please specify your use case if you have any.
The benefit of making Servlets a CDI bean is to have a more consistent platform without so many special cases.
Specifically, CDI beans automatically support a number of things, like obviously injection, but also interceptors, scopes, decorators, ability to be vetoed, and to programmatically enhance them in extensions with all those things.
It's a good point to raise that Servlets (within Jakarta EE) actually should support Interceptors, though I wonder if we have a TCK test for that anywhere?
Obviously when something is a CDI bean, you would not need to test that explicitly, as it comes automatically with being a CDI bean. In order to intercept the typical doGet() etc methods well, we would need to specify something additionally in a potential EE chapter of the Servlet spec. doGet() etc is now called by the Servlet Container's base class for Servlets directly, so it would never be intercepted. This would lead to surprises among users.
So to reiterate, very practical advantages of just being a true CDI bean are being able to give a Servlet a (custom) scope, decorators, ability to be vetoed and to programmatically add those things.
Kind regards,
Arjan Tijms
Based on the
Jakarta EE platform spec, Servlet is a special Jakarta EE class and it supports the standard injection and interceptor. Your requirement for injection and interceptor support should be met though.
Thanks
Emily
Hi,
This was discussed a while ago, but in the context of the CDI-centric Jakarta EE release it might be good to restart this discussion.
The overall goal of the Jakarta EE platform is to move the various spec specific component models and mechanisms to CDI (as per the "CDI-centric" theme).
Servlets have been @Inject injectable (loosely via the pruned Managed Beans spec, although the Servlet spec itself did not say so), but are themselves not CDI beans.
I'd like to propose to make Servlets officially CDI beans, but only within a Jakarta EE environment.
Meaning, Tomcat and Jetty would have no requirement to support this, and these requirements would be in a separate chapter of the Servlet spec.
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