@Test public void testFireSessionDestroy() throws ServletException { ServletConfig servletConfig = new MockServletConfig(); VaadinServlet servlet = new VaadinServlet(); servlet.init(servletConfig); VaadinService service = servlet.getService(); TestSessionDestroyListener listener = new TestSessionDestroyListener(); service.addSessionDestroyListener(listener); MockVaadinSession vaadinSession = new MockVaadinSession(service); service.fireSessionDestroy(vaadinSession); Assert.assertEquals( "'fireSessionDestroy' method doesn't call 'close' for the session", 1, vaadinSession.getCloseCount()); vaadinSession.valueUnbound(EasyMock .createMock(HttpSessionBindingEvent.class)); Assert.assertEquals("'fireSessionDestroy' method may not call 'close' " + "method for closing session", 1, vaadinSession.getCloseCount()); Assert.assertEquals("SessionDestroyListeners not called exactly once", 1, listener.callCount); }
public void fireSessionDestroy(VaadinSession vaadinSession) { final VaadinSession session = vaadinSession; session.access(new Runnable() { @Override public void run() { if (session.getState() == State.CLOSED) { return; } if (session.getState() == State.OPEN) { closeSession(session); } ArrayList<UI> uis = new ArrayList<UI>(session.getUIs()); for (final UI ui : uis) { ui.accessSynchronously(new Runnable() { @Override public void run() { if (!ui.isClosing()) { ui.close(); } session.removeUI(ui); } }); } eventRouter.fireEvent(new SessionDestroyEvent( VaadinService.this, session), session.getErrorHandler()); session.setState(State.CLOSED); } }); }
VaadinService implements Serializable { public void fireSessionDestroy(VaadinSession vaadinSession) { final VaadinSession session = vaadinSession; session.access(new Runnable() { @Override public void run() { if (session.getState() == State.CLOSED) { return; } if (session.getState() == State.OPEN) { closeSession(session); } ArrayList<UI> uis = new ArrayList<UI>(session.getUIs()); for (final UI ui : uis) { ui.accessSynchronously(new Runnable() { @Override public void run() { if (!ui.isClosing()) { ui.close(); } session.removeUI(ui); } }); } eventRouter.fireEvent(new SessionDestroyEvent( VaadinService.this, session), session.getErrorHandler()); session.setState(State.CLOSED); } }); } }
VaadinService implements Serializable { public void fireSessionDestroy(VaadinSession vaadinSession) { final VaadinSession session = vaadinSession; session.access(new Runnable() { @Override public void run() { if (session.getState() == State.CLOSED) { return; } if (session.getState() == State.OPEN) { closeSession(session); } ArrayList<UI> uis = new ArrayList<UI>(session.getUIs()); for (final UI ui : uis) { ui.accessSynchronously(new Runnable() { @Override public void run() { if (!ui.isClosing()) { ui.close(); } session.removeUI(ui); } }); } eventRouter.fireEvent(new SessionDestroyEvent( VaadinService.this, session), session.getErrorHandler()); session.setState(State.CLOSED); } }); } VaadinService(DeploymentConfiguration deploymentConfiguration); }
VaadinService implements Serializable { public void fireSessionDestroy(VaadinSession vaadinSession) { final VaadinSession session = vaadinSession; session.access(new Runnable() { @Override public void run() { if (session.getState() == State.CLOSED) { return; } if (session.getState() == State.OPEN) { closeSession(session); } ArrayList<UI> uis = new ArrayList<UI>(session.getUIs()); for (final UI ui : uis) { ui.accessSynchronously(new Runnable() { @Override public void run() { if (!ui.isClosing()) { ui.close(); } session.removeUI(ui); } }); } eventRouter.fireEvent(new SessionDestroyEvent( VaadinService.this, session), session.getErrorHandler()); session.setState(State.CLOSED); } }); } VaadinService(DeploymentConfiguration deploymentConfiguration); void init(); abstract String getStaticFileLocation(VaadinRequest request); abstract String getConfiguredWidgetset(VaadinRequest request); abstract String getConfiguredTheme(VaadinRequest request); abstract boolean isStandalone(VaadinRequest request); ClassLoader getClassLoader(); void setClassLoader(ClassLoader classLoader); abstract String getMimeType(String resourceName); DeploymentConfiguration getDeploymentConfiguration(); void setSystemMessagesProvider(
            SystemMessagesProvider systemMessagesProvider); SystemMessagesProvider getSystemMessagesProvider(); SystemMessages getSystemMessages(Locale locale, VaadinRequest request); abstract File getBaseDirectory(); void addSessionInitListener(SessionInitListener listener); void removeSessionInitListener(SessionInitListener listener); void addSessionDestroyListener(SessionDestroyListener listener); void fireSessionDestroy(VaadinSession vaadinSession); void removeSessionDestroyListener(SessionDestroyListener listener); VaadinSession findVaadinSession(VaadinRequest request); static VaadinService getCurrent(); void setCurrentInstances(VaadinRequest request,
            VaadinResponse response); static void setCurrent(VaadinService service); static VaadinRequest getCurrentRequest(); static VaadinResponse getCurrentResponse(); abstract String getServiceName(); UI findUI(VaadinRequest request); boolean preserveUIOnRefresh(UIProvider provider, UICreateEvent event); static void reinitializeSession(VaadinRequest request); abstract InputStream getThemeResourceAsStream(UI ui,
            String themeName, String resource); abstract String getMainDivId(VaadinSession session,
            VaadinRequest request, Class<? extends UI> uiClass); void closeSession(VaadinSession session); void requestStart(VaadinRequest request, VaadinResponse response); void requestEnd(VaadinRequest request, VaadinResponse response,
            VaadinSession session); Iterable<RequestHandler> getRequestHandlers(); void handleRequest(VaadinRequest request, VaadinResponse response); void writeStringResponse(VaadinResponse response,
            String contentType, String reponseString); static String createCriticalNotificationJSON(String caption,
            String message, String details, String url); @Deprecated void criticalNotification(VaadinRequest request,
            VaadinResponse response, String caption, String message,
            String details, String url); boolean ensurePushAvailable(); static void verifyNoOtherSessionLocked(VaadinSession session); static boolean isOtherSessionLocked(VaadinSession session); static boolean isCsrfTokenValid(VaadinSession session,
            String requestToken); Future<Void> accessSession(VaadinSession session, Runnable runnable); void ensureAccessQueuePurged(VaadinSession session); void runPendingAccessTasks(VaadinSession session); void addServiceDestroyListener(ServiceDestroyListener listener); void removeServiceDestroyListener(ServiceDestroyListener listener); void destroy(); void removeSession(WrappedSession wrappedSession); }
VaadinService implements Serializable { public void fireSessionDestroy(VaadinSession vaadinSession) { final VaadinSession session = vaadinSession; session.access(new Runnable() { @Override public void run() { if (session.getState() == State.CLOSED) { return; } if (session.getState() == State.OPEN) { closeSession(session); } ArrayList<UI> uis = new ArrayList<UI>(session.getUIs()); for (final UI ui : uis) { ui.accessSynchronously(new Runnable() { @Override public void run() { if (!ui.isClosing()) { ui.close(); } session.removeUI(ui); } }); } eventRouter.fireEvent(new SessionDestroyEvent( VaadinService.this, session), session.getErrorHandler()); session.setState(State.CLOSED); } }); } VaadinService(DeploymentConfiguration deploymentConfiguration); void init(); abstract String getStaticFileLocation(VaadinRequest request); abstract String getConfiguredWidgetset(VaadinRequest request); abstract String getConfiguredTheme(VaadinRequest request); abstract boolean isStandalone(VaadinRequest request); ClassLoader getClassLoader(); void setClassLoader(ClassLoader classLoader); abstract String getMimeType(String resourceName); DeploymentConfiguration getDeploymentConfiguration(); void setSystemMessagesProvider(
            SystemMessagesProvider systemMessagesProvider); SystemMessagesProvider getSystemMessagesProvider(); SystemMessages getSystemMessages(Locale locale, VaadinRequest request); abstract File getBaseDirectory(); void addSessionInitListener(SessionInitListener listener); void removeSessionInitListener(SessionInitListener listener); void addSessionDestroyListener(SessionDestroyListener listener); void fireSessionDestroy(VaadinSession vaadinSession); void removeSessionDestroyListener(SessionDestroyListener listener); VaadinSession findVaadinSession(VaadinRequest request); static VaadinService getCurrent(); void setCurrentInstances(VaadinRequest request,
            VaadinResponse response); static void setCurrent(VaadinService service); static VaadinRequest getCurrentRequest(); static VaadinResponse getCurrentResponse(); abstract String getServiceName(); UI findUI(VaadinRequest request); boolean preserveUIOnRefresh(UIProvider provider, UICreateEvent event); static void reinitializeSession(VaadinRequest request); abstract InputStream getThemeResourceAsStream(UI ui,
            String themeName, String resource); abstract String getMainDivId(VaadinSession session,
            VaadinRequest request, Class<? extends UI> uiClass); void closeSession(VaadinSession session); void requestStart(VaadinRequest request, VaadinResponse response); void requestEnd(VaadinRequest request, VaadinResponse response,
            VaadinSession session); Iterable<RequestHandler> getRequestHandlers(); void handleRequest(VaadinRequest request, VaadinResponse response); void writeStringResponse(VaadinResponse response,
            String contentType, String reponseString); static String createCriticalNotificationJSON(String caption,
            String message, String details, String url); @Deprecated void criticalNotification(VaadinRequest request,
            VaadinResponse response, String caption, String message,
            String details, String url); boolean ensurePushAvailable(); static void verifyNoOtherSessionLocked(VaadinSession session); static boolean isOtherSessionLocked(VaadinSession session); static boolean isCsrfTokenValid(VaadinSession session,
            String requestToken); Future<Void> accessSession(VaadinSession session, Runnable runnable); void ensureAccessQueuePurged(VaadinSession session); void runPendingAccessTasks(VaadinSession session); void addServiceDestroyListener(ServiceDestroyListener listener); void removeServiceDestroyListener(ServiceDestroyListener listener); void destroy(); void removeSession(WrappedSession wrappedSession); @Deprecated
    static final String URL_PARAMETER_RESTART_APPLICATION; @Deprecated
    static final String URL_PARAMETER_CLOSE_APPLICATION; }