Hi Daniel, Carsten,

Carsten Ziegeler skrev:
During development you sometimes face the problem that you need access
to specific information, like the current request object (or its
parameters), the Spring application context, the servlet context etc.

In an ideal world where everything is a component, this is no issue as the container provides a way for this. But as we all know, the world is
not ideal and this means, you sometimes need access to those objects
when you don't have anything else to use.

Can you give some specific examples where you need this?

We have similar needs. For using REST-style POST and PUT request with blocks it is neccessary to copy the original request input stream to a new block request, so it would be helpful to be able to access the original request at this point of time. Another use case is copying request parameters when using blocks. I'm sure Alexander can give you some more details.


I think we need a way to access the servlet context, the original http
request/response object and the current application context. (If you
have access to the current request object, you can get the application
context from the request).

Spring has some kind of request scope for beans together with a servlet filter for setting up the scope it has also mechanisms for keeping dependencies on request scoped beans up to date. This is a fairly structured and controlled way to handle request scoped information. And it keeps DI and testability. Would it be enough for your needs?


If there is a solution for this problem that does not uses global variables, we should go for it.

Lars

--
Lars Trieloff
visit http://www.mindquarry.com/



Reply via email to