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?



On Wed, 16 Dec 2020 at 00:10, Stuart Douglas <sdouglas@xxxxxxxxxx> wrote:
On Wed, 16 Dec 2020 at 03:33, Greg Wilkins <gregw@xxxxxxxxxxx> wrote:

With regard to CDI scopes and servlets,  I think it would be a really REALLY bad idea to try and support scopes for servlets and filters.
A request scoped servlet would essentially be much the same as a javax.servlet.SingleThreadModel servlet - which was a bad idea then and is still a bad idea now.  It added needless complexity to the container whose cost was/is paid by all users regardless when most do not use SingleThreadModel.
I fear that trying to get similar support for CDI built into the core container will have similar no-taxation-without-representation issues.

It should not add any complexity, other than delegating to CDI to create the Servlet. If the Underlying object is RequestScoped then the Servlet container does not have to do any additional work, it just forwards requests to the proxy it has been handed and the CDI container takes care of the details

I think we are on the same page then.  I was fearful that the suggestion was that for scoped requests, the servlet container would need to run the full Servlet lifecycle of init & destroy via CDI, which would add extra complexity to the container.   But if it is just that CDI gives the container a single servlet instance that is initialized/used normally for the full context lifecycle and that it delegates internally to dynamically created instances - then that is fine.

So does CDI need any other facilities from the servlet container, other than to plug into the initial component creation and/or decoration?


That said, there is no way we will be recommending different scopes for Servlets, the real value here in addition to injection is that you get interceptor support, so you can just add @Transactional to your servlet and it will work as you expect. Scope support is basically a by-product of this, and not something that is particularly interesting IMHO.

Can interceptor support be added by a CDI provided proxy servlet?   

 
The Servlet container does not need to do anything, just call the service method on the Servlet the CDI container has provided. Basically as long as you have a way to delegate creation of the Servlet to CDI then this is all that is needed from the containers point of view, support for scopes and interceptors is wired into the object that the CDI container creates, and is totally opaque to the Servlet container.

Great, so we just need a factory interface that will allow the implementation of `ServletContext.createXxx` to be pluggable.   It would be good to also clean up the destroy as well and to make that equally pluggable.

cheers


 

--

Back to the top