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

org.wildfly.clustering.ejb.cache.bean.DefaultImmutableBeanGroup Maven / Gradle / Ivy

Go to download

Contains code common to the wildfly-clustering-ejb-hotrod and wildfly-clustering-ejb-infinispan modules.

There is a newer version: 35.0.0.Final
Show newest version
/*
 * Copyright The WildFly Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package org.wildfly.clustering.ejb.cache.bean;

import java.util.Map;

import org.wildfly.clustering.ejb.bean.BeanInstance;

/**
 * A default {@link ImmutableBeanGroup} implementation based on a map of bean instances.
 * @author Paul Ferraro
 * @param  the bean identifier type
 * @param  the bean instance type
 */
public class DefaultImmutableBeanGroup> implements ImmutableBeanGroup {

    private final K id;
    private final Map instances;
    private final Runnable closeTask;

    public DefaultImmutableBeanGroup(K id, Map instances, Runnable closeTask) {
        this.id = id;
        this.instances = instances;
        this.closeTask = closeTask;
    }

    @Override
    public K getId() {
        return this.id;
    }

    @Override
    public boolean isEmpty() {
        return this.instances.isEmpty();
    }

    @Override
    public V getBeanInstance(K id) {
        return this.instances.get(id);
    }

    @Override
    public void close() {
        this.closeTask.run();
    }

    @Override
    public String toString() {
        return String.format("%s { %s -> %s }", this.getClass().getSimpleName(), this.id, this.instances.keySet());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy