When calling a Java method on which you must pass a new instance as a parameter, how is it possible that this new instance is created by the CDI container?
In the following example: I add a listener to the asynchronous servlet context:
@WebServlet(value = "/example", asyncSupported = true) public class ExampleServlet extends HttpServlet { @Override protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
So instead of manually executing this new AsyncListener () creation, I would like it to be created by the CDI container.
Of course, I want each aync context to have its own listener instance, otherwise I would just inject AsyncListener with @Inject as a field in the servlet class.
At the moment, no way has been found to do this. Does anyone have an idea to share?
source share