
org.wildfly.clustering.session.cache.user.DefaultUserManager Maven / Gradle / Ivy
/*
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.wildfly.clustering.session.cache.user;
import java.util.Map;
import java.util.function.Supplier;
import org.wildfly.clustering.cache.batch.Batch;
import org.wildfly.clustering.cache.batch.Batcher;
import org.wildfly.clustering.server.manager.IdentifierFactory;
import org.wildfly.clustering.session.user.User;
import org.wildfly.clustering.session.user.UserManager;
/**
* A default user manager implementation that delegates to a user factory.
* @param the user context value type
* @param the persistent context type
* @param the transient context type
* @param the user sessions value type
* @param the deployment type
* @param the session type
* @param the batch type
*/
public class DefaultUserManager implements UserManager {
private final UserFactory factory;
private final Batcher batcher;
private final IdentifierFactory identifierFactory;
public DefaultUserManager(UserFactory factory, IdentifierFactory identifierFactory, Batcher batcher) {
this.factory = factory;
this.batcher = batcher;
this.identifierFactory = identifierFactory;
}
@Override
public User createUser(String id, C context) {
Map.Entry value = this.factory.createValue(id, context);
return this.factory.createUser(id, value);
}
@Override
public User findUser(String id) {
Map.Entry value = this.factory.findValue(id);
return (value != null) ? this.factory.createUser(id, value) : null;
}
@Override
public Batcher getBatcher() {
return this.batcher;
}
@Override
public Supplier getIdentifierFactory() {
return this.identifierFactory;
}
@Override
public void start() {
this.identifierFactory.start();
}
@Override
public void stop() {
this.identifierFactory.stop();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy