Hey Abderites:
So here's my situation. I've got an Abdera server (i.e. AbderaServlet
in Tomcat) running that needs to share some information with another
servlet. In particular, the non-AbderaServlet (let's call it Servlet1)
needs to create an Object and then in an ideal world pass that through
to the AbderaServlet in such a way that the Provider instance that gets
created has access to it. Make sense?
The best solution for me would be to put something into the
ServletContext, and then somehow get access to that later - but I can't
seem to do that currently.
Since the initialization step doesn't really need to be done until the
first actual request, and I've already got a solid connection between my
Provider and my TargetResolver, I figured one way would be something
like (pseudocode):
TargetResolver.resolve(Request request) {
ServletRequestContext context = (ServletRequestContext)request;
if (thing == null) {
thing = context.getServletContext().getAttribute("thing");
}
}
A patch that would just carry the ServletContext in addition to the
HttpServletRequest in each ServletRequestContext would be very easy to
do in Abdera, and would get me what I need. Am happy to contribute same.
Is there a better way to do this? I noticed the ManagedProvider stuff
but it looks like you can only pass Strings in there, and only in very
specific ways. Perhaps some kind of more general initialization context
that I'm missing? The above patch would solve my problem later but not
in v0.4.0.
The solution I've come up with for now is to subclass the AbderaServlet,
and add the ServletContext to every HttpRequest as an attribute - that
lets me do basically the same trick, but it seems... less than optimal.
Thoughts/comments?
Thanks,
--Glen