Example usage for org.springframework.security.web.session HttpSessionDestroyedEvent HttpSessionDestroyedEvent

List of usage examples for org.springframework.security.web.session HttpSessionDestroyedEvent HttpSessionDestroyedEvent

Introduction

In this page you can find the example usage for org.springframework.security.web.session HttpSessionDestroyedEvent HttpSessionDestroyedEvent.

Prototype

public HttpSessionDestroyedEvent(HttpSession session) 

Source Link

Usage

From source file:com.hazelcast.web.spring.SpringAwareWebFilter.java

@Override
protected void destroySession(HazelcastHttpSession session, boolean invalidate) {
    super.destroySession(session, invalidate);
    if (invalidate) {
        ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
        if (appContext != null) {
            ensureSessionRegistryInitialized(appContext);
            if (sessionRegistry != null) {
                String originalSessionId = session.getOriginalSessionId();
                // If original session id is registered already, we don't need it.
                // So, we should remove it also.
                sessionRegistry.removeSessionInformation(originalSessionId);
                /**//from   w  ww  . j  av  a2 s .c o m
                 * Publish an event to notify
                 * {@link org.springframework.security.core.session.SessionRegistry} instance.
                 * So Spring clears information about our Hazelcast session.
                 */
                appContext.publishEvent(new HttpSessionDestroyedEvent(session));

                LOGGER.finest(
                        "Published destroy session event for Spring for session with id " + session.getId());
            }
        }
    }
}

From source file:org.springframework.security.web.session.HttpSessionEventPublisher.java

/**
 * Handles the HttpSessionEvent by publishing a {@link HttpSessionDestroyedEvent} to
 * the application appContext.//from w w  w.j  a v a2 s.co  m
 *
 * @param event The HttpSessionEvent pass in by the container
 */
public void sessionDestroyed(HttpSessionEvent event) {
    HttpSessionDestroyedEvent e = new HttpSessionDestroyedEvent(event.getSession());
    Log log = LogFactory.getLog(LOGGER_NAME);

    if (log.isDebugEnabled()) {
        log.debug("Publishing event: " + e);
    }

    getContext(event.getSession().getServletContext()).publishEvent(e);
}