
org.wildfly.clustering.session.cache.SessionFactory Maven / Gradle / Ivy
/*
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.wildfly.clustering.session.cache;
import java.time.Duration;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import org.wildfly.clustering.cache.BiCreator;
import org.wildfly.clustering.cache.Remover;
import org.wildfly.clustering.server.Registration;
import org.wildfly.clustering.session.Session;
import org.wildfly.clustering.session.cache.attributes.SessionAttributesFactory;
import org.wildfly.clustering.session.cache.metadata.SessionMetaDataFactory;
/**
* Factory for creating sessions. Encapsulates the cache mapping strategy for sessions.
* @param the deployment context type
* @param the meta-data value type
* @param the attributes value type
* @param the session context type
* @author Paul Ferraro
*/
public interface SessionFactory extends ImmutableSessionFactory, BiCreator, Remover, Registration {
@Override
SessionMetaDataFactory getMetaDataFactory();
@Override
SessionAttributesFactory getAttributesFactory();
@Override
default Map.Entry, CompletionStage> createEntry(String id, Duration context) {
return Map.entry(this.getMetaDataFactory().createValueAsync(id, context), this.getAttributesFactory().createValueAsync(id, null));
}
@Override
default CompletionStage removeAsync(String id) {
return CompletableFuture.allOf(this.getMetaDataFactory().removeAsync(id).toCompletableFuture(), this.getAttributesFactory().removeAsync(id).toCompletableFuture());
}
@Override
default CompletionStage purgeAsync(String id) {
return CompletableFuture.allOf(this.getMetaDataFactory().purgeAsync(id).toCompletableFuture(), this.getAttributesFactory().purgeAsync(id).toCompletableFuture());
}
Session createSession(String id, Map.Entry entry, DC context);
@Override
default void close() {
this.getMetaDataFactory().close();
this.getAttributesFactory().close();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy