Example usage for com.vaadin.server SessionInitEvent getSession

List of usage examples for com.vaadin.server SessionInitEvent getSession

Introduction

In this page you can find the example usage for com.vaadin.server SessionInitEvent getSession.

Prototype

public VaadinSession getSession() 

Source Link

Document

Gets the Vaadin service session that has been initialized.

Usage

From source file:de.catma.servlet.CatmaApplicationServlet.java

License:Open Source License

@Override
protected void servletInitialized() throws ServletException {
    super.servletInitialized();
    getService().addSessionInitListener(new SessionInitListener() {

        @Override/*  w  w  w .jav a2s  . c o m*/
        public void sessionInit(SessionInitEvent event) throws ServiceException {
            event.getSession().addBootstrapListener(new CatmaBootstrapListener());
        }
    });

    getService().setSystemMessagesProvider(new SystemMessagesProvider() {
        @Override
        public SystemMessages getSystemMessages(SystemMessagesInfo systemMessagesInfo) {
            CustomizedSystemMessages messages = new CustomizedSystemMessages();
            try {
                String problemRedirectURL = RepositoryPropertyKey.BaseURL
                        .getValue(RepositoryPropertyKey.BaseURL.getDefaultValue());

                messages.setAuthenticationErrorURL(problemRedirectURL);
                messages.setInternalErrorURL(problemRedirectURL);
                messages.setSessionExpiredURL(problemRedirectURL);
                messages.setCommunicationErrorURL(problemRedirectURL);
                messages.setCookiesDisabledURL(problemRedirectURL);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return messages;
        }
    });

}

From source file:de.unioninvestment.eai.portal.support.vaadin.CrudVaadinPortlet.java

License:Apache License

@Override
protected void portletInitialized() throws PortletException {
    super.portletInitialized();
    getService().addSessionInitListener(new SessionInitListener() {
        @Override/*from  w w w . j a va 2 s. c  om*/
        public void sessionInit(SessionInitEvent event) {
            event.getSession().addBootstrapListener(new LoadingIndicatorBootstrapListener());
        }
    });
}

From source file:edu.nps.moves.mmowgli.AppMaster.java

License:Open Source License

/**
* Called from servlet
*/
public void logSessionInit(SessionInitEvent event) {
    addVaadinSession(event.getSession());
    sendMySessionReport();
}

From source file:edu.nps.moves.mmowgli.Mmowgli2VaadinServlet.java

License:Open Source License

@Override
public void sessionInit(SessionInitEvent event) throws ServiceException {
    MmowgliSessionGlobals globs = new MmowgliSessionGlobals(event, this); // Initialize global object across all users windows, gets stored in VaadinSession object referenced in event
    event.getSession().addUIProvider(new Mmowgli2UIProvider());

    // Support CAC card
    VaadinRequest req = event.getRequest();
    CACData cData = CACManager.findCAC(req);
    req.setAttribute(CACData.class.getName(), cData);
    globs.setCACInfo(cData);/*from   w w  w  . j a  va2  s  . co  m*/

    MSysOut.println(SYSTEM_LOGS, "JMETERdebug: Session created, id = " + event.getSession().hashCode());
    if (appMaster != null) {// might be with error on startup
        appMaster.doSessionCountUpdate(incrementSessionCount()); // remove after the following works
        appMaster.logSessionInit(event);
    }
}

From source file:edu.nps.moves.mmowgli.MmowgliSessionGlobals.java

License:Open Source License

public MmowgliSessionGlobals(SessionInitEvent event, Mmowgli2VaadinServlet servlet) {
    event.getSession().setAttribute(MmowgliSessionGlobals.class, this); // store this for use across the app

    //appMaster = (AppMaster)servlet.getServletContext().getAttribute(MmowgliConstants.APPLICATION_MASTER_ATTR_NAME);

    scoreManager = new ScoreManager2();
    loginTimeStamp = new SimpleDateFormat("EEE d MMM yyyy HH:mm:ss").format(new Date()).toString();

    sessionCookie = getCookie(event.getRequest().getCookies());
}

From source file:edu.nps.moves.mmowgliMobile.MmowgliMobileVaadinServlet.java

License:Open Source License

@Override
public void sessionInit(SessionInitEvent event) throws ServiceException {
    event.getSession().addUIProvider(uiProvider);
}

From source file:eu.livotov.labs.webskel.app.MainUIServlet.java

License:Apache License

@Override
public void sessionInit(SessionInitEvent event) throws ServiceException {
    event.getSession().addUIProvider(applicationProvider);
}

From source file:fi.semantum.strategia.Servlet.java

License:Open Source License

@Override
protected void servletInitialized() throws ServletException {
    super.servletInitialized();
    getService().addSessionInitListener(new SessionInitListener() {

        private static final long serialVersionUID = 8234186352463637883L;

        @Override//w w  w .  j  av a  2s.  c  om
        public void sessionInit(SessionInitEvent event) {
            event.getSession().addBootstrapListener(new BootstrapListener() {

                private static final long serialVersionUID = 7535841016176448694L;

                @Override
                public void modifyBootstrapFragment(BootstrapFragmentResponse response) {
                }

                @Override
                public void modifyBootstrapPage(BootstrapPageResponse response) {
                }
            });
        }
    });
}

From source file:fr.amapj.view.engine.ui.ValoThemeSessionInitListener.java

License:Open Source License

@Override
public void sessionInit(final SessionInitEvent event) throws ServiceException {
    event.getService().setSystemMessagesProvider(new SystemMessagesProvider() {

        @Override//from   ww  w.  j a  v  a 2 s  . co m
        public SystemMessages getSystemMessages(final SystemMessagesInfo systemMessagesInfo) {
            CustomizedSystemMessages csm = new CustomizedSystemMessages();
            csm.setSessionExpiredNotificationEnabled(false);
            return csm;
        }
    });
    event.getSession().addBootstrapListener(new BootstrapListener() {

        @Override
        public void modifyBootstrapPage(final BootstrapPageResponse response) {
            final Element head = response.getDocument().head();
            head.appendElement("meta").attr("name", "viewport").attr("content",
                    "width=device-width, initial-scale=1");
            head.appendElement("meta").attr("name", "apple-mobile-web-app-capable").attr("content", "yes");
            head.appendElement("meta").attr("name", "apple-mobile-web-app-status-bar-style").attr("content",
                    "black");
        }

        @Override
        public void modifyBootstrapFragment(final BootstrapFragmentResponse response) {
            // TODO Auto-generated method stub
        }
    });
}

From source file:fr.univlorraine.mondossierweb.utils.MdwSpringVaadinServlet.java

License:Apache License

@Override
protected void servletInitialized() throws ServletException {
    getService().addSessionInitListener(new SessionInitListener() {

        private static final long serialVersionUID = -6307820453486668084L;

        @Override/*from   ww w.  java  2  s  .c  o  m*/
        public void sessionInit(SessionInitEvent sessionInitEvent) throws ServiceException {
            WebApplicationContext webApplicationContext = WebApplicationContextUtils
                    .getWebApplicationContext(getServletContext());

            // remove DefaultUIProvider instances to avoid mapping
            // extraneous UIs if e.g. a servlet is declared as a nested
            // class in a UI class
            VaadinSession session = sessionInitEvent.getSession();
            List<UIProvider> uiProviders = new ArrayList<UIProvider>(session.getUIProviders());
            for (UIProvider provider : uiProviders) {
                // use canonical names as these may have been loaded with
                // different classloaders
                if (DefaultUIProvider.class.getCanonicalName().equals(provider.getClass().getCanonicalName())) {
                    session.removeUIProvider(provider);
                }
            }

            // add Spring UI provider
            SpringUIProvider uiProvider = new MdwUIProvider(webApplicationContext);
            session.addUIProvider(uiProvider);
        }
    });
}