use of org.wildfly.clustering.ee.BatchContext in project wildfly by wildfly.
the class DistributableSession method setMaxInactiveInterval.
@Override
public void setMaxInactiveInterval(int interval) {
Session<LocalSessionContext> session = this.entry.getKey();
validate(session);
try (BatchContext context = this.manager.getSessionManager().getBatcher().resumeBatch(this.batch)) {
session.getMetaData().setMaxInactiveInterval(Duration.ofSeconds(interval));
}
}
use of org.wildfly.clustering.ee.BatchContext in project wildfly by wildfly.
the class DistributableSession method getLastAccessedTime.
@Override
public long getLastAccessedTime() {
Session<LocalSessionContext> session = this.entry.getKey();
validate(session);
try (BatchContext context = this.manager.getSessionManager().getBatcher().resumeBatch(this.batch)) {
return session.getMetaData().getLastAccessedTime().toEpochMilli();
}
}
use of org.wildfly.clustering.ee.BatchContext in project wildfly by wildfly.
the class DistributableSession method setAttribute.
@Override
public Object setAttribute(String name, Object value) {
if (value == null) {
return this.removeAttribute(name);
}
Session<LocalSessionContext> session = this.entry.getKey();
validate(session);
try (BatchContext context = this.manager.getSessionManager().getBatcher().resumeBatch(this.batch)) {
if (CachedAuthenticatedSessionHandler.ATTRIBUTE_NAME.equals(name)) {
AuthenticatedSession auth = (AuthenticatedSession) value;
return AUTO_REAUTHENTICATING_MECHANISMS.contains(auth.getMechanism()) ? this.setLocalContext(auth) : session.getAttributes().setAttribute(name, new ImmutableAuthenticatedSession(auth));
}
Object old = session.getAttributes().setAttribute(name, value);
if (old == null) {
this.manager.getSessionListeners().attributeAdded(this, name, value);
} else if (old != value) {
this.manager.getSessionListeners().attributeUpdated(this, name, value, old);
}
return old;
}
}
use of org.wildfly.clustering.ee.BatchContext in project wildfly by wildfly.
the class DistributableSession method changeSessionId.
@Override
public String changeSessionId(HttpServerExchange exchange, SessionConfig config) {
Session<LocalSessionContext> oldSession = this.entry.getKey();
validate(oldSession);
SessionManager<LocalSessionContext, Batch> manager = this.manager.getSessionManager();
String id = manager.createIdentifier();
try (BatchContext context = this.manager.getSessionManager().getBatcher().resumeBatch(this.batch)) {
Session<LocalSessionContext> newSession = manager.createSession(id);
for (String name : oldSession.getAttributes().getAttributeNames()) {
newSession.getAttributes().setAttribute(name, oldSession.getAttributes().getAttribute(name));
}
newSession.getMetaData().setMaxInactiveInterval(oldSession.getMetaData().getMaxInactiveInterval());
newSession.getMetaData().setLastAccessedTime(oldSession.getMetaData().getLastAccessedTime());
newSession.getLocalContext().setAuthenticatedSession(oldSession.getLocalContext().getAuthenticatedSession());
config.setSessionId(exchange, id);
this.entry = new SimpleImmutableEntry<>(newSession, config);
oldSession.invalidate();
}
// Invoke listeners outside of the context of the batch associated with this session
this.manager.getSessionListeners().sessionIdChanged(this, oldSession.getId());
return id;
}
use of org.wildfly.clustering.ee.BatchContext in project wildfly by wildfly.
the class DistributableSession method getMaxInactiveInterval.
@Override
public int getMaxInactiveInterval() {
Session<LocalSessionContext> session = this.entry.getKey();
validate(session);
try (BatchContext context = this.manager.getSessionManager().getBatcher().resumeBatch(this.batch)) {
return (int) session.getMetaData().getMaxInactiveInterval().getSeconds();
}
}
Aggregations