CDI and Push

Hello,

in Vaadin wiki article “Enabling server push” https://vaadin.com/wiki/-/wiki/Main/Enabling%20server%20push it mentions to add tag “true” in web.xml file, when using a servlet 3.0 compatible server.

Where would I place this tag when useing CDI without a web.xml file? Or did I miss something?

Thanks all
Andreas.

It is a parameter in your @WebServlet annotation, have not tested this in Vaadin 7, but you might find it difficult to do background threads combined with CDI.


@SuppressWarnings("serial")
@CDIUI("/info")
public class InfoUI extends UI {

    private static final Logger LOGGER = Logger.getLogger(InfoUI.class.getName());
    @Inject
    private CDIViewProvider viewProvider;
    @WebServlet( asyncSupported = true, urlPatterns = {"/info", "/info/*", "/VAADIN/*"}, initParams = {
        @WebInitParam(name = VaadinSession.UI_PARAMETER, value = Props.INFO_UI_NAME),
        @WebInitParam(name = Constants.SERVLET_PARAMETER_UI_PROVIDER, value = "com.vaadin.cdi.CDIUIProvider"),
        @WebInitParam(name = Constants.SERVLET_PARAMETER_PRODUCTION_MODE, value = "true"),
        @WebInitParam(name = Constants.SERVLET_PARAMETER_PUSH_MODE, value = "true")
    })
    public static class InfoUIApplicationServlet extends VaadinServlet {
    }

}

Thank you for the quick reply!

I am bit worried from the comment “…but you might find it difficult to do background threads combined with CDI.”. Can you please explain what this means?

The reason I ask is that a few month ago I started a new project using VAADIN 7, with the expectation that in Version 7xx adds Push, not knowing or expecting that CDI and Push were problematic!

Artur has a demo application, as he calls it: "Chat application with all the bells and whistles (like CDI, JMS, try it here)
https://github.com/R2R/CDIChat/

Does this mean the Chat application is not servlet 3 compatible?

I’m a bit confused if VAADIN 7.1 + Push + CDI + Servlet 3 can work together?

Thank-you
Andreas.

I think https://github.com/R2R/CDIChat/ proves that the issues I had (Vaadin 6 + push + cdi) was addressed :slight_smile:

As stated I have not tested this in Vaadin 7 and the new Vaadin-CDI addon ( just have not had the time to play with it yet ).

The main problem ( that I had in Vaadin 6 ) was that cdi-util addon (1.xx ) used @RequestScoped, and obviously in a background thread you don’t have a Request.

From a very quick scan of the Vaadin-CDI source, it would seem that only JaasAccessControl still makes use of @RequestScoped so avoid using that class in your background thread and you should be fine.