use of javax.servlet.http.HttpSessionEvent in project wildfly by wildfly.
the class InfinispanSessionManager method triggerPrePassivationEvents.
void triggerPrePassivationEvents(ImmutableSession session) {
List<HttpSessionActivationListener> listeners = findListeners(session);
if (!listeners.isEmpty()) {
HttpSessionEvent event = new HttpSessionEvent(new ImmutableHttpSessionAdapter(session, this.context));
listeners.forEach(listener -> listener.sessionWillPassivate(event));
}
}
use of javax.servlet.http.HttpSessionEvent in project wildfly by wildfly.
the class InfinispanSessionManager method triggerPostActivationEvents.
void triggerPostActivationEvents(ImmutableSession session) {
List<HttpSessionActivationListener> listeners = findListeners(session);
if (!listeners.isEmpty()) {
HttpSessionEvent event = new HttpSessionEvent(new ImmutableHttpSessionAdapter(session, this.context));
listeners.forEach(listener -> listener.sessionDidActivate(event));
}
}
use of javax.servlet.http.HttpSessionEvent in project tomee by apache.
the class SessionManager method doDestroy.
private void doDestroy(final SessionWrapper next) {
HttpSessionEvent event = null;
if (next.end != null) {
event = new HttpSessionEvent(next.session);
next.end.sessionDestroyed(event);
// just set session thread local
next.begin.sessionCreated(event);
}
try {
next.session.invalidate();
} finally {
if (next.begin != null) {
next.begin.sessionDestroyed(event);
}
}
}
use of javax.servlet.http.HttpSessionEvent in project tomee by apache.
the class HttpRequestImpl method getSession.
public HttpSession getSession(boolean create) {
if (session == null && create) {
// default is infinite *here* only
long timeout = -1;
if (contextPath != null) {
// TODO: webapp should be contextual, would need to normalize jaxws, jaxrs, servlet, jsf...before but would be better
final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
if (assembler != null) {
for (final AppInfo info : assembler.getDeployedApplications()) {
for (final WebAppInfo webApp : info.webApps) {
if (webApp.contextRoot.replace("/", "").equals(contextPath.replace("/", ""))) {
timeout = webApp.sessionTimeout;
}
}
}
}
}
final HttpSessionImpl impl = new HttpSessionImpl(contextPath, timeout) {
@Override
public void invalidate() {
super.invalidate();
HttpRequestImpl.this.session = null;
}
};
session = impl;
if (begin != null) {
begin.sessionCreated(new HttpSessionEvent(session));
session = new SessionInvalidateListener(session, begin);
}
// can call req.getSession() so do it after affectation + do it after cdi init
impl.callListeners();
final SessionManager sessionManager = SystemInstance.get().getComponent(SessionManager.class);
final SessionManager.SessionWrapper previous = sessionManager.newSession(begin, end, session, application);
if (previous != null) {
session = previous.session;
}
}
return session;
}
use of javax.servlet.http.HttpSessionEvent in project tomee by apache.
the class HttpSessionImpl method invalidate.
@Override
public void invalidate() {
if (!valid) {
return;
}
synchronized (this) {
if (!valid) {
return;
}
if (!listeners.isEmpty()) {
final HttpSessionEvent event = new HttpSessionEvent(this);
for (final HttpSessionListener o : listeners) {
try {
HttpSessionListener.class.cast(o).sessionDestroyed(event);
} catch (final Throwable th) {
// ignore, may be undeployed
}
}
}
final SessionManager sessionManager = SystemInstance.get().getComponent(SessionManager.class);
if (sessionManager != null) {
sessionManager.removeSession(sessionId);
}
valid = false;
}
}
Aggregations