-
Feature Request
-
Resolution: Obsolete
-
Major
-
1.0
-
None
Consider this code based on this blog post: < https://weblogs.java.net/blog/swchan2/archive/2013/06/06/asynchronous-servlet-and-java-ee-concurrency-utilities >.
@WebServlet(urlPatterns="/test2", asyncSupported=true) public class TestAsyncMESServlet extends HttpServlet { @Resource private ManagedExecutorService managedExecutorService; @Inject MyRunnableImpl myRunnableImpl; @Override protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { final AsyncContext asyncContext = req.startAsync(); final PrintWriter writer = res.getWriter(); managedExecutorService.submit(myRunnableImpl); } public static class MyRunnableImpl implements Runnable { @Inject Bean bean; // Bean is @RequestScoped @Override public void run() { writer.println("Done"); asyncContext.complete(); } } }
According to Jozef Hartzinger, this currently does not work, because only @Dependent and @ApplicationScoped beans are propagated to the new thread. To keep CDI relevant in light of the reactive programming movement and the popularity of node.js, we need to make this work.
- blocks
-
RESTEASY-682 Async request could not find CDI injected bean with RequestScoped
- Reopened