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

org.jboss.weld.bootstrap.BeanDeploymentArchiveMapping Maven / Gradle / Ivy

There is a newer version: 3.0.0.Alpha1
Show newest version
package org.jboss.weld.bootstrap;

import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.manager.BeanManagerImpl;

/**
 * @author Marko Luksa
 */
public class BeanDeploymentArchiveMapping {

    private final Map beanDeployments = new HashMap();
    private final ConcurrentMap beanManagers = new ConcurrentHashMap();


    public void put(BeanDeploymentArchive bda, BeanDeployment beanDeployment) {
        beanDeployments.put(bda, beanDeployment);
        beanManagers.put(bda, beanDeployment.getBeanManager());
    }

    public BeanDeployment getBeanDeployment(BeanDeploymentArchive bda) {
        return beanDeployments.get(bda);
    }

    public Collection getBeanDeployments() {
        return beanDeployments.values();
    }

    public ConcurrentMap getBdaToBeanManagerMap() {
        return beanManagers;
    }

    boolean isNonuniqueIdentifierDetected() {
        Set beanDeploymentArchiveIds = new HashSet<>();
        Set beanManagerIds = new HashSet<>();
        for (Entry entry : beanDeployments.entrySet()) {
            if (!beanDeploymentArchiveIds.add(entry.getKey().getId()) || !beanManagerIds.add(entry.getValue().getBeanManager().getId())) {
                return true;
            }
        }
        return false;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy