use of javax.servlet.http.HttpSessionEvent in project tomcat by apache.
the class StandardSessionContext method tellNew.
/**
* Inform the listeners about the new session.
*
*/
public void tellNew() {
// Notify interested session event listeners
fireSessionEvent(Session.SESSION_CREATED_EVENT, null);
// Notify interested application event listeners
Context context = manager.getContext();
Object[] listeners = context.getApplicationLifecycleListeners();
if (listeners != null && listeners.length > 0) {
HttpSessionEvent event = new HttpSessionEvent(getSession());
for (int i = 0; i < listeners.length; i++) {
if (!(listeners[i] instanceof HttpSessionListener))
continue;
HttpSessionListener listener = (HttpSessionListener) listeners[i];
try {
context.fireContainerEvent("beforeSessionCreated", listener);
listener.sessionCreated(event);
context.fireContainerEvent("afterSessionCreated", listener);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
try {
context.fireContainerEvent("afterSessionCreated", listener);
} catch (Exception e) {
// Ignore
}
manager.getContext().getLogger().error(sm.getString("standardSession.sessionEvent"), t);
}
}
}
}
use of javax.servlet.http.HttpSessionEvent in project tomcat by apache.
the class StandardSessionContext method passivate.
/**
* Perform the internal processing required to passivate
* this session.
*/
public void passivate() {
// Notify interested session event listeners
fireSessionEvent(Session.SESSION_PASSIVATED_EVENT, null);
// Notify ActivationListeners
HttpSessionEvent event = null;
String[] keys = keys();
for (int i = 0; i < keys.length; i++) {
Object attribute = attributes.get(keys[i]);
if (attribute instanceof HttpSessionActivationListener) {
if (event == null)
event = new HttpSessionEvent(getSession());
try {
((HttpSessionActivationListener) attribute).sessionWillPassivate(event);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
manager.getContext().getLogger().error(sm.getString("standardSession.attributeEvent"), t);
}
}
}
}
use of javax.servlet.http.HttpSessionEvent in project jetty.project by eclipse.
the class Session method didActivate.
/* ------------------------------------------------------------- */
/**
* Call the activation listeners. This must be called holding the
* lock.
*/
public void didActivate() {
HttpSessionEvent event = new HttpSessionEvent(this);
for (Iterator<String> iter = _sessionData.getKeys().iterator(); iter.hasNext(); ) {
Object value = _sessionData.getAttribute(iter.next());
if (value instanceof HttpSessionActivationListener) {
HttpSessionActivationListener listener = (HttpSessionActivationListener) value;
listener.sessionDidActivate(event);
}
}
}
use of javax.servlet.http.HttpSessionEvent in project jetty.project by eclipse.
the class SessionHandler method renewSessionId.
/* ------------------------------------------------------------ */
/** Change the existing session id.
*
* @param oldId the old session id
* @param oldExtendedId the session id including worker suffix
* @param newId the new session id
* @param newExtendedId the new session id including worker suffix
*/
public void renewSessionId(String oldId, String oldExtendedId, String newId, String newExtendedId) {
try {
//swap the id over
Session session = _sessionCache.renewSessionId(oldId, newId);
if (session == null) {
//session doesn't exist on this context
return;
}
//remember the extended id
session.setExtendedId(newExtendedId);
//inform the listeners
if (!_sessionIdListeners.isEmpty()) {
HttpSessionEvent event = new HttpSessionEvent(session);
for (HttpSessionIdListener l : _sessionIdListeners) {
l.sessionIdChanged(event, oldId);
}
}
} catch (Exception e) {
LOG.warn(e);
}
}
use of javax.servlet.http.HttpSessionEvent in project jodd by oblac.
the class ServletsMockitoUtil method createHttpSessionEvent.
public static HttpSessionEvent createHttpSessionEvent(HttpSession session) {
HttpSessionEvent sessionEvent = mock(HttpSessionEvent.class);
when(sessionEvent.getSession()).thenReturn(session);
return sessionEvent;
}
Aggregations