Example usage for com.vaadin.server VaadinSession getConfiguration

List of usage examples for com.vaadin.server VaadinSession getConfiguration

Introduction

In this page you can find the example usage for com.vaadin.server VaadinSession getConfiguration.

Prototype

public DeploymentConfiguration getConfiguration() 

Source Link

Document

Gets the configuration for this session.

Usage

From source file:annis.gui.servlets.AnnisServlet.java

License:Apache License

@Override
protected void servletInitialized() throws ServletException {
    super.servletInitialized();

    getService().addSessionInitListener(new SessionInitListener() {

        @Override/* w w w .  ja  v a2s.c o m*/
        public void sessionInit(SessionInitEvent event) throws ServiceException {
            VaadinSession session = event.getSession();
            if (Helper.isKickstarter(session)) {
                // only load configurations from the WEB-INF/conf folder
                File config = new File(event.getService().getBaseDirectory(),
                        "/WEB-INF/conf/annis-gui.properties");
                loadPropertyFile(config, session);
                // manually override the service URL if given
                String serviceURL = session.getConfiguration().getInitParameters()
                        .getProperty(Helper.KEY_WEB_SERVICE_URL);
                if (serviceURL != null) {
                    session.setAttribute(Helper.KEY_WEB_SERVICE_URL, serviceURL);
                }
            } else {
                // load some additional properties from our ANNIS configuration
                loadApplicationProperties("annis-gui.properties", session);
            }

            event.getSession().addRequestHandler(new ShortenerRequestHandler());
        }
    });
}

From source file:annis.libgui.Helper.java

License:Apache License

public static boolean isKickstarter(VaadinSession session) {
    if (session != null) {
        return Boolean.parseBoolean(
                session.getConfiguration().getInitParameters().getProperty("kickstarterEnvironment", "false"));
    } else {//from www.ja v a 2  s. com
        return false;
    }
}

From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPageBase.java

License:Open Source License

@HibernateUpdate
@HibernateUserUpdate/*from w ww  .  j av a2 s.  c om*/
private void wereInReallyTL(User _u_) {
    boolean updateneeded = false; // avoid db hit if possible

    if (currentPopup != null)
        UI.getCurrent().removeWindow(currentPopup); // app.getMainWindow().removeWindow(currentPopup);

    MmowgliSessionGlobals globs = Mmowgli2UI.getGlobals();
    globs.setLoggedIn(true);

    if (_u_ != null) {
        Object cacId = CACManager.getCacId(globs.getCACInfo());
        if (cacId == null) {
            if (_u_.getCacId() != null) {
                _u_.setCacId(null);
                updateneeded = true;
            }
        } else if (!_u_.getCacId().equals(cacId.toString())) {
            _u_.setCacId(cacId.toString());
            updateneeded = true;
        }
        //_u_.setCacId(cacId == null? null :cacId.toString());
        if (!_u_.isWelcomeEmailSent()) {
            MailManager mmgr = AppMaster.instance().getMailManager();
            mmgr.onNewUserSignupTL(_u_);
            _u_.setWelcomeEmailSent(true);
            updateneeded = true;
        }
        // If we're here, we've either been email-confirmed or that is not necessary; make sure here
        if (!_u_.isEmailConfirmed()) {
            _u_.setEmailConfirmed(true);
            updateneeded = true;
        }

        // Adjust session timeouts.  Default (standard user) is set in web.xml
        VaadinSession vsess = UI.getCurrent().getSession();
        WrappedSession sess = vsess.getSession();
        if (_u_.isGameMaster())
            sess.setMaxInactiveInterval(GAMEMASTER_SESSION_TIMEOUT_SECONDS);
        if (_u_.isAdministrator())
            sess.setMaxInactiveInterval(ADMINSTRATOR_SESSION_TIMEOUT_SECONDS);

        MSysOut.println(SYSTEM_LOGS,
                "Vaadin heartbeat interval (sec): " + vsess.getConfiguration().getHeartbeatInterval());
        MSysOut.println(SYSTEM_LOGS,
                "Tomcat timeout (\"maxInactiveInterval\") (sec): " + sess.getMaxInactiveInterval());
        GameEventLogger.logUserLoginTL(_u_);
        if (updateneeded) {
            User.updateTL(_u_);
        }

        HSess.closeAndReopen(); // should be ok
        _u_ = User.merge(_u_, HSess.get());

        MmowgliController cntlr = globs.getController();
        if (cntlr != null)
            cntlr.handleEventTL(MmowgliEvent.HANDLE_LOGIN_STARTUP, _u_, null); //don't want User.get() in this session, userId, null);
        else
            System.err.println("No controller in RegistrationPageBase.wereIn()");

        AppMaster.instance().sendMySessionReport();
    }
}