aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBorislav Kapukaranov2011-08-30 03:48:21 (EDT)
committerBorislav Kapukaranov2011-09-28 12:29:35 (EDT)
commit2b7a05447c2f5ae31841d0a50acd59a8c3f25f63 (patch)
treeb9b61e4854548d2bf8f05358aac4749eda49c0fa
parent9f9628013ad7e27a94c25aebba0710f591b3d728 (diff)
downloadrt.equinox.bundles-2b7a05447c2f5ae31841d0a50acd59a8c3f25f63.zip
rt.equinox.bundles-2b7a05447c2f5ae31841d0a50acd59a8c3f25f63.tar.gz
rt.equinox.bundles-2b7a05447c2f5ae31841d0a50acd59a8c3f25f63.tar.bz2
bug354655 - Added default assign region to the RegionDigraph API
-rwxr-xr-x[-rw-r--r--]bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/internal/region/hook/RegionResolverHookTests.java0
-rwxr-xr-x[-rw-r--r--]bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/BundleIdBasedRegion.java0
-rw-r--r--bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionDigraph.java13
-rw-r--r--bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionBundleEventHook.java30
-rwxr-xr-x[-rw-r--r--]bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/region/Region.java0
-rw-r--r--bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/region/RegionDigraph.java20
6 files changed, 48 insertions, 15 deletions
diff --git a/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/internal/region/hook/RegionResolverHookTests.java b/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/internal/region/hook/RegionResolverHookTests.java
index 3d15cae..3d15cae 100644..100755
--- a/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/internal/region/hook/RegionResolverHookTests.java
+++ b/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/internal/region/hook/RegionResolverHookTests.java
diff --git a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/BundleIdBasedRegion.java b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/BundleIdBasedRegion.java
index db539e3..db539e3 100644..100755
--- a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/BundleIdBasedRegion.java
+++ b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/BundleIdBasedRegion.java
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 c2a17ae..81e4943 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
@@ -67,6 +67,8 @@ public final class StandardRegionDigraph implements RegionDigraph {
private long originTimeStamp;
private final AtomicLong timeStamp = new AtomicLong();
+ private volatile Region defaultAssignRegion;
+
StandardRegionDigraph(StandardRegionDigraph origin) throws BundleException {
this(null, null, origin);
@@ -459,4 +461,15 @@ public final class StandardRegionDigraph implements RegionDigraph {
public org.osgi.framework.hooks.service.FindHook getServiceFindHook() {
return serviceFindHook;
}
+
+ @Override
+ public void setDefaultAssignRegion(Region defaultRegion) {
+ this.defaultAssignRegion = defaultRegion;
+
+ }
+
+ @Override
+ public Region getDefaultAssignRegion() {
+ return this.defaultAssignRegion;
+ }
}
diff --git a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionBundleEventHook.java b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionBundleEventHook.java
index d9b3476..e170bd2 100644
--- a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionBundleEventHook.java
+++ b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionBundleEventHook.java
@@ -77,25 +77,29 @@ public final class RegionBundleEventHook implements EventHook {
*/
Region installRegion = this.threadLocal.get();
if (installRegion != null) {
- try {
- installRegion.addBundle(eventBundle);
- } catch (BundleException e) {
- e.printStackTrace();
- throw new RuntimeException("Bundle could not be added to region", e); //$NON-NLS-1$
- }
+ addBundleToRegion(eventBundle, installRegion);
} else {
- Region originRegion = this.regionDigraph.getRegion(originBundle);
- if (originRegion != null) {
- try {
- originRegion.addBundle(eventBundle);
- } catch (BundleException e) {
- e.printStackTrace();
- throw new RuntimeException("Bundle could not be added to region", e); //$NON-NLS-1$
+ Region defaultAssignRegion = this.regionDigraph.getDefaultAssignRegion();
+ if (defaultAssignRegion != null) {
+ addBundleToRegion(eventBundle, defaultAssignRegion);
+ } else {
+ Region originRegion = this.regionDigraph.getRegion(originBundle);
+ if (originRegion != null) {
+ addBundleToRegion(eventBundle, originRegion);
}
}
}
}
+ private void addBundleToRegion(Bundle eventBundle, Region region) {
+ try {
+ region.addBundle(eventBundle);
+ } catch (BundleException e) {
+ e.printStackTrace();
+ throw new RuntimeException("Bundle could not be added to region", e); //$NON-NLS-1$
+ }
+ }
+
private void bundleUninstalled(Bundle eventBundle) {
Region region = this.regionDigraph.getRegion(eventBundle);
if (region != null) {
diff --git a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/region/Region.java b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/region/Region.java
index c9d17d6..c9d17d6 100644..100755
--- a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/region/Region.java
+++ b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/region/Region.java
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 5142223..9017126 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,8 +12,7 @@
package org.eclipse.equinox.region;
import java.util.Set;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
+import org.osgi.framework.*;
import org.osgi.framework.hooks.resolver.ResolverHookFactory;
/**
@@ -216,4 +215,21 @@ public interface RegionDigraph extends Iterable<Region> {
*/
org.osgi.framework.hooks.service.FindHook getServiceFindHook();
+ /**
+ * Sets a {@link Region} as default one, where all bundles installed via {@link BundleContext} will be included.
+ * If the default {@link Region} isn't set newly installed bundles are assigned to their installer's region.
+ *
+ * @param defaultRegion the region where all bundles installed via {@link BundleContext} will be assigned to
+ */
+ void setDefaultAssignRegion(Region defaultRegion);
+
+ /**
+ * Gets the default {@link Region}, where all bundles installed via {@link BundleContext} are assigned.
+ * If the default {@link Region} isn't set newly installed bundles are assigned to their installer's region.
+ *
+ * @param defaultRegion the region where all bundles installed via {@link BundleContext} will be assigned to
+ * @return The default region to assign to or <b>null</b> if it isn't set
+ */
+ Region getDefaultAssignRegion();
+
}