private static void walkKnownBundleDependenciesDown()

in nbm-maven-plugin/src/main/java/org/apache/netbeans/nbm/CreateClusterAppMojo.java [1236:1276]


    private static void walkKnownBundleDependenciesDown( List<BundleTuple> known, List<BundleTuple> toProcess )
    {
        boolean atLeastOneWasFound = false;
        for ( Iterator<BundleTuple> it = toProcess.iterator(); it.hasNext(); )
        {
            BundleTuple bundleTuple = it.next();
            boolean found = false;
            for ( BundleTuple knownBT : known )
            {
                Sets.SetView<String> is = Sets.intersection( bundleTuple.manifest.getOsgiExports(), knownBT.manifest.
                                                             getOsgiImports() );
                if ( !is.isEmpty() )
                {
                    found = true;
                    bundleTuple.cluster = knownBT.cluster;
                    break;
                }
                //dependencyTokens are requireBundle - matches the module property
                is = Sets.intersection( Collections.singleton( bundleTuple.manifest.getModule() ), new HashSet(
                                        knownBT.manifest.getDependencyTokens() ) );
                if ( !is.isEmpty() )
                {
                    found = true;
                    bundleTuple.cluster = knownBT.cluster;
                    break;
                }

            }
            if ( found )
            {
                atLeastOneWasFound = true;
                it.remove();
                known.add( bundleTuple );
            }

        }
        if ( !toProcess.isEmpty() && atLeastOneWasFound )
        {
            walkKnownBundleDependenciesDown( known, toProcess );
        }
    }