Vaadin/Guice Integration

Hello,

I’m using the integration of Vaadin with Guice framework to do dependency injection, as is the tutorial on the site of Vaadin.

My web.xml is as:



  <!-- ==== CONFIGURATION OF GUICE ================================================== -->

   <filter>
        <filter-name>guiceFilter</filter-name>
        <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>guiceFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <listener>
        <listener-class>com.sinais.midas.guice.GuiceServletConfig</listener-class>
    </listener>


 <!-- ==== CONFIGURATION OF VAADIN=================================================== -->

    <servlet>
        <servlet-name>VaadinApplication</servlet-name>
        <servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
        <init-param>
            <param-name>application</param-name>
            <param-value>com.sinais.midas.vaadin.Consulta</param-value>
        </init-param>
        <load-on-startup>3</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>VaadinApplication</servlet-name>
        <url-pattern>/consulta/*</url-pattern>
    </servlet-mapping>


    <servlet-mapping>
        <servlet-name>VaadinApplication</servlet-name>
        <url-pattern>/VAADIN/*</url-pattern>
    </servlet-mapping>

and GuiceServeletConfig…


public class GuiceServletConfig extends GuiceServletContextListener {

    @Override
    protected Injector getInjector() {

        ServletModule module = new ServletModule() {

            @Override
            protected void configureServlets() {


//                serve("/consulta/*", "/*" ).with(GuiceApplicationServlet.class);

                serve("/consulta/*").with(GuiceApplicationServlet.class);
                                               
                bind(Application.class).to(Consulta.class).in(ServletScopes.SESSION);
                bind(ProdutoService.class).annotatedWith(Names.named("produtoService")).to(ProdutoService.class);
                bindConstant().annotatedWith(Names.named("bemvindo")).to("Test of DI with Vaadin/Guice Application");
            }
        };

        Injector injector = Guice.createInjector(module);

        return injector;
    }
}

Thus the above does not do dependency injection in any way. But it works if you remove the comment. Ok, but my app with vaadin is inserted into a website, via iframe tag. If I remove the comment it will turn first to enter in vaadin, because the filter is redirecting everything to it.

Is first necessary to enter in my website and then enter in app with vaadin, in this order.

someone would have an idea? Tanks in advance.

Hübner