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

org.wildfly.clustering.session.cache.affinity.SessionAffinityRegistryGroupMemberMapper 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.cache.affinity;

import java.util.Map;
import java.util.function.Function;

import org.wildfly.clustering.server.GroupMember;
import org.wildfly.clustering.server.registry.Registry;

/**
 * Uses a registry to map a group member to a string value.
 * @param  the group member type
 * @author Paul Ferraro
 */
public class SessionAffinityRegistryGroupMemberMapper implements Function {

	private final Registry registry;
	private final String localKey;

	public SessionAffinityRegistryGroupMemberMapper(Registry registry) {
		this.registry = registry;
		this.localKey = registry.getEntry(registry.getGroup().getLocalMember()).getKey();
	}

	@Override
	public String apply(M member) {
		Map.Entry entry = (member != null) ? this.registry.getEntry(member) : null;
		return (entry != null) ? entry.getKey() : this.localKey;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy