Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 118520 | Differences between
and this patch

Collapse All | Expand All

(-)resolver/src/org/eclipse/osgi/internal/module/ResolverBundle.java (+15 lines)
Lines 39-44 Link Here
39
39
40
	private ResolverImpl resolver;
40
	private ResolverImpl resolver;
41
	private boolean newFragmentExports;
41
	private boolean newFragmentExports;
42
	private ArrayList refs;
42
43
43
	ResolverBundle(BundleDescription bundle, ResolverImpl resolver) {
44
	ResolverBundle(BundleDescription bundle, ResolverImpl resolver) {
44
		super(bundle);
45
		super(bundle);
Lines 48-53 Link Here
48
	}
49
	}
49
50
50
	void initialize(boolean useSelectedExports) {
51
	void initialize(boolean useSelectedExports) {
52
		if (getBundle().isSingleton())
53
			refs = new ArrayList();
51
		if (getBundle().getHost() != null) {
54
		if (getBundle().getHost() != null) {
52
			host = new BundleConstraint(this, getBundle().getHost());
55
			host = new BundleConstraint(this, getBundle().getHost());
53
			exports = new ResolverExport[0];
56
			exports = new ResolverExport[0];
Lines 440-443 Link Here
440
	ResolverImpl getResolver() {
443
	ResolverImpl getResolver() {
441
		return resolver;
444
		return resolver;
442
	}
445
	}
446
447
	void clearRefs() {
448
		if (refs != null)
449
			refs.clear();
450
	}
451
	void addRef(ResolverBundle ref) {
452
		if (refs != null && !refs.contains(ref))
453
			refs.add(ref);
454
	}
455
	int getRefs() {
456
		return refs == null ? 0 : refs.size();
457
	}
443
}
458
}
(-)resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java (-9 / +24 lines)
Lines 285-292 Link Here
285
		BundleConstraint hostConstraint = bundle.getHost();
285
		BundleConstraint hostConstraint = bundle.getHost();
286
		Object[] hosts = resolverBundles.get(hostConstraint.getVersionConstraint().getName());
286
		Object[] hosts = resolverBundles.get(hostConstraint.getVersionConstraint().getName());
287
		for (int i = 0; i < hosts.length; i++)
287
		for (int i = 0; i < hosts.length; i++)
288
			if (((ResolverBundle) hosts[i]).isResolvable() && hostConstraint.isSatisfiedBy((ResolverBundle) hosts[i]))
288
			if (((ResolverBundle) hosts[i]).isResolvable() && hostConstraint.isSatisfiedBy((ResolverBundle) hosts[i])) {
289
				((ResolverBundle) hosts[i]).addRef(bundle);
289
				resolverExports.put(((ResolverBundle) hosts[i]).attachFragment(bundle, true));
290
				resolverExports.put(((ResolverBundle) hosts[i]).attachFragment(bundle, true));
291
			}
290
	}
292
	}
291
293
292
	public synchronized void resolve(BundleDescription[] reRefresh, Dictionary[] platformProperties) {
294
	public synchronized void resolve(BundleDescription[] reRefresh, Dictionary[] platformProperties) {
Lines 344-349 Link Here
344
		for (int i = 0; i < bundles.length; i++) {
346
		for (int i = 0; i < bundles.length; i++) {
345
			state.removeResolverErrors(bundles[i].getBundle());
347
			state.removeResolverErrors(bundles[i].getBundle());
346
			bundles[i].setResolvable(isResolvable(bundles[i].getBundle(), platformProperties, rejectedSingletons));
348
			bundles[i].setResolvable(isResolvable(bundles[i].getBundle(), platformProperties, rejectedSingletons));
349
			bundles[i].clearRefs();
347
			groupingChecker.removeAllExportConstraints(bundles[i]);
350
			groupingChecker.removeAllExportConstraints(bundles[i]);
348
		}
351
		}
349
352
Lines 426-438 Link Here
426
				continue;
429
				continue;
427
			Object[] sameName = resolverBundles.get(bundleDesc.getName());
430
			Object[] sameName = resolverBundles.get(bundleDesc.getName());
428
			if (sameName.length > 1) { // Need to make a selection based off of num dependents
431
			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++) {
432
				for (int j = 0; j < sameName.length; j++) {
431
					BundleDescription sameNameDesc = ((VersionSupplier) sameName[j]).getBundle();
433
					BundleDescription sameNameDesc = ((VersionSupplier) sameName[j]).getBundle();
434
					ResolverBundle sameNameBundle = (ResolverBundle) sameName[j];
432
					if (sameName[j] == bundles[i] || !sameNameDesc.isSingleton() || !sameNameDesc.isResolved() || rejectedSingletons.contains(sameNameDesc))
435
					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
436
						continue; // Ignore the bundle we are selecting, non-singletons, and non-resolved
434
					result = true;
437
					result = true;
435
					if (sameNameDesc.getVersion().compareTo(bundleDesc.getVersion()) > 0 && (sameNameDesc.getDependents().length > 0 || numDeps == 0)) {
438
					if (sameNameDesc.getVersion().compareTo(bundleDesc.getVersion()) > 0 && sameNameBundle.getRefs() >= bundles[i].getRefs()) {
436
						// this bundle is not selected; add it to the rejected list
439
						// this bundle is not selected; add it to the rejected list
437
						if (!rejectedSingletons.contains(bundles[i].getBundle()))
440
						if (!rejectedSingletons.contains(bundles[i].getBundle()))
438
							rejectedSingletons.add(bundles[i].getBundle());
441
							rejectedSingletons.add(bundles[i].getBundle());
Lines 554-568 Link Here
554
			return true; // Already wired (due to grouping dependencies) so just return
557
			return true; // Already wired (due to grouping dependencies) so just return
555
		}
558
		}
556
		Object[] bundles = resolverBundles.get(req.getVersionConstraint().getName());
559
		Object[] bundles = resolverBundles.get(req.getVersionConstraint().getName());
560
		boolean result = false;
557
		for (int i = 0; i < bundles.length; i++) {
561
		for (int i = 0; i < bundles.length; i++) {
558
			ResolverBundle bundle = (ResolverBundle) bundles[i];
562
			ResolverBundle bundle = (ResolverBundle) bundles[i];
559
			if (DEBUG_REQUIRES)
563
			if (DEBUG_REQUIRES)
560
				ResolverImpl.log("CHECKING: " + bundle.getBundle()); //$NON-NLS-1$
564
				ResolverImpl.log("CHECKING: " + bundle.getBundle()); //$NON-NLS-1$
561
			// Check if export matches
565
			// Check if export matches
562
			if (req.isSatisfiedBy(bundle)) {
566
			if (req.isSatisfiedBy(bundle)) {
567
				bundle.addRef(req.getBundle());
568
				if (result)
569
					continue;
563
				req.setMatchingBundle(bundle); // Wire to the bundle
570
				req.setMatchingBundle(bundle); // Wire to the bundle
564
				if (req.getBundle() == bundle)
571
				if (req.getBundle() == bundle) {
565
					return true; // Wired to ourselves
572
					result = true; // Wired to ourselves
573
					continue;
574
				}
566
				if ((bundle.getState() != ResolverBundle.RESOLVED && !resolveBundle(bundle, cycle))) {
575
				if ((bundle.getState() != ResolverBundle.RESOLVED && !resolveBundle(bundle, cycle))) {
567
					req.setMatchingBundle(null);
576
					req.setMatchingBundle(null);
568
					continue; // Bundle hasn't resolved
577
					continue; // Bundle hasn't resolved
Lines 574-583 Link Here
574
						cycle.add(req.getBundle());
583
						cycle.add(req.getBundle());
575
				if (DEBUG_REQUIRES)
584
				if (DEBUG_REQUIRES)
576
					ResolverImpl.log("Found match: " + bundle.getBundle() + ". Wiring"); //$NON-NLS-1$ //$NON-NLS-2$
585
					ResolverImpl.log("Found match: " + bundle.getBundle() + ". Wiring"); //$NON-NLS-1$ //$NON-NLS-2$
577
				return checkRequiresConstraints(req, req.getMatchingBundle());
586
				result = checkRequiresConstraints(req, req.getMatchingBundle());
578
			}
587
			}
579
		}
588
		}
580
		if (req.isOptional())
589
		if (result || req.isOptional())
581
			return true; // If the req is optional then just return true
590
			return true; // If the req is optional then just return true
582
591
583
		return false;
592
		return false;
Lines 605-610 Link Here
605
				ResolverImpl.log("  - already wired"); //$NON-NLS-1$
614
				ResolverImpl.log("  - already wired"); //$NON-NLS-1$
606
			return true; // Already wired (due to grouping dependencies) so just return
615
			return true; // Already wired (due to grouping dependencies) so just return
607
		}
616
		}
617
		boolean result = false;
608
		Object[] exports = resolverExports.get(imp.getName());
618
		Object[] exports = resolverExports.get(imp.getName());
609
		exportsloop: for (int i = 0; i < exports.length; i++) {
619
		exportsloop: for (int i = 0; i < exports.length; i++) {
610
			ResolverExport export = (ResolverExport) exports[i];
620
			ResolverExport export = (ResolverExport) exports[i];
Lines 614-622 Link Here
614
			if (imp.isSatisfiedBy(export) && imp.isNotAnUnresolvableWiring(export)) {
624
			if (imp.isSatisfiedBy(export) && imp.isNotAnUnresolvableWiring(export)) {
615
				int originalState = export.getExporter().getState();
625
				int originalState = export.getExporter().getState();
616
				if (imp.isDynamic() && originalState != ResolverBundle.RESOLVED)
626
				if (imp.isDynamic() && originalState != ResolverBundle.RESOLVED)
617
					return false; // Must not attempt to resolve an exporter when dynamic
627
					continue; // Must not attempt to resolve an exporter when dynamic
618
				if (imp.getBundle() == export.getExporter() && !export.getExportPackageDescription().isRoot())
628
				if (imp.getBundle() == export.getExporter() && !export.getExportPackageDescription().isRoot())
619
					continue; // Can't wire to our own re-export
629
					continue; // Can't wire to our own re-export
630
				export.getExporter().addRef(imp.getBundle());
631
				if (result)
632
					continue;
620
				imp.setMatchingExport(export); // Wire the import to the export
633
				imp.setMatchingExport(export); // Wire the import to the export
621
				if (imp.getBundle() != export.getExporter()) {
634
				if (imp.getBundle() != export.getExporter()) {
622
					ResolverExport[] exps = imp.getBundle().getExports(imp.getName());
635
					ResolverExport[] exps = imp.getBundle().getExports(imp.getName());
Lines 651-657 Link Here
651
						}
664
						}
652
					if (DEBUG_IMPORTS)
665
					if (DEBUG_IMPORTS)
653
						ResolverImpl.log("Found match: " + export.getExporter() + ". Wiring " + imp.getBundle() + ":" + imp.getName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
666
						ResolverImpl.log("Found match: " + export.getExporter() + ". Wiring " + imp.getBundle() + ":" + imp.getName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
654
					return true;
667
					result = true;
655
				} else if (!imp.getBundle().isResolvable()) {
668
				} else if (!imp.getBundle().isResolvable()) {
656
					// If grouping has caused recursive calls to resolveImport, and the grouping has failed
669
					// 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
670
					// 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
674
					return true; // Grouping has changed the wiring, so return here
662
			}
675
			}
663
		}
676
		}
677
		if (result)
678
			return true;
664
		if (checkReexportsFromRequires && resolveImportReprovide(imp, cycle))
679
		if (checkReexportsFromRequires && resolveImportReprovide(imp, cycle))
665
			return true; // A reprovide satisfies imp
680
			return true; // A reprovide satisfies imp
666
		if (imp.isOptional())
681
		if (imp.isOptional())

Return to bug 118520