org.wildfly.clustering.session.cache.user.CompositeUser 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 org.wildfly.clustering.cache.CacheEntryRemover;
import org.wildfly.clustering.session.user.User;
import org.wildfly.clustering.session.user.UserSessions;
/**
* A user implementation composed of a context entry and user sessions.
* @param the persistent context type
* @param the transient context type
* @param the deployment type
* @param the session type
*/
public class CompositeUser implements User {
private final String id;
private final Map.Entry contextEntry;
private final UserSessions sessions;
private final CacheEntryRemover remover;
public CompositeUser(String id, Map.Entry contextEntry, UserSessions sessions, CacheEntryRemover remover) {
this.id = id;
this.contextEntry = contextEntry;
this.sessions = sessions;
this.remover = remover;
}
@Override
public String getId() {
return this.id;
}
@Override
public C getPersistentContext() {
return this.contextEntry.getKey();
}
@Override
public UserSessions getSessions() {
return this.sessions;
}
@Override
public void invalidate() {
this.remover.remove(this.id);
}
@Override
public T getTransientContext() {
return this.contextEntry.getValue();
}
}