|
Lines 344-349
Link Here
|
| 344 |
for (int i = 0; i < bundles.length; i++) { |
344 |
for (int i = 0; i < bundles.length; i++) { |
| 345 |
state.removeResolverErrors(bundles[i].getBundle()); |
345 |
state.removeResolverErrors(bundles[i].getBundle()); |
| 346 |
bundles[i].setResolvable(isResolvable(bundles[i].getBundle(), platformProperties, rejectedSingletons)); |
346 |
bundles[i].setResolvable(isResolvable(bundles[i].getBundle(), platformProperties, rejectedSingletons)); |
|
|
347 |
bundles[i].clearRefs(); |
| 347 |
groupingChecker.removeAllExportConstraints(bundles[i]); |
348 |
groupingChecker.removeAllExportConstraints(bundles[i]); |
| 348 |
} |
349 |
} |
| 349 |
|
350 |
|
|
Lines 426-438
Link Here
|
| 426 |
continue; |
427 |
continue; |
| 427 |
Object[] sameName = resolverBundles.get(bundleDesc.getName()); |
428 |
Object[] sameName = resolverBundles.get(bundleDesc.getName()); |
| 428 |
if (sameName.length > 1) { // Need to make a selection based off of num dependents |
429 |
if (sameName.length > 1) { // Need to make a selection based off of num dependents |
| 429 |
int numDeps = bundleDesc.getDependents().length; |
|
|
| 430 |
for (int j = 0; j < sameName.length; j++) { |
430 |
for (int j = 0; j < sameName.length; j++) { |
| 431 |
BundleDescription sameNameDesc = ((VersionSupplier) sameName[j]).getBundle(); |
431 |
BundleDescription sameNameDesc = ((VersionSupplier) sameName[j]).getBundle(); |
|
|
432 |
ResolverBundle sameNameBundle = (ResolverBundle) sameName[j]; |
| 432 |
if (sameName[j] == bundles[i] || !sameNameDesc.isSingleton() || !sameNameDesc.isResolved() || rejectedSingletons.contains(sameNameDesc)) |
433 |
if (sameName[j] == bundles[i] || !sameNameDesc.isSingleton() || !sameNameDesc.isResolved() || rejectedSingletons.contains(sameNameDesc)) |
| 433 |
continue; // Ignore the bundle we are selecting, non-singletons, and non-resolved |
434 |
continue; // Ignore the bundle we are selecting, non-singletons, and non-resolved |
| 434 |
result = true; |
435 |
result = true; |
| 435 |
if (sameNameDesc.getVersion().compareTo(bundleDesc.getVersion()) > 0 && (sameNameDesc.getDependents().length > 0 || numDeps == 0)) { |
436 |
if (sameNameDesc.getVersion().compareTo(bundleDesc.getVersion()) > 0 && sameNameBundle.getRefs() >= bundles[i].getRefs()) { |
| 436 |
// this bundle is not selected; add it to the rejected list |
437 |
// this bundle is not selected; add it to the rejected list |
| 437 |
if (!rejectedSingletons.contains(bundles[i].getBundle())) |
438 |
if (!rejectedSingletons.contains(bundles[i].getBundle())) |
| 438 |
rejectedSingletons.add(bundles[i].getBundle()); |
439 |
rejectedSingletons.add(bundles[i].getBundle()); |
|
Lines 554-568
Link Here
|
| 554 |
return true; // Already wired (due to grouping dependencies) so just return |
555 |
return true; // Already wired (due to grouping dependencies) so just return |
| 555 |
} |
556 |
} |
| 556 |
Object[] bundles = resolverBundles.get(req.getVersionConstraint().getName()); |
557 |
Object[] bundles = resolverBundles.get(req.getVersionConstraint().getName()); |
|
|
558 |
boolean result = false; |
| 557 |
for (int i = 0; i < bundles.length; i++) { |
559 |
for (int i = 0; i < bundles.length; i++) { |
| 558 |
ResolverBundle bundle = (ResolverBundle) bundles[i]; |
560 |
ResolverBundle bundle = (ResolverBundle) bundles[i]; |
| 559 |
if (DEBUG_REQUIRES) |
561 |
if (DEBUG_REQUIRES) |
| 560 |
ResolverImpl.log("CHECKING: " + bundle.getBundle()); //$NON-NLS-1$ |
562 |
ResolverImpl.log("CHECKING: " + bundle.getBundle()); //$NON-NLS-1$ |
| 561 |
// Check if export matches |
563 |
// Check if export matches |
| 562 |
if (req.isSatisfiedBy(bundle)) { |
564 |
if (req.isSatisfiedBy(bundle)) { |
|
|
565 |
bundle.addRef(req.getBundle()); |
| 566 |
if (result) |
| 567 |
continue; |
| 563 |
req.setMatchingBundle(bundle); // Wire to the bundle |
568 |
req.setMatchingBundle(bundle); // Wire to the bundle |
| 564 |
if (req.getBundle() == bundle) |
569 |
if (req.getBundle() == bundle) { |
| 565 |
return true; // Wired to ourselves |
570 |
result = true; // Wired to ourselves |
|
|
571 |
continue; |
| 572 |
} |
| 566 |
if ((bundle.getState() != ResolverBundle.RESOLVED && !resolveBundle(bundle, cycle))) { |
573 |
if ((bundle.getState() != ResolverBundle.RESOLVED && !resolveBundle(bundle, cycle))) { |
| 567 |
req.setMatchingBundle(null); |
574 |
req.setMatchingBundle(null); |
| 568 |
continue; // Bundle hasn't resolved |
575 |
continue; // Bundle hasn't resolved |
|
Lines 574-583
Link Here
|
| 574 |
cycle.add(req.getBundle()); |
581 |
cycle.add(req.getBundle()); |
| 575 |
if (DEBUG_REQUIRES) |
582 |
if (DEBUG_REQUIRES) |
| 576 |
ResolverImpl.log("Found match: " + bundle.getBundle() + ". Wiring"); //$NON-NLS-1$ //$NON-NLS-2$ |
583 |
ResolverImpl.log("Found match: " + bundle.getBundle() + ". Wiring"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 577 |
return checkRequiresConstraints(req, req.getMatchingBundle()); |
584 |
result = checkRequiresConstraints(req, req.getMatchingBundle()); |
| 578 |
} |
585 |
} |
| 579 |
} |
586 |
} |
| 580 |
if (req.isOptional()) |
587 |
if (result || req.isOptional()) |
| 581 |
return true; // If the req is optional then just return true |
588 |
return true; // If the req is optional then just return true |
| 582 |
|
589 |
|
| 583 |
return false; |
590 |
return false; |
|
Lines 605-610
Link Here
|
| 605 |
ResolverImpl.log(" - already wired"); //$NON-NLS-1$ |
612 |
ResolverImpl.log(" - already wired"); //$NON-NLS-1$ |
| 606 |
return true; // Already wired (due to grouping dependencies) so just return |
613 |
return true; // Already wired (due to grouping dependencies) so just return |
| 607 |
} |
614 |
} |
|
|
615 |
boolean result = false; |
| 608 |
Object[] exports = resolverExports.get(imp.getName()); |
616 |
Object[] exports = resolverExports.get(imp.getName()); |
| 609 |
exportsloop: for (int i = 0; i < exports.length; i++) { |
617 |
exportsloop: for (int i = 0; i < exports.length; i++) { |
| 610 |
ResolverExport export = (ResolverExport) exports[i]; |
618 |
ResolverExport export = (ResolverExport) exports[i]; |
|
Lines 614-622
Link Here
|
| 614 |
if (imp.isSatisfiedBy(export) && imp.isNotAnUnresolvableWiring(export)) { |
622 |
if (imp.isSatisfiedBy(export) && imp.isNotAnUnresolvableWiring(export)) { |
| 615 |
int originalState = export.getExporter().getState(); |
623 |
int originalState = export.getExporter().getState(); |
| 616 |
if (imp.isDynamic() && originalState != ResolverBundle.RESOLVED) |
624 |
if (imp.isDynamic() && originalState != ResolverBundle.RESOLVED) |
| 617 |
return false; // Must not attempt to resolve an exporter when dynamic |
625 |
continue; // Must not attempt to resolve an exporter when dynamic |
| 618 |
if (imp.getBundle() == export.getExporter() && !export.getExportPackageDescription().isRoot()) |
626 |
if (imp.getBundle() == export.getExporter() && !export.getExportPackageDescription().isRoot()) |
| 619 |
continue; // Can't wire to our own re-export |
627 |
continue; // Can't wire to our own re-export |
|
|
628 |
export.getExporter().addRef(imp.getBundle()); |
| 629 |
if (result) |
| 630 |
continue; |
| 620 |
imp.setMatchingExport(export); // Wire the import to the export |
631 |
imp.setMatchingExport(export); // Wire the import to the export |
| 621 |
if (imp.getBundle() != export.getExporter()) { |
632 |
if (imp.getBundle() != export.getExporter()) { |
| 622 |
ResolverExport[] exps = imp.getBundle().getExports(imp.getName()); |
633 |
ResolverExport[] exps = imp.getBundle().getExports(imp.getName()); |
|
Lines 651-657
Link Here
|
| 651 |
} |
662 |
} |
| 652 |
if (DEBUG_IMPORTS) |
663 |
if (DEBUG_IMPORTS) |
| 653 |
ResolverImpl.log("Found match: " + export.getExporter() + ". Wiring " + imp.getBundle() + ":" + imp.getName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
664 |
ResolverImpl.log("Found match: " + export.getExporter() + ". Wiring " + imp.getBundle() + ":" + imp.getName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
| 654 |
return true; |
665 |
result = true; |
| 655 |
} else if (!imp.getBundle().isResolvable()) { |
666 |
} else if (!imp.getBundle().isResolvable()) { |
| 656 |
// If grouping has caused recursive calls to resolveImport, and the grouping has failed |
667 |
// If grouping has caused recursive calls to resolveImport, and the grouping has failed |
| 657 |
// then we need to catch that here, so we don't continue trying to wire here |
668 |
// then we need to catch that here, so we don't continue trying to wire here |
|
Lines 661-666
Link Here
|
| 661 |
return true; // Grouping has changed the wiring, so return here |
672 |
return true; // Grouping has changed the wiring, so return here |
| 662 |
} |
673 |
} |
| 663 |
} |
674 |
} |
|
|
675 |
if (result) |
| 676 |
return true; |
| 664 |
if (checkReexportsFromRequires && resolveImportReprovide(imp, cycle)) |
677 |
if (checkReexportsFromRequires && resolveImportReprovide(imp, cycle)) |
| 665 |
return true; // A reprovide satisfies imp |
678 |
return true; // A reprovide satisfies imp |
| 666 |
if (imp.isOptional()) |
679 |
if (imp.isOptional()) |