Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2008, 2010 VMware Inc. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: VMware Inc. - initial contribution /
 
 
 package org.eclipse.virgo.kernel.model.internal.bundle;
 
 import java.util.List;
 import java.util.Set;
 
 import  org.eclipse.equinox.region.RegionDigraph;
Implementation of org.eclipse.virgo.kernel.model.internal.DependencyDeterminer that returns the dependents of a Bundle. The dependents consist of any bundle that has been wired to as a result of Import-Package.

Concurrent Semantics
Threadsafe

 
 public final class BundleDependencyDeterminer implements DependencyDeterminer {
 
 
 
     private final RegionDigraph regionDigraph;
 
     public BundleDependencyDeterminer(@NonNull QuasiFrameworkFactory quasiFrameworkFactory, @NonNull RuntimeArtifactRepository artifactRepository,
         @NonNull RegionDigraph regionDigraph) {
         this. = quasiFrameworkFactory;
         this. = artifactRepository;
         this. = regionDigraph;
     }

    
 
     public Set<ArtifactgetDependents(Artifact rootArtifact) {
         if (!rootArtifact.getType().equalsIgnoreCase("bundle")) {
             return Collections.<ArtifactemptySet();
         }
 
         QuasiBundle rootBundle = getBundle(rootArtifact);
         if (rootBundle == null) {
             return Collections.<ArtifactemptySet();
         }
 
         Set<Artifactartifacts = new HashSet<Artifact>();
         for (QuasiImportPackage importPackage : rootBundle.getImportPackages()) {
             QuasiExportPackage provider = importPackage.getProvider();
             if (provider != null) {
                 QuasiBundle bundle = provider.getExportingBundle();
                 addDependentBundle(artifactsbundle);
             }
         }
 
         addDependents(artifactsrootBundle.getHosts());
         
         List<QuasiRequiredBundlerequiredBundles = rootBundle.getRequiredBundles();
         if (requiredBundles != null) {
             for (QuasiRequiredBundle requiredBundle : requiredBundles) {
                 addDependentBundle(artifactsrequiredBundle.getProvider());
             }
         }
 
         return artifacts;
     }
 
     public void addDependents(Set<ArtifactartifactsList<QuasiBundledependents) {
         if (dependents != null) {
             for (QuasiBundle dependent : dependents) {
                 addDependentBundle(artifactsdependent);
             }
         }
     }
 
     public void addDependentBundle(Set<ArtifactartifactsQuasiBundle bundle) {
         if (bundle != null) {
            Artifact artifact = .getArtifact(.bundle.getSymbolicName(), bundle.getVersion(),
                this..getRegion(bundle.getBundleId()));
            artifacts.add(artifact);
        }
    }
    private QuasiBundle getBundle(Artifact artifact) {
        QuasiFramework framework = .create();
        for (QuasiBundle bundle : framework.getBundles()) {
            if (artifact.getName().equals(bundle.getSymbolicName()) && artifact.getVersion().equals(bundle.getVersion())
                && artifact.getRegion().getName().equals(this..getRegion(bundle.getBundleId()).getName())) {
                return bundle;
            }
        }
        return null;
    }
New to GrepCode? Check out our FAQ X