use of javax.servlet.http.HttpSessionListener in project nutzboot by nutzam.
the class TomcatStarter method addNutzSupport.
private void addNutzSupport() {
List<WebFilterFace> filters = appContext.getBeans(WebFilterFace.class);
Collections.sort(filters, Comparator.comparing(WebFilterFace::getOrder));
filters.forEach((face) -> addFilter(face));
appContext.getBeans(WebServletFace.class).forEach((face) -> {
if (face.getServlet() == null) {
return;
}
addServlet(face);
});
appContext.getBeans(WebEventListenerFace.class).forEach((face) -> {
EventListener listener = face.getEventListener();
if (listener != null) {
if ((listener instanceof ServletContextAttributeListener) || (listener instanceof ServletRequestAttributeListener) || (listener instanceof ServletRequestListener) || (listener instanceof HttpSessionIdListener) || (listener instanceof HttpSessionAttributeListener)) {
this.tomcatContext.addApplicationEventListener(listener);
}
if ((listener instanceof ServletContextListener) || (listener instanceof HttpSessionListener)) {
this.tomcatContext.addApplicationLifecycleListener(listener);
}
}
});
}
use of javax.servlet.http.HttpSessionListener in project drill by axbaretto.
the class WebServer method createSessionHandler.
/**
* @return A {@link SessionHandler} which contains a
* {@link HashSessionManager}
*/
private SessionHandler createSessionHandler(Config config, final SecurityHandler securityHandler) {
SessionManager sessionManager = new HashSessionManager();
sessionManager.setMaxInactiveInterval(config.getInt(DrillOnYarnConfig.HTTP_SESSION_MAX_IDLE_SECS));
sessionManager.addEventListener(new HttpSessionListener() {
@Override
public void sessionCreated(HttpSessionEvent se) {
// No-op
}
@Override
public void sessionDestroyed(HttpSessionEvent se) {
final HttpSession session = se.getSession();
if (session == null) {
return;
}
final Object authCreds = session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
if (authCreds != null) {
final SessionAuthentication sessionAuth = (SessionAuthentication) authCreds;
securityHandler.logout(sessionAuth);
session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
}
}
});
return new SessionHandler(sessionManager);
}
use of javax.servlet.http.HttpSessionListener in project tomcat70 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 = (Context) manager.getContainer();
Object[] listeners = context.getApplicationLifecycleListeners();
if (listeners != null) {
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.getContainer().getLogger().error(sm.getString("standardSession.sessionEvent"), t);
}
}
}
}
use of javax.servlet.http.HttpSessionListener in project drill by apache.
the class WebServer method createSessionHandler.
/**
* It creates A {@link SessionHandler}
*
* @param config Drill configs
* @param securityHandler Set of initparameters that are used by the Authentication
* @return session handler
*/
private SessionHandler createSessionHandler(Config config, final SecurityHandler securityHandler) {
SessionHandler sessionHandler = new SessionHandler();
sessionHandler.setMaxInactiveInterval(config.getInt(DrillOnYarnConfig.HTTP_SESSION_MAX_IDLE_SECS));
sessionHandler.addEventListener(new HttpSessionListener() {
@Override
public void sessionCreated(HttpSessionEvent se) {
// No-op
}
@Override
public void sessionDestroyed(HttpSessionEvent se) {
final HttpSession session = se.getSession();
if (session == null) {
return;
}
final Object authCreds = session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
if (authCreds != null) {
final SessionAuthentication sessionAuth = (SessionAuthentication) authCreds;
securityHandler.logout(sessionAuth);
session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
}
}
});
return sessionHandler;
}
use of javax.servlet.http.HttpSessionListener in project jodd by oblac.
the class SessionMonitor method sessionDestroyed.
/**
* Removes session from a map and broadcasts event to registered listeners.
*/
@Override
public void sessionDestroyed(final HttpSessionEvent httpSessionEvent) {
HttpSession session = httpSessionEvent.getSession();
sessionMap.remove(session.getId());
for (HttpSessionListener listener : listeners) {
listener.sessionDestroyed(httpSessionEvent);
}
}
Aggregations