Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2011-04-21 16:12:24 +0000
committerThomas Watson2011-04-21 16:12:24 +0000
commitfac97041c6f87bfde8b5c8ecbbf16b50a9909578 (patch)
tree8ec93ffaa192fc3749bab31e783e7db92b962969
parenta7703ea8e06fce5cbbb79ec017bc2bfcfe6d21b4 (diff)
downloadrt.equinox.bundles-fac97041c6f87bfde8b5c8ecbbf16b50a9909578.tar.gz
rt.equinox.bundles-fac97041c6f87bfde8b5c8ecbbf16b50a9909578.tar.xz
rt.equinox.bundles-fac97041c6f87bfde8b5c8ecbbf16b50a9909578.zip
Bug 343570 - [region] Need a way to access the hooks associated with a digraphv20110421-1700
-rw-r--r--bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/internal/region/StandardRegionDigraphTests.java20
-rw-r--r--bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/RegionManager.java22
-rw-r--r--bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionDigraph.java46
-rw-r--r--bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/region/RegionDigraph.java34
4 files changed, 107 insertions, 15 deletions
diff --git a/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/internal/region/StandardRegionDigraphTests.java b/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/internal/region/StandardRegionDigraphTests.java
index bda9b2825..69e5f279a 100644
--- a/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/internal/region/StandardRegionDigraphTests.java
+++ b/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/internal/region/StandardRegionDigraphTests.java
@@ -230,4 +230,24 @@ public class StandardRegionDigraphTests {
testDigraph.replace(testCopy);
StandardRegionDigraphPeristenceTests.assertEquals(testDigraph, testCopy);
}
+
+ @Test
+ public void testGetHooks() throws InvalidSyntaxException, BundleException {
+ setDefaultFilters();
+ replayMocks();
+
+ assertNotNull("Resolver Hook is null", digraph.getResolverHookFactory());
+ assertNotNull("Bundle Event Hook is null", digraph.getBundleEventHook());
+ assertNotNull("Bundle Find Hook is null", digraph.getBundleFindHook());
+ assertNotNull("Servie Event Hook is null", digraph.getServiceEventHook());
+ assertNotNull("Service Find Hook is null", digraph.getServiceFindHook());
+
+ RegionDigraph copy = digraph.copy();
+ assertNotNull("Resolver Hook is null", copy.getResolverHookFactory());
+ assertNotNull("Bundle Event Hook is null", copy.getBundleEventHook());
+ assertNotNull("Bundle Find Hook is null", copy.getBundleFindHook());
+ assertNotNull("Servie Event Hook is null", copy.getServiceEventHook());
+ assertNotNull("Service Find Hook is null", copy.getServiceFindHook());
+ }
+
}
diff --git a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/RegionManager.java b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/RegionManager.java
index a19c94deb..c1929b8f9 100644
--- a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/RegionManager.java
+++ b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/RegionManager.java
@@ -11,16 +11,12 @@
package org.eclipse.equinox.internal.region;
-import org.eclipse.equinox.internal.region.management.StandardManageableRegionDigraph;
-
-import org.eclipse.equinox.internal.region.hook.*;
-
-import org.eclipse.equinox.region.Region;
-import org.eclipse.equinox.region.RegionDigraph;
-
import java.io.*;
import java.util.ArrayList;
import java.util.Collection;
+import org.eclipse.equinox.internal.region.management.StandardManageableRegionDigraph;
+import org.eclipse.equinox.region.Region;
+import org.eclipse.equinox.region.RegionDigraph;
import org.osgi.framework.*;
import org.osgi.framework.hooks.bundle.EventHook;
import org.osgi.framework.hooks.bundle.FindHook;
@@ -121,15 +117,13 @@ public final class RegionManager implements BundleActivator {
}
private void registerRegionHooks(RegionDigraph regionDigraph) {
- registerResolverHookFactory(new RegionResolverHookFactory(regionDigraph));
+ registerResolverHookFactory(regionDigraph.getResolverHookFactory());
- RegionBundleFindHook bundleFindHook = new RegionBundleFindHook(regionDigraph, bundleContext.getBundle().getBundleId());
- registerBundleFindHook(bundleFindHook);
- registerBundleEventHook(new RegionBundleEventHook(regionDigraph, bundleFindHook, this.threadLocal));
+ registerBundleFindHook(regionDigraph.getBundleFindHook());
+ registerBundleEventHook(regionDigraph.getBundleEventHook());
- RegionServiceFindHook serviceFindHook = new RegionServiceFindHook(regionDigraph);
- registerServiceFindHook(serviceFindHook);
- registerServiceEventHook(new RegionServiceEventHook(serviceFindHook));
+ registerServiceFindHook(regionDigraph.getServiceFindHook());
+ registerServiceEventHook(regionDigraph.getServiceEventHook());
}
private void registerRegionDigraph(RegionDigraph regionDigraph) {
diff --git a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionDigraph.java b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionDigraph.java
index f3a7d2160..5110ad480 100644
--- a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionDigraph.java
+++ b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionDigraph.java
@@ -12,8 +12,12 @@
package org.eclipse.equinox.internal.region;
import java.util.*;
+import org.eclipse.equinox.internal.region.hook.*;
import org.eclipse.equinox.region.*;
import org.osgi.framework.*;
+import org.osgi.framework.hooks.bundle.EventHook;
+import org.osgi.framework.hooks.bundle.FindHook;
+import org.osgi.framework.hooks.resolver.ResolverHookFactory;
/**
* {@link StandardRegionDigraph} is the default implementation of {@link RegionDigraph}.
@@ -45,6 +49,13 @@ public final class StandardRegionDigraph implements RegionDigraph {
private final SubgraphTraverser subgraphTraverser;
+ private final org.osgi.framework.hooks.bundle.EventHook bundleEventHook;
+ private final org.osgi.framework.hooks.bundle.FindHook bundleFindHook;
+ @SuppressWarnings("deprecation")
+ private final org.osgi.framework.hooks.service.EventHook serviceEventHook;
+ private final org.osgi.framework.hooks.service.FindHook serviceFindHook;
+ private final ResolverHookFactory resolverHookFactory;
+
StandardRegionDigraph() {
this(null, null);
}
@@ -53,6 +64,15 @@ public final class StandardRegionDigraph implements RegionDigraph {
this.subgraphTraverser = new SubgraphTraverser();
this.bundleContext = bundleContext;
this.threadLocal = threadLocal;
+
+ // Note we are safely escaping this only because we know the hook impls
+ // do not escape the digraph to other threads on construction.
+ this.resolverHookFactory = new RegionResolverHookFactory(this);
+ this.bundleFindHook = new RegionBundleFindHook(this, bundleContext == null ? 0 : bundleContext.getBundle().getBundleId());
+ this.bundleEventHook = new RegionBundleEventHook(this, this.bundleFindHook, this.threadLocal);
+
+ this.serviceFindHook = new RegionServiceFindHook(this);
+ this.serviceEventHook = new RegionServiceEventHook(serviceFindHook);
}
/**
@@ -368,4 +388,30 @@ public final class StandardRegionDigraph implements RegionDigraph {
}
}
+ @Override
+ public ResolverHookFactory getResolverHookFactory() {
+ return resolverHookFactory;
+ }
+
+ @Override
+ public EventHook getBundleEventHook() {
+ return bundleEventHook;
+ }
+
+ @Override
+ public FindHook getBundleFindHook() {
+ return bundleFindHook;
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public org.osgi.framework.hooks.service.EventHook getServiceEventHook() {
+ return serviceEventHook;
+ }
+
+ @Override
+ public org.osgi.framework.hooks.service.FindHook getServiceFindHook() {
+ return serviceFindHook;
+ }
+
}
diff --git a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/region/RegionDigraph.java b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/region/RegionDigraph.java
index de1cee4e7..c543ec23e 100644
--- a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/region/RegionDigraph.java
+++ b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/region/RegionDigraph.java
@@ -12,9 +12,9 @@
package org.eclipse.equinox.region;
import java.util.Set;
-
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
+import org.osgi.framework.hooks.resolver.ResolverHookFactory;
/**
* {@link RegionDigraph} is a <a href="http://en.wikipedia.org/wiki/Directed_graph">directed graph</a>, or
@@ -180,4 +180,36 @@ public interface RegionDigraph extends Iterable<Region> {
* @throws BundleException if the digraph could not be replaced
*/
void replace(RegionDigraph digraph) throws BundleException;
+
+ /**
+ * Gets the resolver hook factory associated with this digraph.
+ * @return the resolver hook factory
+ */
+ ResolverHookFactory getResolverHookFactory();
+
+ /**
+ * Gets the bundle event hook associated with this digraph.
+ * @return the bundle event hook
+ */
+ org.osgi.framework.hooks.bundle.EventHook getBundleEventHook();
+
+ /**
+ * Gets the bundle find hook associated with this digraph.
+ * @return the bundle find hook
+ */
+ org.osgi.framework.hooks.bundle.FindHook getBundleFindHook();
+
+ /**
+ * Gets the service event hook associated with this digraph.
+ * @return the service event hook
+ */
+ @SuppressWarnings("deprecation")
+ org.osgi.framework.hooks.service.EventHook getServiceEventHook();
+
+ /**
+ * Gets the service find hook associated with this digraph.
+ * @return the service find hook
+ */
+ org.osgi.framework.hooks.service.FindHook getServiceFindHook();
+
}

Back to the top