Hi All,
I am currently trying to *hack* an approach to use Aysnc Servlet support
for Guice 4.1.0 app (along with guice-servlets extension, servlet spec
3.1.0).
Most of the things are working just fine but I run into a problem where
Sesion scoped deps are not injected/Provider fails with null pointer
because session is not available at all in filter's localContext is null
since obviously the processing is in completely different scope.
I was wondering if anybody has faced this problem or may someone can
provide any pointers in direction to fix this.
Example pseudo code. (Can add more details/examples if required, but not
sure if I can share actual snippets)
*/** Service**/*
package com.dummy.app.serviceA;
import com.google.inject.AbstractModule;
public class SubModule extends AbstractModule {
@Override
protected void configure() {
bind(SomeService.class).in(ServletScopes.SESSION);
}
}
package com.dummy.web.servlets;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class SomeServlet extends AbstractModule {
private final SomeService service;
@Override
protected final void doGet(final HttpServletRequest req, final
HttpServletResponse resp) throws ServletException,
IOException {
// Put into context when context is initialized from
GuiceServletContextListener.
ExecutorService executor = (ExecutorService)
req.getServletContext().getAttribute("ASYNC_SERV_EXECUTOR");
final AsyncContext asyncContext = req.startAsync();
executor.submit( () -> service.processRequest(req,resp))
}
}
Best.
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-guice/f5f77f46-5928-4201-8d92-b5e2130f10aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.