All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wildfly.clustering.session.infinispan.remote.HotRodSessionManager Maven / Gradle / Ivy

There is a newer version: 4.0.0.Final
Show newest version
/*
 * Copyright The WildFly Authors
 * SPDX-License-Identifier: Apache-2.0
 */
package org.wildfly.clustering.session.infinispan.remote;

import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Supplier;

import org.wildfly.clustering.cache.batch.Batch;
import org.wildfly.clustering.server.Registrar;
import org.wildfly.clustering.server.Registration;
import org.wildfly.clustering.session.ImmutableSession;
import org.wildfly.clustering.session.SessionManagerConfiguration;
import org.wildfly.clustering.session.cache.AbstractSessionManager;
import org.wildfly.clustering.session.cache.SessionFactory;
import org.wildfly.common.function.Functions;

/**
 * Generic HotRod-based session manager implementation - independent of cache mapping strategy.
 * @param  the session manager context type
 * @param  the meta-data value type
 * @param  the attributes value type
 * @param  the session context type
 * @author Paul Ferraro
 */
public class HotRodSessionManager extends AbstractSessionManager {
	private final Registrar> expirationListenerRegistrar;
	private final Consumer expirationListener;
	private final Supplier batchFactory;

	private volatile Registration expirationListenerRegistration;

	public HotRodSessionManager(SessionManagerConfiguration configuration, SessionFactory factory, HotRodSessionManagerConfiguration hotrod) {
		super(configuration, hotrod, factory, Functions.discardingConsumer());
		this.expirationListenerRegistrar = hotrod.getExpirationListenerRegistrar();
		this.expirationListener = configuration.getExpirationListener();
		this.batchFactory = hotrod.getBatchFactory();
	}

	@Override
	public void start() {
		this.expirationListenerRegistration = this.expirationListenerRegistrar.register(this.expirationListener);
	}

	@Override
	public void stop() {
		if (this.expirationListenerRegistration != null) {
			this.expirationListenerRegistration.close();
		}
	}

	@Override
	public Supplier getBatchFactory() {
		return this.batchFactory;
	}

	@Override
	public Set getActiveSessions() {
		return Set.of();
	}

	@Override
	public Set getSessions() {
		return Set.of();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy