View | Details | Raw Unified | Return to bug 346682
Collapse All | Expand All

(-)src/org/eclipse/equinox/internal/region/BundleIdBasedRegion.java (-1 / +18 lines)
Lines 105-116 Link Here
105
		if (this.bundleContext == null)
105
		if (this.bundleContext == null)
106
			throw new BundleException("This region is not connected to an OSGi Framework.", BundleException.INVALID_OPERATION); //$NON-NLS-1$
106
			throw new BundleException("This region is not connected to an OSGi Framework.", BundleException.INVALID_OPERATION); //$NON-NLS-1$
107
		setRegionThreadLocal();
107
		setRegionThreadLocal();
108
		Bundle installed = null;
108
		try {
109
		try {
109
			input = checkFileProtocol(location, input);
110
			input = checkFileProtocol(location, input);
110
			return this.bundleContext.installBundle(location + REGION_LOCATION_DELIMITER + this.regionName, input);
111
			installed = this.bundleContext.installBundle(location + REGION_LOCATION_DELIMITER + this.regionName, input);
111
		} finally {
112
		} finally {
112
			removeRegionThreadLocal();
113
			removeRegionThreadLocal();
113
		}
114
		}
115
116
		if (regionDigraph.getRegion(installed) == null) {
117
			// This bundle has been blacklisted; uninstall it
118
			BundleException dup = new BundleException("The symbolic name and version of the installed bundle already exists: " + installed.getSymbolicName() + " - " + installed.getVersion()); //$NON-NLS-1$ //$NON-NLS-2$
119
			try {
120
				installed.uninstall();
121
			} catch (BundleException e) {
122
				// ok, now we are in a bad state
123
				// we have a bundle we cannot uninstall!  
124
				// better make it part of the region or it will become part of the system region on restart
125
				addBundle(installed.getBundleId());
126
				throw new IllegalStateException("Error occurred cleaning up duplicate bundle.", e); //$NON-NLS-1$
127
			}
128
			throw dup;
129
		}
130
		return installed;
114
	}
131
	}
115
132
116
	private InputStream checkFileProtocol(String location, InputStream input) throws BundleException {
133
	private InputStream checkFileProtocol(String location, InputStream input) throws BundleException {
(-)src/org/eclipse/equinox/internal/region/hook/RegionBundleEventHook.java (+21 lines)
Lines 77-82 Link Here
77
		 */
77
		 */
78
		Region installRegion = this.threadLocal.get();
78
		Region installRegion = this.threadLocal.get();
79
		if (installRegion != null) {
79
		if (installRegion != null) {
80
			String bsn = eventBundle.getSymbolicName();
81
			if (bsn != null && bundleFindHook instanceof RegionBundleFindHook) {
82
				BundleContext context = originBundle.getBundleContext();
83
				if (context != null) {
84
					Bundle system = context.getBundle(Constants.SYSTEM_BUNDLE_LOCATION);
85
					BundleContext systemContext = system.getBundleContext();
86
					if (systemContext != null) {
87
						Bundle[] bundles = systemContext.getBundles();
88
						Collection<Bundle> candidates = new ArrayList<Bundle>(bundles.length);
89
						for (Bundle bundle : bundles) {
90
							candidates.add(bundle);
91
						}
92
						((RegionBundleFindHook) bundleFindHook).find(installRegion, candidates);
93
						for (Bundle bundle : candidates) {
94
							if (bsn.equals(bundle.getSymbolicName()) && eventBundle.getVersion().equals(bundle.getVersion())) {
95
								return;
96
							}
97
						}
98
					}
99
				}
100
			}
80
			try {
101
			try {
81
				installRegion.addBundle(eventBundle);
102
				installRegion.addBundle(eventBundle);
82
			} catch (BundleException e) {
103
			} catch (BundleException e) {
(-)src/org/eclipse/equinox/internal/region/hook/RegionBundleFindHook.java (-1 / +4 lines)
Lines 47-53 Link Here
47
			return;
47
			return;
48
		}
48
		}
49
49
50
		Region finderRegion = getRegion(context);
50
		find(getRegion(context), bundles);
51
	}
52
53
	void find(Region finderRegion, Collection<Bundle> bundles) {
51
		if (finderRegion == null) {
54
		if (finderRegion == null) {
52
			bundles.clear();
55
			bundles.clear();
53
			return;
56
			return;

Return to bug 346682