Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jboss.weld.bootstrap;
 
 import java.util.Set;
 
 
A Deployment visitor which can find the transitive closure of Bean Deployment Archives

Author(s):
pmuir
public class DeploymentVisitor {
    private final BeanManagerImpl deploymentManager;
    private final Environment environment;
    private final Deployment deployment;
    private final BeanDeploymentArchiveMapping bdaMapping;
    private final Collection<ContextHolder<? extends Context>> contexts;
    public DeploymentVisitor(BeanManagerImpl deploymentManagerEnvironment environmentfinal Deployment deployment,
                             Collection<ContextHolder<? extends Context>> contexts,
                             BeanDeploymentArchiveMapping bdaMapping) {
        this. = deploymentManager;
        this. = environment;
        this. = deployment;
        this. = contexts;
        this. = bdaMapping;
    }
    public void visit() {
        Set<BeanDeploymentArchiveseenBeanDeploymentArchives = new HashSet<BeanDeploymentArchive>();
        for (BeanDeploymentArchive archive : .getBeanDeploymentArchives()) {
            if (!seenBeanDeploymentArchives.contains(archive)) {
                visit(archiveseenBeanDeploymentArchives);
            }
        }
    }
    private BeanDeployment visit(BeanDeploymentArchive bdaSet<BeanDeploymentArchiveseenBeanDeploymentArchives) {
        copyService(bdaResourceLoader.class);
        // Check that the required services are specified
        // Check the id is not null
        if (bda.getId() == null) {
            throw ..deploymentArchiveNull(bda);
        }
        BeanDeployment parent = .getBeanDeployment(bda);
        if (parent == null) {
            // Create the BeanDeployment
            parent = new BeanDeployment(bda.getServices(), );
            // Attach it
            .put(bdaparent);
        }
        seenBeanDeploymentArchives.add(bda);
        for (BeanDeploymentArchive archive : bda.getBeanDeploymentArchives()) {
            BeanDeployment child;
            // Cut any circularities
            if (!seenBeanDeploymentArchives.contains(archive)) {
                child = visit(archiveseenBeanDeploymentArchives);
            } else {
                // already visited
                child = .getBeanDeployment(archive);
            }
            parent.getBeanManager().addAccessibleBeanManager(child.getBeanManager());
        }
        return parent;
    }
    private <T extends Servicevoid copyService(BeanDeploymentArchive archiveClass<T> serviceClass) {
        // for certain services we can fall back to deployment-level settings or defaults
        ServiceRegistry registry = archive.getServices();
        if (!registry.contains(serviceClass)) {
            T service = .getServices().get(serviceClass);
            if (service != null) {
                registry.add(serviceClassservice);
            }
        }
    }
New to GrepCode? Check out our FAQ X