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

org.wildfly.clustering.session.cache.affinity.RegistryGroupMemberMapper Maven / Gradle / Ivy

There is a newer version: 5.0.7.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.
 * @author Paul Ferraro
 */
public class RegistryGroupMemberMapper implements Function {

	private final Registry registry;
	private final String localKey;

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy