Package net.frenopatico.citadels.conf

Source Code of net.frenopatico.citadels.conf.CitadelsServletConfig

package net.frenopatico.citadels.conf;

import java.util.HashMap;
import java.util.Map;

import net.frenopatico.citadels.app.CitadelsApplication;
import net.frenopatico.citadels.app.GuiceApplicationServlet;
import net.frenopatico.citadels.modules.AppEngineModule;
import net.frenopatico.citadels.modules.ManagersModule;
import net.frenopatico.citadels.modules.ServicesModule;
import net.frenopatico.citadels.modules.WindowsModule;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.servlet.GuiceServletContextListener;
import com.google.inject.servlet.ServletModule;
import com.google.inject.servlet.ServletScopes;
import com.vaadin.Application;

/**
* Configure the Guice Servlet.
*
*/
public class CitadelsServletConfig extends GuiceServletContextListener {

    @Override
    protected Injector getInjector() {

        final Module gaeModule = AppEngineModule.build().withAsyncDatastoreService().withMemcacheService();
        final Module windowsModule = WindowsModule.build();
        final Module servicesModule = ServicesModule.build();
        final Module managersModule = ManagersModule.build();

        final ServletModule module = new ServletModule() {
            @Override
            protected void configureServlets() {
                bind( Application.class ).to( CitadelsApplication.class ).in( ServletScopes.SESSION );

                Map<String, String> parameters = new HashMap<String, String>( 1 );
                parameters.put( "application", CitadelsApplication.class.getName() );

                serve( "/app/*", "/VAADIN/*", "/UIDL*" ).with( GuiceApplicationServlet.class, parameters );
            }
        };

        final Injector injector = Guice.createInjector( module, managersModule, windowsModule, servicesModule, gaeModule );

        return injector;
    }
}
TOP

Related Classes of net.frenopatico.citadels.conf.CitadelsServletConfig

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.