org.wildfly.clustering.session.cache.attributes.DetachedSessionAttributes Maven / Gradle / Ivy
/*
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.wildfly.clustering.session.cache.attributes;
import java.util.Collection;
import java.util.Set;
import java.util.function.Supplier;
import org.wildfly.clustering.cache.batch.Batch;
import org.wildfly.clustering.session.Session;
/**
* A {@link SessionAttributes} implementation for detached sessions.
* @param the session context type
* @param the batch type
* @author Paul Ferraro
*/
public class DetachedSessionAttributes implements SessionAttributes {
private final Supplier batchFactory;
private final Supplier> sessionFactory;
public DetachedSessionAttributes(Supplier batchFactory, Supplier> sessionFactory) {
this.batchFactory = batchFactory;
this.sessionFactory = sessionFactory;
}
@Override
public Set keySet() {
try (B batch = this.batchFactory.get()) {
try (Session session = this.sessionFactory.get()) {
return session.getAttributes().keySet();
}
}
}
@Override
public Set> entrySet() {
try (B batch = this.batchFactory.get()) {
try (Session session = this.sessionFactory.get()) {
return session.getAttributes().entrySet();
}
}
}
@Override
public Collection