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 343570
Collapse All | Expand All

(-)src/org/eclipse/equinox/internal/region/RegionManager.java (-15 / +9 lines)
Lines 11-26 Link Here
11
11
12
package org.eclipse.equinox.internal.region;
12
package org.eclipse.equinox.internal.region;
13
13
14
import org.eclipse.equinox.internal.region.management.StandardManageableRegionDigraph;
15
16
import org.eclipse.equinox.internal.region.hook.*;
17
18
import org.eclipse.equinox.region.Region;
19
import org.eclipse.equinox.region.RegionDigraph;
20
21
import java.io.*;
14
import java.io.*;
22
import java.util.ArrayList;
15
import java.util.ArrayList;
23
import java.util.Collection;
16
import java.util.Collection;
17
import org.eclipse.equinox.internal.region.management.StandardManageableRegionDigraph;
18
import org.eclipse.equinox.region.Region;
19
import org.eclipse.equinox.region.RegionDigraph;
24
import org.osgi.framework.*;
20
import org.osgi.framework.*;
25
import org.osgi.framework.hooks.bundle.EventHook;
21
import org.osgi.framework.hooks.bundle.EventHook;
26
import org.osgi.framework.hooks.bundle.FindHook;
22
import org.osgi.framework.hooks.bundle.FindHook;
Lines 121-135 Link Here
121
	}
117
	}
122
118
123
	private void registerRegionHooks(RegionDigraph regionDigraph) {
119
	private void registerRegionHooks(RegionDigraph regionDigraph) {
124
		registerResolverHookFactory(new RegionResolverHookFactory(regionDigraph));
120
		registerResolverHookFactory(regionDigraph.getResolverHookFactory());
121
122
		registerBundleFindHook(regionDigraph.getBundleFindHook());
123
		registerBundleEventHook(regionDigraph.getBundleEventHook());
125
124
126
		RegionBundleFindHook bundleFindHook = new RegionBundleFindHook(regionDigraph, bundleContext.getBundle().getBundleId());
125
		registerServiceFindHook(regionDigraph.getServiceFindHook());
127
		registerBundleFindHook(bundleFindHook);
126
		registerServiceEventHook(regionDigraph.getServiceEventHook());
128
		registerBundleEventHook(new RegionBundleEventHook(regionDigraph, bundleFindHook, this.threadLocal));
129
130
		RegionServiceFindHook serviceFindHook = new RegionServiceFindHook(regionDigraph);
131
		registerServiceFindHook(serviceFindHook);
132
		registerServiceEventHook(new RegionServiceEventHook(serviceFindHook));
133
	}
127
	}
134
128
135
	private void registerRegionDigraph(RegionDigraph regionDigraph) {
129
	private void registerRegionDigraph(RegionDigraph regionDigraph) {
(-)src/org/eclipse/equinox/internal/region/StandardRegionDigraph.java (+46 lines)
Lines 12-19 Link Here
12
package org.eclipse.equinox.internal.region;
12
package org.eclipse.equinox.internal.region;
13
13
14
import java.util.*;
14
import java.util.*;
15
import org.eclipse.equinox.internal.region.hook.*;
15
import org.eclipse.equinox.region.*;
16
import org.eclipse.equinox.region.*;
16
import org.osgi.framework.*;
17
import org.osgi.framework.*;
18
import org.osgi.framework.hooks.bundle.EventHook;
19
import org.osgi.framework.hooks.bundle.FindHook;
20
import org.osgi.framework.hooks.resolver.ResolverHookFactory;
17
21
18
/**
22
/**
19
 * {@link StandardRegionDigraph} is the default implementation of {@link RegionDigraph}.
23
 * {@link StandardRegionDigraph} is the default implementation of {@link RegionDigraph}.
Lines 45-50 Link Here
45
49
46
	private final SubgraphTraverser subgraphTraverser;
50
	private final SubgraphTraverser subgraphTraverser;
47
51
52
	private final org.osgi.framework.hooks.bundle.EventHook bundleEventHook;
53
	private final org.osgi.framework.hooks.bundle.FindHook bundleFindHook;
54
	@SuppressWarnings("deprecation")
55
	private final org.osgi.framework.hooks.service.EventHook serviceEventHook;
56
	private final org.osgi.framework.hooks.service.FindHook serviceFindHook;
57
	private final ResolverHookFactory resolverHookFactory;
58
48
	StandardRegionDigraph() {
59
	StandardRegionDigraph() {
49
		this(null, null);
60
		this(null, null);
50
	}
61
	}
Lines 53-58 Link Here
53
		this.subgraphTraverser = new SubgraphTraverser();
64
		this.subgraphTraverser = new SubgraphTraverser();
54
		this.bundleContext = bundleContext;
65
		this.bundleContext = bundleContext;
55
		this.threadLocal = threadLocal;
66
		this.threadLocal = threadLocal;
67
68
		// Note we are safely escaping this only because we know the hook impls
69
		// do not escape the digraph to other threads on construction.
70
		this.resolverHookFactory = new RegionResolverHookFactory(this);
71
		this.bundleFindHook = new RegionBundleFindHook(this, bundleContext == null ? 0 : bundleContext.getBundle().getBundleId());
72
		this.bundleEventHook = new RegionBundleEventHook(this, this.bundleFindHook, this.threadLocal);
73
74
		this.serviceFindHook = new RegionServiceFindHook(this);
75
		this.serviceEventHook = new RegionServiceEventHook(serviceFindHook);
56
	}
76
	}
57
77
58
	/**
78
	/**
Lines 368-371 Link Here
368
		}
388
		}
369
	}
389
	}
370
390
391
	@Override
392
	public ResolverHookFactory getResolverHookFactory() {
393
		return resolverHookFactory;
394
	}
395
396
	@Override
397
	public EventHook getBundleEventHook() {
398
		return bundleEventHook;
399
	}
400
401
	@Override
402
	public FindHook getBundleFindHook() {
403
		return bundleFindHook;
404
	}
405
406
	@SuppressWarnings("deprecation")
407
	@Override
408
	public org.osgi.framework.hooks.service.EventHook getServiceEventHook() {
409
		return serviceEventHook;
410
	}
411
412
	@Override
413
	public org.osgi.framework.hooks.service.FindHook getServiceFindHook() {
414
		return serviceFindHook;
415
	}
416
371
}
417
}
(-)src/org/eclipse/equinox/region/RegionDigraph.java (-1 / +33 lines)
Lines 12-20 Link Here
12
package org.eclipse.equinox.region;
12
package org.eclipse.equinox.region;
13
13
14
import java.util.Set;
14
import java.util.Set;
15
16
import org.osgi.framework.Bundle;
15
import org.osgi.framework.Bundle;
17
import org.osgi.framework.BundleException;
16
import org.osgi.framework.BundleException;
17
import org.osgi.framework.hooks.resolver.ResolverHookFactory;
18
18
19
/**
19
/**
20
 * {@link RegionDigraph} is a <a href="http://en.wikipedia.org/wiki/Directed_graph">directed graph</a>, or
20
 * {@link RegionDigraph} is a <a href="http://en.wikipedia.org/wiki/Directed_graph">directed graph</a>, or
Lines 180-183 Link Here
180
	 * @throws BundleException if the digraph could not be replaced
180
	 * @throws BundleException if the digraph could not be replaced
181
	 */
181
	 */
182
	void replace(RegionDigraph digraph) throws BundleException;
182
	void replace(RegionDigraph digraph) throws BundleException;
183
184
	/**
185
	 * Gets the resolver hook factory associated with this digraph.
186
	 * @return the resolver hook factory
187
	 */
188
	ResolverHookFactory getResolverHookFactory();
189
190
	/**
191
	 * Gets the bundle event hook associated with this digraph.
192
	 * @return the bundle event hook
193
	 */
194
	org.osgi.framework.hooks.bundle.EventHook getBundleEventHook();
195
196
	/**
197
	 * Gets the bundle find hook associated with this digraph.
198
	 * @return the bundle find hook
199
	 */
200
	org.osgi.framework.hooks.bundle.FindHook getBundleFindHook();
201
202
	/**
203
	 * Gets the service event hook associated with this digraph.
204
	 * @return the service event hook
205
	 */
206
	@SuppressWarnings("deprecation")
207
	org.osgi.framework.hooks.service.EventHook getServiceEventHook();
208
209
	/**
210
	 * Gets the service find hook associated with this digraph.
211
	 * @return the service find hook
212
	 */
213
	org.osgi.framework.hooks.service.FindHook getServiceFindHook();
214
183
}
215
}
(-)src/org/eclipse/equinox/internal/region/StandardRegionDigraphTests.java (+20 lines)
Lines 230-233 Link Here
230
		testDigraph.replace(testCopy);
230
		testDigraph.replace(testCopy);
231
		StandardRegionDigraphPeristenceTests.assertEquals(testDigraph, testCopy);
231
		StandardRegionDigraphPeristenceTests.assertEquals(testDigraph, testCopy);
232
	}
232
	}
233
234
	@Test
235
	public void testGetHooks() throws InvalidSyntaxException, BundleException {
236
		setDefaultFilters();
237
		replayMocks();
238
239
		assertNotNull("Resolver Hook is null", digraph.getResolverHookFactory());
240
		assertNotNull("Bundle Event Hook is null", digraph.getBundleEventHook());
241
		assertNotNull("Bundle Find Hook is null", digraph.getBundleFindHook());
242
		assertNotNull("Servie Event Hook is null", digraph.getServiceEventHook());
243
		assertNotNull("Service Find Hook is null", digraph.getServiceFindHook());
244
245
		RegionDigraph copy = digraph.copy();
246
		assertNotNull("Resolver Hook is null", copy.getResolverHookFactory());
247
		assertNotNull("Bundle Event Hook is null", copy.getBundleEventHook());
248
		assertNotNull("Bundle Find Hook is null", copy.getBundleFindHook());
249
		assertNotNull("Servie Event Hook is null", copy.getServiceEventHook());
250
		assertNotNull("Service Find Hook is null", copy.getServiceFindHook());
251
	}
252
233
}
253
}

Return to bug 343570