diff options
author | Borislav Kapukaranov | 2011-08-30 07:48:21 +0000 |
---|---|---|
committer | Borislav Kapukaranov | 2011-09-28 16:29:35 +0000 |
commit | 2b7a05447c2f5ae31841d0a50acd59a8c3f25f63 (patch) | |
tree | b9b61e4854548d2bf8f05358aac4749eda49c0fa /bundles | |
parent | 9f9628013ad7e27a94c25aebba0710f591b3d728 (diff) | |
download | rt.equinox.bundles-2b7a05447c2f5ae31841d0a50acd59a8c3f25f63.tar.gz rt.equinox.bundles-2b7a05447c2f5ae31841d0a50acd59a8c3f25f63.tar.xz rt.equinox.bundles-2b7a05447c2f5ae31841d0a50acd59a8c3f25f63.zip |
bug354655 - Added default assign region to the RegionDigraph API
Diffstat (limited to 'bundles')
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 3d15cae51..3d15cae51 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 db539e34b..db539e34b 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 c2a17aec3..81e4943fd 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 d9b3476c0..e170bd2ee 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 c9d17d68d..c9d17d68d 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 514222397..90171264c 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(); + } |