Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2011-05-11 05:54:19 -0400
committerGlyn Normington2011-05-11 05:54:19 -0400
commit9274e509cec65ae140bbb606452cfec09b99995e (patch)
treee6d51c4c00fd6792ec38973d0ef4a7ac9ce811ac
parent145ff0c85ffd02a3976d442fe6a48c8ea7b616bd (diff)
downloadorg.eclipse.virgo.kernel-9274e509cec65ae140bbb606452cfec09b99995e.tar.gz
org.eclipse.virgo.kernel-9274e509cec65ae140bbb606452cfec09b99995e.tar.xz
org.eclipse.virgo.kernel-9274e509cec65ae140bbb606452cfec09b99995e.zip
bug 343364: switch to using Equinox region digraph
-rw-r--r--build-kernel/config/org.eclipse.virgo.kernel.userregion.properties5
-rw-r--r--org.eclipse.virgo.kernel.agent.dm/.classpath1
-rw-r--r--org.eclipse.virgo.kernel.agent.dm/ivy.xml1
-rw-r--r--org.eclipse.virgo.kernel.agent.dm/src/main/java/org/eclipse/virgo/kernel/agent/dm/internal/DeployerFailureListener.java4
-rw-r--r--org.eclipse.virgo.kernel.agent.dm/template.mf3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/.classpath1
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/NestedPlanIntegrationTests.java2
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMDeploymentIntegrationTests.java9
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/no.heap.dump.test.config.properties1
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/spring256.test.config.properties1
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/test.config.properties1
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties5
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/resources/META-INF/spring/internal-osgi-context.xml4
-rw-r--r--org.eclipse.virgo.kernel.deployer/template.mf1
-rw-r--r--org.eclipse.virgo.kernel.model/.classpath1
-rw-r--r--org.eclipse.virgo.kernel.model/ivy.xml1
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/Artifact.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/RuntimeArtifactRepository.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/AbstractArtifact.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/NotifyingRuntimeArtifactRepository.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleArtifact.java5
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminer.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListener.java8
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializer.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerArtifact.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerBundleArtifact.java7
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListener.java12
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerInitializer.java14
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/ManageableArtifact.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/RuntimeArtifactModelObjectNameCreator.java3
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DefaultRuntimeArtifactModelObjectNameCreator.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableArtifact.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/osgi-context.xml2
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubArtifactRepository.java4
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubCompositeArtifact.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/NotifyingArtifactRepositoryTests.java16
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleArtifactTests.java13
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java6
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializerTests.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerTests.java13
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerInitializerTests.java11
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerTests.java10
-rw-r--r--org.eclipse.virgo.kernel.model/template.mf1
-rw-r--r--org.eclipse.virgo.kernel.osgi/.springBeans2
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/Region.java192
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraph.java159
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraphPersistence.java55
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraphVisitor.java50
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionFilter.java120
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionFilterBuilder.java49
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionManager.java142
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleEventHook.java115
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleFindHook.java94
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionDigraphVisitorBase.java141
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionResolverHook.java184
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionResolverHookFactory.java45
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionServiceEventHook.java70
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionServiceFindHook.java90
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/BundleIdBasedRegion.java289
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/RegionLifecycleListener.java42
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraph.java340
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraphPersistence.java212
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionFilter.java149
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionFilterBuilder.java84
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/SubgraphTraverser.java63
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/ManageableRegion.java49
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/ManageableRegionDigraph.java43
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/internal/RegionObjectNameCreator.java43
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/internal/StandardManageableRegion.java83
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/internal/StandardManageableRegionDigraph.java164
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/resources/META-INF/spring/internal-osgi-context.xml3
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/resources/META-INF/spring/osgi-framework-context.xml11
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/RegionManagerTests.java45
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleEventHookTests.java93
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleFindHookTests.java263
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionResolverHookTests.java547
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionServiceEventHookTests.java91
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionServiceFindHookTests.java285
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/internal/BundleIdBasedRegionTests.java307
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraphPeristenceTests.java283
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraphTests.java190
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionFilterTests.java191
-rw-r--r--org.eclipse.virgo.kernel.shell/.classpath1
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/AbstractInstallArtifactBasedCommands.java4
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/BundleCommands.java2
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/util/ArtifactRetriever.java5
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/model/helper/StandardRamAccessorHelper.java4
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateService.java2
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/resources/META-INF/spring/osgi-context.xml2
-rw-r--r--org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/commands/StubRuntimeArtifactModelObjectNameCreator.java5
-rw-r--r--org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateServiceTests.java6
-rw-r--r--org.eclipse.virgo.kernel.shell/template.mf1
-rw-r--r--org.eclipse.virgo.kernel.test/.classpath1
-rw-r--r--org.eclipse.virgo.kernel.test/src/test/java/org/eclipse/virgo/kernel/osgi/test/RegionTests.java2
-rw-r--r--org.eclipse.virgo.kernel.test/src/test/resources/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.virgo.kernel.test/src/test/resources/META-INF/test.config.properties1
-rw-r--r--org.eclipse.virgo.kernel.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties5
-rw-r--r--org.eclipse.virgo.kernel.userregion/.classpath1
-rw-r--r--org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/Activator.java12
-rw-r--r--org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/RegionDigraphDumpContributor.java2
-rw-r--r--org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/DependencyCalculator.java6
-rw-r--r--org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFramework.java9
-rw-r--r--org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFrameworkFactory.java4
-rw-r--r--org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/AbstractOsgiFrameworkLaunchingTests.java6
-rw-r--r--org.eclipse.virgo.kernel.userregion/template.mf2
-rw-r--r--org.eclipse.virgo.kernel.userregionfactory/.classpath1
-rw-r--r--org.eclipse.virgo.kernel.userregionfactory/src/main/java/org/eclipse/virgo/kernel/userregionfactory/Activator.java12
-rw-r--r--org.eclipse.virgo.kernel.userregionfactory/template.mf3
109 files changed, 150 insertions, 5521 deletions
diff --git a/build-kernel/config/org.eclipse.virgo.kernel.userregion.properties b/build-kernel/config/org.eclipse.virgo.kernel.userregion.properties
index 26007bea..de07c3e6 100644
--- a/build-kernel/config/org.eclipse.virgo.kernel.userregion.properties
+++ b/build-kernel/config/org.eclipse.virgo.kernel.userregion.properties
@@ -29,12 +29,13 @@ packageImports =\
org.aspectj.*;version="[1.6.5.RELEASE,2.0.0)",\
org.osgi.service.cm;version="0",\
org.osgi.service.event;version="0",\
+ org.eclipse.equinox.region;version="1",\
org.slf4j;version="[1.6.1,2)",\
org.slf4j.spi;version="[1.6.1,2)"
serviceImports =\
- org.eclipse.virgo.kernel.osgi.region.Region,\
- org.eclipse.virgo.kernel.osgi.region.RegionDigraph,\
+ org.eclipse.equinox.region.Region,\
+ org.eclipse.equinox.region.RegionDigraph,\
org.osgi.framework.hooks.resolver.ResolverHookFactory,\
org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer,\
org.eclipse.virgo.kernel.deployer.core.DeployUriNormaliser,\
diff --git a/org.eclipse.virgo.kernel.agent.dm/.classpath b/org.eclipse.virgo.kernel.agent.dm/.classpath
index 30650202..76af7bbf 100644
--- a/org.eclipse.virgo.kernel.agent.dm/.classpath
+++ b/org.eclipse.virgo.kernel.agent.dm/.classpath
@@ -42,5 +42,6 @@
<classpathentry kind="var" path="KERNEL_IVY_CACHE/org.springframework/org.springframework.beans/3.0.0.RELEASE/org.springframework.beans-3.0.0.RELEASE.jar" sourcepath="/KERNEL_IVY_CACHE/org.springframework/org.springframework.beans/3.0.0.RELEASE/org.springframework.beans-sources-3.0.0.RELEASE.jar"/>
<classpathentry kind="src" path="/org.eclipse.virgo.kernel.osgi"/>
<classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.event/1.2.100.v20110110/org.eclipse.equinox.event-1.2.100.v20110110.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.region/1.0.0.v20110503/org.eclipse.equinox.region-1.0.0.v20110503.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
diff --git a/org.eclipse.virgo.kernel.agent.dm/ivy.xml b/org.eclipse.virgo.kernel.agent.dm/ivy.xml
index 98824436..a0e22ebb 100644
--- a/org.eclipse.virgo.kernel.agent.dm/ivy.xml
+++ b/org.eclipse.virgo.kernel.agent.dm/ivy.xml
@@ -22,6 +22,7 @@
<dependency org="org.eclipse.osgi" name="org.eclipse.osgi.services" rev="${org.eclipse.osgi.services}" conf="compile->runtime"/>
<dependency org="org.eclipse.osgi" name="org.eclipse.equinox.cm" rev="${org.eclipse.equinox.cm}" conf="compile->runtime"/>
<dependency org="org.eclipse.osgi" name="org.eclipse.equinox.event" rev="${org.eclipse.equinox.event}" conf="compile->runtime"/>
+ <dependency org="org.eclipse.osgi" name="org.eclipse.equinox.region" rev="${org.eclipse.equinox.region}" conf="compile->runtime"/>
<dependency org="org.eclipse.virgo.kernel" name="org.eclipse.virgo.kernel.deployer" rev="latest.integration" conf='compile->compile'/>
<dependency name='org.eclipse.virgo.util.io' rev='${org.eclipse.virgo.util}' org='org.eclipse.virgo.util' conf='compile->compile'/>
diff --git a/org.eclipse.virgo.kernel.agent.dm/src/main/java/org/eclipse/virgo/kernel/agent/dm/internal/DeployerFailureListener.java b/org.eclipse.virgo.kernel.agent.dm/src/main/java/org/eclipse/virgo/kernel/agent/dm/internal/DeployerFailureListener.java
index afd39bb9..e7868f77 100644
--- a/org.eclipse.virgo.kernel.agent.dm/src/main/java/org/eclipse/virgo/kernel/agent/dm/internal/DeployerFailureListener.java
+++ b/org.eclipse.virgo.kernel.agent.dm/src/main/java/org/eclipse/virgo/kernel/agent/dm/internal/DeployerFailureListener.java
@@ -11,8 +11,8 @@
package org.eclipse.virgo.kernel.agent.dm.internal;
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
+import org.eclipse.equinox.region.Region;
+import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.virgo.medic.eventlog.EventLogger;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
diff --git a/org.eclipse.virgo.kernel.agent.dm/template.mf b/org.eclipse.virgo.kernel.agent.dm/template.mf
index b1b6ce28..7ca5e245 100644
--- a/org.eclipse.virgo.kernel.agent.dm/template.mf
+++ b/org.eclipse.virgo.kernel.agent.dm/template.mf
@@ -15,5 +15,6 @@ Import-Template:
org.springframework.*;version="${org.springframework:[2.5.6, =.+1)}",
org.springframework.osgi.*;version="${org.springframework.osgi:[=.=.=, +1)}",
org.osgi.*;version="0",
- org.eclipse.osgi.*;version="0"
+ org.eclipse.osgi.*;version="0",
+ org.eclipse.equinox.region.*;version="${org.eclipse.equinox.region:[=.=.=, =.+1)}"
Service-Component: OSGI-INF/dm_agent.xml, OSGI-INF/agentdm_start_tracker.xml
diff --git a/org.eclipse.virgo.kernel.deployer.test/.classpath b/org.eclipse.virgo.kernel.deployer.test/.classpath
index 3cbc569a..708752cd 100644
--- a/org.eclipse.virgo.kernel.deployer.test/.classpath
+++ b/org.eclipse.virgo.kernel.deployer.test/.classpath
@@ -40,5 +40,6 @@
<classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.virgo.test/org.eclipse.virgo.test.framework/3.0.0.D-20110504073047/org.eclipse.virgo.test.framework-3.0.0.D-20110504073047.jar" sourcepath="/KERNEL_IVY_CACHE/org.eclipse.virgo.test/org.eclipse.virgo.test.framework/3.0.0.D-20110504073047/org.eclipse.virgo.test.framework-sources-3.0.0.D-20110504073047.jar"/>
<classpathentry kind="src" path="/org.eclipse.virgo.kernel.model"/>
<classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi.services/3.3.0.v20110110/org.eclipse.osgi.services-3.3.0.v20110110.jar" sourcepath="/KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi.services/3.3.0.v20110110/org.eclipse.osgi.services-sources-3.3.0.v20110110.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.region/1.0.0.v20110503/org.eclipse.equinox.region-1.0.0.v20110503.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/NestedPlanIntegrationTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/NestedPlanIntegrationTests.java
index 3a10030a..6893237c 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/NestedPlanIntegrationTests.java
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/NestedPlanIntegrationTests.java
@@ -29,7 +29,7 @@ import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.ArtifactState;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
-import org.eclipse.virgo.kernel.osgi.region.Region;
+import org.eclipse.equinox.region.Region;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMDeploymentIntegrationTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMDeploymentIntegrationTests.java
index 6cda3a87..333f6a02 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMDeploymentIntegrationTests.java
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMDeploymentIntegrationTests.java
@@ -15,8 +15,12 @@ import static org.junit.Assert.assertNotNull;
import java.io.File;
+import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListener;
+import org.eclipse.virgo.kernel.model.Artifact;
+import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -24,11 +28,6 @@ import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.Version;
-import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListener;
-import org.eclipse.virgo.kernel.model.Artifact;
-import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-
/**
* Test the interactions between the Runtime Artifact Model (RAM) and the deployer.
*
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/MANIFEST.MF
index 0b1fae6b..f199d9a7 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/MANIFEST.MF
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/MANIFEST.MF
@@ -12,7 +12,7 @@ Import-Package: org.eclipse.virgo.kernel.core,
org.eclipse.virgo.kernel.module,
org.eclipse.virgo.kernel.osgi.common,
org.eclipse.virgo.kernel.osgi.framework,
- org.eclipse.virgo.kernel.osgi.region,
+ org.eclipse.equinox.region,
org.eclipse.virgo.kernel.services.work,
org.eclipse.virgo.util.io,
org.eclipse.virgo.util.math,
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/no.heap.dump.test.config.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/no.heap.dump.test.config.properties
index 6d10a2b2..c9a3a4b8 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/no.heap.dump.test.config.properties
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/no.heap.dump.test.config.properties
@@ -1,4 +1,5 @@
launcher.bundles =\
+ file:../ivy-cache/repository/org.eclipse.osgi/org.eclipse.equinox.region/${org.eclipse.equinox.region}/org.eclipse.equinox.region-${org.eclipse.equinox.region}.jar@start,\
file:../ivy-cache/repository/org.eclipse.osgi/org.eclipse.equinox.ds/1.3.0.v20110124-0830/org.eclipse.equinox.ds-1.3.0.v20110124-0830.jar@start,\
file:../ivy-cache/repository/org.eclipse.osgi/org.eclipse.equinox.util/1.0.200.v20100503/org.eclipse.equinox.util-1.0.200.v20100503.jar@start,\
file:../ivy-cache/repository/org.slf4j/com.springsource.slf4j.api/${org.slf4j}/com.springsource.slf4j.api-${org.slf4j}.jar@start,\
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/spring256.test.config.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/spring256.test.config.properties
index 63e1ff2f..e28ab1c5 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/spring256.test.config.properties
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/spring256.test.config.properties
@@ -1,4 +1,5 @@
launcher.bundles =\
+ file:../ivy-cache/repository/org.eclipse.osgi/org.eclipse.equinox.region/${org.eclipse.equinox.region}/org.eclipse.equinox.region-${org.eclipse.equinox.region}.jar@start,\
file:../ivy-cache/repository/org.eclipse.osgi/org.eclipse.equinox.ds/1.3.0.v20110124-0830/org.eclipse.equinox.ds-1.3.0.v20110124-0830.jar@start,\
file:../ivy-cache/repository/org.eclipse.osgi/org.eclipse.equinox.util/1.0.200.v20100503/org.eclipse.equinox.util-1.0.200.v20100503.jar@start,\
file:../ivy-cache/repository/org.slf4j/com.springsource.slf4j.api/${org.slf4j}/com.springsource.slf4j.api-${org.slf4j}.jar@start,\
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/test.config.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/test.config.properties
index ce6a4d07..859f8bc3 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/test.config.properties
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/test.config.properties
@@ -1,4 +1,5 @@
launcher.bundles =\
+ file:../ivy-cache/repository/org.eclipse.osgi/org.eclipse.equinox.region/${org.eclipse.equinox.region}/org.eclipse.equinox.region-${org.eclipse.equinox.region}.jar@start,\
file:../ivy-cache/repository/org.eclipse.osgi/org.eclipse.equinox.ds/1.3.0.v20110124-0830/org.eclipse.equinox.ds-1.3.0.v20110124-0830.jar@start,\
file:../ivy-cache/repository/org.eclipse.osgi/org.eclipse.equinox.util/1.0.200.v20100503/org.eclipse.equinox.util-1.0.200.v20100503.jar@start,\
file:../ivy-cache/repository/org.slf4j/com.springsource.slf4j.api/${org.slf4j}/com.springsource.slf4j.api-${org.slf4j}.jar@start,\
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties
index 127b5625..d0faac02 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties
@@ -49,11 +49,12 @@ packageImports =\
org.junit.runner;version="[4.7.0,5.0.0)",\
org.osgi.service.cm;version="0",\
org.osgi.service.event;version="0",\
+ org.eclipse.equinox.region;version="1",\
org.slf4j;version="[1.6.1,2)"
serviceImports =\
- org.eclipse.virgo.kernel.osgi.region.Region,\
- org.eclipse.virgo.kernel.osgi.region.RegionDigraph,\
+ org.eclipse.equinox.region.Region,\
+ org.eclipse.equinox.region.RegionDigraph,\
org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer,\
org.eclipse.virgo.kernel.deployer.core.DeployUriNormaliser,\
org.eclipse.virgo.kernel.install.artifact.ScopeServiceRepository,\
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/resources/META-INF/spring/internal-osgi-context.xml b/org.eclipse.virgo.kernel.deployer/src/main/resources/META-INF/spring/internal-osgi-context.xml
index d5347295..7a40f144 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/resources/META-INF/spring/internal-osgi-context.xml
+++ b/org.eclipse.virgo.kernel.deployer/src/main/resources/META-INF/spring/internal-osgi-context.xml
@@ -49,10 +49,6 @@
<osgi:reference id="importExpander"
interface="org.eclipse.virgo.kernel.osgi.framework.ImportExpander" />
- <osgi:reference id="region"
- interface="org.eclipse.virgo.kernel.osgi.region.Region"
- filter="(org.eclipse.virgo.kernel.region.name=org.eclipse.virgo.region.user)" />
-
<!-- services -->
<osgi:service ref="moduleContextEventPublisher"
interface="org.eclipse.virgo.kernel.module.ModuleContextEventPublisher" />
diff --git a/org.eclipse.virgo.kernel.deployer/template.mf b/org.eclipse.virgo.kernel.deployer/template.mf
index 1706cb73..7b38699e 100644
--- a/org.eclipse.virgo.kernel.deployer/template.mf
+++ b/org.eclipse.virgo.kernel.deployer/template.mf
@@ -16,6 +16,7 @@ Import-Template:
org.eclipse.osgi.*;version="0",
org.osgi.service.*;version="0",
org.osgi.util.tracker.*;version="0",
+ org.eclipse.equinox.region.*;version="${org.eclipse.equinox.region:[=.=.=, =.+1)}",
javax.management.*;version="0",
javax.xml.*;version="0",
org.xml.*;version="0",
diff --git a/org.eclipse.virgo.kernel.model/.classpath b/org.eclipse.virgo.kernel.model/.classpath
index 4c4807d7..9a661868 100644
--- a/org.eclipse.virgo.kernel.model/.classpath
+++ b/org.eclipse.virgo.kernel.model/.classpath
@@ -41,5 +41,6 @@
<classpathentry kind="src" path="/org.eclipse.virgo.kernel.core"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.virgo.kernel.stubs"/>
<classpathentry kind="var" path="KERNEL_IVY_CACHE/org.springframework/org.springframework.context/3.0.0.RELEASE/org.springframework.context-3.0.0.RELEASE.jar" sourcepath="/KERNEL_IVY_CACHE/org.springframework/org.springframework.context/3.0.0.RELEASE/org.springframework.context-sources-3.0.0.RELEASE.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.region/1.0.0.v20110503/org.eclipse.equinox.region-1.0.0.v20110503.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
diff --git a/org.eclipse.virgo.kernel.model/ivy.xml b/org.eclipse.virgo.kernel.model/ivy.xml
index 64b2cce9..c4b536a8 100644
--- a/org.eclipse.virgo.kernel.model/ivy.xml
+++ b/org.eclipse.virgo.kernel.model/ivy.xml
@@ -32,6 +32,7 @@
<dependency org="org.eclipse.osgi" name="org.eclipse.osgi.services" rev="${org.eclipse.osgi.services}" conf="compile->runtime"/>
<dependency org="org.eclipse.osgi" name="org.eclipse.equinox.cm" rev="${org.eclipse.equinox.cm}" conf="compile->runtime"/>
+ <dependency org="org.eclipse.osgi" name="org.eclipse.equinox.region" rev="${org.eclipse.equinox.region}" conf="compile->runtime"/>
<override org="org.eclipse.virgo.util" rev="${org.eclipse.virgo.util}"/>
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/Artifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/Artifact.java
index 22a5c46b..67bbff30 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/Artifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/Artifact.java
@@ -14,7 +14,7 @@ package org.eclipse.virgo.kernel.model;
import java.util.Map;
import java.util.Set;
-import org.eclipse.virgo.kernel.osgi.region.Region;
+import org.eclipse.equinox.region.Region;
import org.osgi.framework.Version;
/**
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/RuntimeArtifactRepository.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/RuntimeArtifactRepository.java
index 9ac61295..9e9f0881 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/RuntimeArtifactRepository.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/RuntimeArtifactRepository.java
@@ -13,7 +13,7 @@ package org.eclipse.virgo.kernel.model;
import java.util.Set;
-import org.eclipse.virgo.kernel.osgi.region.Region;
+import org.eclipse.equinox.region.Region;
import org.osgi.framework.Version;
/**
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/AbstractArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/AbstractArtifact.java
index aa0b76da..921285ca 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/AbstractArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/AbstractArtifact.java
@@ -16,8 +16,8 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.model.Artifact;
-import org.eclipse.virgo.kernel.osgi.region.Region;
import org.eclipse.virgo.kernel.serviceability.NonNull;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/NotifyingRuntimeArtifactRepository.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/NotifyingRuntimeArtifactRepository.java
index fdc43f6d..bd77f013 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/NotifyingRuntimeArtifactRepository.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/NotifyingRuntimeArtifactRepository.java
@@ -16,9 +16,9 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
-import org.eclipse.virgo.kernel.osgi.region.Region;
import org.osgi.framework.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleArtifact.java
index 0bbecaac..b5483719 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleArtifact.java
@@ -11,9 +11,11 @@
package org.eclipse.virgo.kernel.model.internal.bundle;
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.ArtifactState;
import org.eclipse.virgo.kernel.model.internal.AbstractArtifact;
+import org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil;
import org.eclipse.virgo.kernel.serviceability.NonNull;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -21,9 +23,6 @@ import org.osgi.framework.BundleException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil;
-import org.eclipse.virgo.kernel.osgi.region.Region;
-
/**
* Implementation of {@link Artifact} that delegates to an OSGi native bundle
* <p />
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminer.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminer.java
index d5e6d95c..901c58c7 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminer.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminer.java
@@ -15,6 +15,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
@@ -23,7 +24,6 @@ import org.eclipse.virgo.kernel.osgi.quasi.QuasiExportPackage;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiFramework;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiFrameworkFactory;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiImportPackage;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
import org.eclipse.virgo.kernel.serviceability.NonNull;
/**
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListener.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListener.java
index 8c3cd8c3..391c0f55 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListener.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListener.java
@@ -11,20 +11,20 @@
package org.eclipse.virgo.kernel.model.internal.bundle;
+import org.eclipse.equinox.region.Region;
+import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
+import org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil;
import org.eclipse.virgo.kernel.serviceability.NonNull;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
import org.osgi.framework.SynchronousBundleListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil;
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-
/**
* Implementation of {@link BundleListener} that notices {@link BundleEvent#INSTALLED} and
* {@link BundleEvent#UNINSTALLED} events to add and remove respectively {@link Artifact}s from the
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializer.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializer.java
index 8a526236..d1894c3b 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializer.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializer.java
@@ -14,9 +14,9 @@ package org.eclipse.virgo.kernel.model.internal.bundle;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
+import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
import org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
import org.eclipse.virgo.kernel.serviceability.NonNull;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerArtifact.java
index ccc4bc87..ca84fa09 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerArtifact.java
@@ -17,6 +17,7 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.core.BlockingAbortableSignal;
import org.eclipse.virgo.kernel.core.FailureSignalledException;
import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
@@ -25,7 +26,6 @@ import org.eclipse.virgo.kernel.install.artifact.InstallArtifact.State;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.ArtifactState;
import org.eclipse.virgo.kernel.model.internal.AbstractArtifact;
-import org.eclipse.virgo.kernel.osgi.region.Region;
import org.eclipse.virgo.kernel.serviceability.NonNull;
import org.osgi.framework.BundleContext;
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerBundleArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerBundleArtifact.java
index 4bf25494..8bc30df7 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerBundleArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerBundleArtifact.java
@@ -13,12 +13,11 @@ package org.eclipse.virgo.kernel.model.internal.deployer;
import java.net.URI;
-import org.eclipse.virgo.kernel.serviceability.NonNull;
-import org.osgi.framework.BundleContext;
-
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.install.artifact.BundleInstallArtifact;
import org.eclipse.virgo.kernel.model.BundleArtifact;
-import org.eclipse.virgo.kernel.osgi.region.Region;
+import org.eclipse.virgo.kernel.serviceability.NonNull;
+import org.osgi.framework.BundleContext;
final class DeployerBundleArtifact extends DeployerArtifact implements BundleArtifact {
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListener.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListener.java
index 57cccc7e..3fd4073b 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListener.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListener.java
@@ -11,20 +11,20 @@
package org.eclipse.virgo.kernel.model.internal.deployer;
+import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
-import org.eclipse.virgo.kernel.serviceability.NonNull;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.eclipse.virgo.kernel.install.artifact.BundleInstallArtifact;
import org.eclipse.virgo.kernel.install.artifact.InstallArtifact;
import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListener;
import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListenerSupport;
import org.eclipse.virgo.kernel.install.artifact.PlanInstallArtifact;
import org.eclipse.virgo.kernel.model.Artifact;
+import org.eclipse.virgo.kernel.model.BundleArtifact;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
+import org.eclipse.virgo.kernel.serviceability.NonNull;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Implementation of {@link InstallArtifactLifecycleListener} that notices
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerInitializer.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerInitializer.java
index 41b25277..8903ae5f 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerInitializer.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerInitializer.java
@@ -13,21 +13,19 @@ package org.eclipse.virgo.kernel.model.internal.deployer;
import javax.annotation.PostConstruct;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
+import org.eclipse.equinox.region.RegionDigraph;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.kernel.deployer.model.RuntimeArtifactModel;
import org.eclipse.virgo.kernel.install.artifact.BundleInstallArtifact;
import org.eclipse.virgo.kernel.install.artifact.InstallArtifact;
import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListener;
import org.eclipse.virgo.kernel.install.artifact.PlanInstallArtifact;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-
-import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
-import org.eclipse.virgo.kernel.deployer.model.RuntimeArtifactModel;
import org.eclipse.virgo.kernel.serviceability.NonNull;
import org.eclipse.virgo.util.osgi.ServiceRegistrationTracker;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* An initializer responsible for registering a {@link ModelInstallArtifactLifecycleListener} and enumerating any
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/ManageableArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/ManageableArtifact.java
index 999d2f1a..12abf070 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/ManageableArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/ManageableArtifact.java
@@ -16,7 +16,7 @@ import java.util.Map;
import javax.management.MXBean;
import javax.management.ObjectName;
-import org.eclipse.virgo.kernel.osgi.region.Region;
+import org.eclipse.equinox.region.Region;
import org.osgi.framework.Version;
/**
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/RuntimeArtifactModelObjectNameCreator.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/RuntimeArtifactModelObjectNameCreator.java
index e7772fcd..19358ecd 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/RuntimeArtifactModelObjectNameCreator.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/RuntimeArtifactModelObjectNameCreator.java
@@ -13,8 +13,9 @@ package org.eclipse.virgo.kernel.model.management;
import javax.management.ObjectName;
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.model.Artifact;
-import org.eclipse.virgo.kernel.osgi.region.Region;
+import org.eclipse.virgo.kernel.model.internal.AbstractArtifact;
import org.osgi.framework.Version;
/**
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DefaultRuntimeArtifactModelObjectNameCreator.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DefaultRuntimeArtifactModelObjectNameCreator.java
index d30d1774..e3105e05 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DefaultRuntimeArtifactModelObjectNameCreator.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DefaultRuntimeArtifactModelObjectNameCreator.java
@@ -14,9 +14,9 @@ package org.eclipse.virgo.kernel.model.management.internal;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.management.RuntimeArtifactModelObjectNameCreator;
-import org.eclipse.virgo.kernel.osgi.region.Region;
import org.eclipse.virgo.kernel.serviceability.NonNull;
import org.osgi.framework.Version;
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableArtifact.java
index c4cbe9d3..203aaed9 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableArtifact.java
@@ -17,10 +17,10 @@ import java.util.Set;
import javax.management.ObjectName;
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
import org.eclipse.virgo.kernel.model.management.RuntimeArtifactModelObjectNameCreator;
-import org.eclipse.virgo.kernel.osgi.region.Region;
import org.eclipse.virgo.kernel.serviceability.NonNull;
diff --git a/org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/osgi-context.xml b/org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/osgi-context.xml
index df23f813..22c8c648 100644
--- a/org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/osgi-context.xml
+++ b/org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/osgi-context.xml
@@ -41,6 +41,6 @@
<reference id="applicationDeployer" interface="org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer"/>
- <reference id="regionDigraph" interface="org.eclipse.virgo.kernel.osgi.region.RegionDigraph" />
+ <reference id="regionDigraph" interface="org.eclipse.equinox.region.RegionDigraph" />
</beans:beans>
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubArtifactRepository.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubArtifactRepository.java
index 87e0e896..5e9a6be2 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubArtifactRepository.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubArtifactRepository.java
@@ -14,9 +14,7 @@ package org.eclipse.virgo.kernel.model;
import java.util.HashSet;
import java.util.Set;
-import org.eclipse.virgo.kernel.model.Artifact;
-import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
-import org.eclipse.virgo.kernel.osgi.region.Region;
+import org.eclipse.equinox.region.Region;
import org.osgi.framework.Version;
public class StubArtifactRepository implements RuntimeArtifactRepository {
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubCompositeArtifact.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubCompositeArtifact.java
index b29054a1..028ba34f 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubCompositeArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubCompositeArtifact.java
@@ -14,7 +14,7 @@ package org.eclipse.virgo.kernel.model;
import java.util.Map;
import java.util.Set;
-import org.eclipse.virgo.kernel.osgi.region.Region;
+import org.eclipse.equinox.region.Region;
import org.osgi.framework.Version;
public class StubCompositeArtifact implements CompositeArtifact {
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/NotifyingArtifactRepositoryTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/NotifyingArtifactRepositoryTests.java
index ad82a671..079ea408 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/NotifyingArtifactRepositoryTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/NotifyingArtifactRepositoryTests.java
@@ -20,16 +20,17 @@ import static org.junit.Assert.assertTrue;
import java.io.InputStream;
import java.util.Set;
+import org.eclipse.equinox.region.Region;
+import org.eclipse.equinox.region.RegionDigraph;
+import org.eclipse.equinox.region.RegionDigraph.FilteredRegion;
+import org.eclipse.equinox.region.RegionDigraphVisitor;
+import org.eclipse.equinox.region.RegionFilter;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.StubCompositeArtifact;
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph.FilteredRegion;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraphVisitor;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
+import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Version;
-import org.junit.Test;
public class NotifyingArtifactRepositoryTests {
@@ -144,6 +145,11 @@ public class NotifyingArtifactRepositoryTests {
public void visitSubgraph(RegionDigraphVisitor visitor) {
}
+
+ @Override
+ public RegionDigraph getRegionDigraph() {
+ return null;
+ }
}
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleArtifactTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleArtifactTests.java
index 4abf5703..445893dc 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleArtifactTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleArtifactTests.java
@@ -18,21 +18,18 @@ import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-
-import org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil;
-import org.eclipse.virgo.kernel.osgi.region.Region;
-
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.model.ArtifactState;
import org.eclipse.virgo.kernel.model.internal.AbstractArtifact;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
-import org.eclipse.virgo.kernel.model.internal.bundle.BundleArtifact;
+import org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil;
import org.eclipse.virgo.kernel.serviceability.Assert.FatalAssertionException;
import org.eclipse.virgo.teststubs.osgi.framework.StubBundle;
import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
import org.eclipse.virgo.teststubs.osgi.support.TrueFilter;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
public class BundleArtifactTests {
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java
index 707ec84c..15e80978 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java
@@ -14,8 +14,8 @@ package org.eclipse.virgo.kernel.model.internal.bundle;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
import static org.easymock.EasyMock.reset;
+import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
@@ -23,6 +23,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Set;
+import org.eclipse.equinox.region.Region;
+import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
import org.eclipse.virgo.kernel.model.StubArtifactRepository;
@@ -31,8 +33,6 @@ import org.eclipse.virgo.kernel.osgi.quasi.QuasiBundle;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiFramework;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiFrameworkFactory;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiImportPackage;
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
import org.eclipse.virgo.kernel.serviceability.Assert.FatalAssertionException;
import org.junit.Before;
import org.junit.Test;
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializerTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializerTests.java
index 59bb20db..bff93e76 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializerTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializerTests.java
@@ -16,10 +16,10 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
+import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.virgo.kernel.model.StubArtifactRepository;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
import org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
import org.eclipse.virgo.kernel.serviceability.Assert.FatalAssertionException;
import org.eclipse.virgo.teststubs.osgi.framework.StubBundle;
import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerTests.java
index b77d1b7f..6a939d7f 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerTests.java
@@ -17,20 +17,17 @@ import static org.easymock.EasyMock.isA;
import static org.easymock.EasyMock.replay;
import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleEvent;
-
-import org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-
+import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.virgo.kernel.model.StubArtifactRepository;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
-import org.eclipse.virgo.kernel.model.internal.bundle.ModelBundleListener;
+import org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil;
import org.eclipse.virgo.kernel.serviceability.Assert.FatalAssertionException;
import org.eclipse.virgo.teststubs.osgi.framework.StubBundle;
import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
import org.eclipse.virgo.teststubs.osgi.support.TrueFilter;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleEvent;
public class ModelBundleListenerTests {
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerInitializerTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerInitializerTests.java
index eb380dab..56db866c 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerInitializerTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerInitializerTests.java
@@ -20,22 +20,19 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
-import org.junit.Test;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.Version;
-
-
+import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
import org.eclipse.virgo.kernel.deployer.model.RuntimeArtifactModel;
import org.eclipse.virgo.kernel.model.StubArtifactRepository;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
-import org.eclipse.virgo.kernel.model.internal.deployer.ModelInstallArtifactLifecycleListenerInitializer;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
import org.eclipse.virgo.kernel.serviceability.Assert.FatalAssertionException;
import org.eclipse.virgo.kernel.stubs.StubInstallArtifact;
import org.eclipse.virgo.kernel.stubs.StubPlanInstallArtifact;
import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
import org.eclipse.virgo.teststubs.osgi.support.TrueFilter;
+import org.junit.Test;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.Version;
public class ModelInstallArtifactLifecycleListenerInitializerTests {
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerTests.java
index af9edca4..b7dda74c 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerTests.java
@@ -14,21 +14,17 @@ package org.eclipse.virgo.kernel.model.internal.deployer;
import static org.easymock.EasyMock.createMock;
import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
+import org.eclipse.equinox.region.RegionDigraph;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
import org.eclipse.virgo.kernel.install.artifact.InstallArtifact;
import org.eclipse.virgo.kernel.model.StubArtifactRepository;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
-import org.eclipse.virgo.kernel.model.internal.deployer.ModelInstallArtifactLifecycleListener;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-
-
-import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
import org.eclipse.virgo.kernel.serviceability.Assert.FatalAssertionException;
import org.eclipse.virgo.kernel.stubs.StubInstallArtifact;
import org.eclipse.virgo.kernel.stubs.StubPlanInstallArtifact;
import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
import org.eclipse.virgo.teststubs.osgi.support.TrueFilter;
+import org.junit.Test;
public class ModelInstallArtifactLifecycleListenerTests {
diff --git a/org.eclipse.virgo.kernel.model/template.mf b/org.eclipse.virgo.kernel.model/template.mf
index 543d8fbd..1fcb3bd6 100644
--- a/org.eclipse.virgo.kernel.model/template.mf
+++ b/org.eclipse.virgo.kernel.model/template.mf
@@ -14,6 +14,7 @@ Import-Template:
org.osgi.framework.*;version="0",
org.osgi.service.cm.*;version="0",
org.osgi.util.tracker.*;version="0",
+ org.eclipse.equinox.region.*;version="${org.eclipse.equinox.region:[=.=.=, =.+1)}",
org.slf4j.*;version="${org.slf4j:[=.=.=, +1)}"
Excluded-Exports:
*.internal.*
diff --git a/org.eclipse.virgo.kernel.osgi/.springBeans b/org.eclipse.virgo.kernel.osgi/.springBeans
index 4dbe37b1..6c6cb5a2 100644
--- a/org.eclipse.virgo.kernel.osgi/.springBeans
+++ b/org.eclipse.virgo.kernel.osgi/.springBeans
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<beansProjectDescription>
<version>1</version>
- <pluginVersion><![CDATA[2.2.7.200910202224-RELEASE]]></pluginVersion>
+ <pluginVersion><![CDATA[2.5.0.201010221000-RELEASE]]></pluginVersion>
<configSuffixes>
<configSuffix><![CDATA[xml]]></configSuffix>
</configSuffixes>
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/Region.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/Region.java
deleted file mode 100644
index 88fc7f51..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/Region.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region;
-
-import java.io.InputStream;
-import java.util.Set;
-
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph.FilteredRegion;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Version;
-
-/**
- * A <i>region</i> is a subset of the bundles of an OSGi framework. A regions is "weakly" isolated from other regions
- * except that is has full visibility of certain (subject to a {@link RegionFilter}) bundles, packages, and services
- * from other regions to which it is connected. However a bundle running in a region is not protected from discovering
- * bundles in other regions, e.g. by following wires using Wire Admin or similar services, so this is why regions are
- * only weakly isolated from each other.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- *
- * Implementations must be thread safe.
- *
- */
-public interface Region {
-
- /**
- * Returns the name of the region.
- *
- * @return the region name
- */
- String getName();
-
- /**
- * Associates a given bundle, which has therefore already been installed, with this region.
- * <p>
- * This method is typically used to associate the system bundle with a region. Note that the system bundle is not
- * treated specially and in order to be fully visible in a region, it must either be associated with the region or
- * imported from another region via a connection.
- * <p>
- * If the bundle is already associated with this region, takes no action and returns normally.
- * <p>
- * If the bundle is already associated with another region, throws BundleException with exception type
- * INVALID_OPERATION.
- * <p>
- * If the bundle has the same bundle symbolic name and version as a bundle already present in the region or as a
- * bundle import specified on a connection to another region, then BundleException with exception type
- * DUPLICATE_BUNDLE_ERROR is thrown.
- *
- * @param bundle the bundle to be associated with this region
- * @throws BundleException if the bundle cannot be associated with the region
- */
- void addBundle(Bundle bundle) throws BundleException;
-
- /**
- * Associates the given bundle id with this region. If the given bundle id is already associated with this region,
- * this is not an error and there is no effect.
- * <p>
- * This is useful when manipulating offline resolver states and bundle descriptions which do not correspond to
- * bundles.
- *
- * @param bundleId the bundle id to be associated with this region
- */
- void addBundle(long bundleId);
-
- /**
- * Installs a bundle and associates the bundle with this region. The bundle's location will have the region name
- * prepended to the given location to ensure the location is unique across regions.
- * <p>
- * If the bundle has the same bundle symbolic name and version as a bundle already present in the region or as a
- * bundle import specified on a connection to another region, then BundleException with exception type
- * DUPLICATE_BUNDLE_ERROR is thrown.
- *
- * @param location the bundle location string
- * @param input a stream of the bundle's contents or <code>null</code>
- * @return the installed Bundle
- * @throws BundleException if the install fails
- * @see BundleContext#installBundle(String, InputStream)
- */
- Bundle installBundle(String location, InputStream input) throws BundleException;
-
- /**
- * Installs a bundle and associates the bundle with this region. The bundle's location will have the region name
- * prepended to the given location to ensure the location is unique across regions.
- * <p>
- * If the bundle has the same bundle symbolic name and version as a bundle already present in the region or as a
- * bundle import specified on a connection to another region, then BundleException with exception type
- * DUPLICATE_BUNDLE_ERROR is thrown.
- *
- *
- * @param location the bundle location string
- * @return the installed Bundle
- * @throws BundleException if the install fails
- * @see BundleContext#installBundle(String)
- */
- Bundle installBundle(String location) throws BundleException;
-
- /**
- *
- * Gets the bundle ids of the bundles associated with this region.
- *
- * @return a set of bundle ids
- */
- Set<Long> getBundleIds();
-
- /**
- * Returns <code>true</code> if and only if the given bundle belongs to this region.
- *
- * @param bundle a {@link Bundle}
- * @return <code>true</code> if the given bundle belongs to this region and <code>false</code> otherwise
- */
- boolean contains(Bundle bundle);
-
- /**
- * Returns <code>true</code> if and only if a bundle with the given bundle id belongs to this region.
- *
- * @param bundleId a bundle id
- * @return <code>true</code> if a bundle with the given bundle id belongs to this region and <code>false</code>
- * otherwise
- */
- boolean contains(long bundleId);
-
- /**
- * Get the bundle in this region with the given symbolic name and version.
- *
- * @param symbolicName
- * @param version
- * @return the bundle or <code>null</code> if there is no such bundle
- */
- Bundle getBundle(String symbolicName, Version version);
-
- /**
- * Connects this region to the given head region and associates the given {@link RegionFilter} with the connection.
- * This region may then, subject to the region filter, see bundles, packages, and services visible in the head
- * region.
- * <p>
- * If the filter allows the same bundle symbolic name and version as a bundle already present in this region or a
- * filter connecting this region to a region other than the tail region, then BundleException with exception type
- * DUPLICATE_BUNDLE_ERROR is thrown.
- * <p>
- * If the given source region is already connected to the given tail region, then BundleException with exception
- * type UNSUPPORTED_OPERATION is thrown.
- *
- * @param headRegion the region to connect this region to
- * @param filter a {@link RegionFilter} which controls what is visible across the connection
- * @throws BundleException if the connection was not created
- */
- void connectRegion(Region headRegion, RegionFilter filter) throws BundleException;
-
- /**
- * Removes the given bundle from this region. If the given bundle does not belong to this region, this is not an
- * error and there is no effect.
- *
- * @param bundle the bundle to be removed
- */
- void removeBundle(Bundle bundle);
-
- /**
- * Removes the given bundle id from this region. If the given bundle id is not associated with this region, this is
- * not an error and there is no effect.
- *
- * @param bundleId the bundle id to be removed
- */
- void removeBundle(long bundleId);
-
- /**
- * Gets a {@link Set} containing a snapshot of the {@link FilteredRegion FilteredRegions} attached to this tail
- * region.
- *
- * @return a {@link Set} of {@link FilteredRegion FilteredRegions} of head regions and region filters
- */
- Set<FilteredRegion> getEdges();
-
- /**
- * Visit the subgraph connected to this region.
- *
- * @param visitor a {@link RegionDigraphVisitor} to be called as the subgraph is navigated
- */
- void visitSubgraph(RegionDigraphVisitor visitor);
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraph.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraph.java
deleted file mode 100644
index 3bb7c266..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraph.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * This file is part of the Virgo Web Server.
- *
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SpringSource, a division of VMware - initial API and implementation and/or initial documentation
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region;
-
-import java.util.Set;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-
-/**
- * {@link RegionDigraph} is a <a href="http://en.wikipedia.org/wiki/Directed_graph">directed graph</a>, or
- * <i>digraph</i>, of {@link Region Regions}. The regions form the nodes of the graph and the edges connect regions to
- * other regions.
- * <p>
- * Each edge (r, s) of the digraph is directed from region r, known as the <i>tail</i> of the edge, to region s, known
- * as the <i>head</i> of the edge.
- * <p>
- * Each edge is associated with a {@link RegionFilter}, making the digraph a <i>labelled</i> digraph. The region filter
- * for edge (r, s) allows region r to see certain bundles, packages, and services visible in region s.
- * <p>
- * Although the digraph may contain cycles it does not contain any <i>loops</i> which are edges of the form (r, r) for
- * some region r. Loopless digraphs are known as <i>simple</i> digraphs. So the digraph is a simple, labelled digraph.
- * <p>
- * The region digraph extends <code>Iterable<Region></code> and so a foreach statement may be used to iterate over (a
- * snapshot of) the regions in the digraph, e.g.
- *
- * <pre>
- * for (Region r : regionDigraph) {
- * ...
- * }
- * </pre>
- * <p>
- * <strong>Concurrent Semantics</strong><br />
- *
- * Implementations of this interface must be thread safe.
- *
- */
-public interface RegionDigraph extends Iterable<Region> {
-
- public interface FilteredRegion {
-
- Region getRegion();
-
- RegionFilter getFilter();
- }
-
- /**
- * Create a {@link Region} with the given name. If a region with the given name already exists, then BundleException
- * with exception type UNSUPPORTED_OPERATION is thrown.
- *
- * @param regionName the name of the region
- * @return the {@link Region} created
- * @throws BundleException if the region was not created
- */
- Region createRegion(String regionName) throws BundleException;
-
- /**
- * Create a {@link RegionFilterBuilder} instance.
- *
- * @return a region filter builder
- */
- RegionFilterBuilder createRegionFilterBuilder();
-
- /**
- * Removes the given {@link Region} from the digraph along with any edges which have the given region as head or
- * tail. If the given region is not present in the digraph, this is not an error and there is no effect.
- *
- * @param region the {@link Region} to be removed
- */
- void removeRegion(Region region);
-
- /**
- * Gets all the {@link Region Regions} in the digraph.
- *
- * @return a set of {@link Region Regions}
- */
- Set<Region> getRegions();
-
- /**
- * Gets the {@link Region} in the digraph with the given name.
- *
- * @param regionName the name of the region
- * @return the {@link Region} or <code>null</code> if no such region is present in the digraph
- */
- Region getRegion(String regionName);
-
- /**
- * Gets the {@link Region} in the digraph containing the given bundle.
- *
- * @param bundle the bundle to search for
- * @return the {@link Region} which contains the given bundle or <code>null</code> if there is no such region
- */
- Region getRegion(Bundle bundle);
-
- /**
- * Gets the {@link Region} in the digraph containing a bundle with the given bundle id.
- *
- * @param bundleId the bundleId of the bundle to search for
- * @return the {@link Region} which contains a bundle with the given bundle or <code>null</code> if there is no such
- * region
- */
- Region getRegion(long bundleId);
-
- /**
- * Connects a given tail region to a given head region via an edge labelled with the given {@link RegionFilter}. The
- * tail region may then, subject to the region filter, see bundles, packages, and services visible in the head
- * region.
- * <p>
- * The given head and tail regions are added to the digraph if they are not already present.
- * <p>
- * If the given tail region is already connected to the given head region, then BundleException with exception type
- * UNSUPPORTED_OPERATION is thrown.
- * <p>
- * If the given head and the given tail are identical, then BundleException with exception type
- * UNSUPPORTED_OPERATION is thrown.
- *
- * @param tailRegion the region at the tail of the new edge
- * @param filter a {@link RegionFilter} which labels the new edge
- * @param headRegion the region at the head of the new edge
- * @throws BundleException if the edge was not created
- */
- void connect(Region tailRegion, RegionFilter filter, Region headRegion) throws BundleException;
-
- /**
- * Gets a {@link Set} containing a snapshot of the {@link FilteredRegion FilteredRegions} attached to the given tail
- * region.
- *
- * @param tailRegion the tail region whose edges are gotten
- * @return a {@link Set} of {@link FilteredRegion FilteredRegions} of head regions and region filters
- */
- Set<FilteredRegion> getEdges(Region tailRegion);
-
- /**
- * Visit the subgraph connected to the given region.
- *
- * @param startingRegion the region at which to start
- * @param visitor a {@link RegionDigraphVisitor} to be called as the subgraph is navigated
- */
- void visitSubgraph(Region startingRegion, RegionDigraphVisitor visitor);
-
- /**
- * Gets a {@link RegionDigraphPersistence} object which can be used to save and load a {@link RegionDigraph} to and
- * from persistent storage.
- *
- * @return a {@link RegionDigraphPersistence} object.
- */
- RegionDigraphPersistence getRegionDigraphPersistence();
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraphPersistence.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraphPersistence.java
deleted file mode 100644
index d9cd7889..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraphPersistence.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * A region digraph persistence is used to persist the state of a {@link RegionDigraph}.
- * <p />
- * <strong>Concurrent Semantics</strong><br />
- *
- * Implementations of this interface must be thread safe.
- */
-public interface RegionDigraphPersistence {
-
- /**
- * Creates a new digraph and reads the content of the digraph from the provided input. The provided input must have
- * been persisted using the {@link #save(RegionDigraph, OutputStream)} method.
- * <p />
- * Note that the returned digraph is disconnected from the OSGi runtime. Any modifications made to the returned
- * digraph will not affect the OSGi runtime behavior of the bundles installed in the running framework.
- * <p />
- * The specified stream remains open after this method returns.
- *
- * @param input an input stream to read a digraph from.
- * @return the new digraph
- * @throws IOException if error occurs reading the digraph.
- * @throws IllegalArgumentException if the input stream is not a digraph or has an incompatible persistent version
- */
- RegionDigraph load(InputStream input) throws IOException;
-
- /**
- * Writes the specified {@link RegionDigraph} to the provided output in a form suitable for using the
- * {@link #load(InputStream)} method.
- * <p />
- * After the digraph has been written, the output stream is flushed. The output stream remains open after this
- * method returns.
- *
- * @param digraph a digraph to be written.
- * @param output an output stream to write a digraph to.
- * @throws IOException if error occurs writing the digraph.
- */
- void save(RegionDigraph digraph, OutputStream output) throws IOException;
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraphVisitor.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraphVisitor.java
deleted file mode 100644
index ae486d96..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraphVisitor.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * This file is part of the Virgo Web Server.
- *
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SpringSource, a division of VMware - initial API and implementation and/or initial documentation
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region;
-
-/**
- * {@link RegionDigraphVisitor} is used to traverse a subgraph of a {@link RegionDigraph}.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- *
- * Implementations of this interface must be thread safe.
- */
-public interface RegionDigraphVisitor {
-
- /**
- * Visits the given region and determines whether or not to continue traversing.
- *
- * @param region the region to visit
- * @return <code>true</code> if the traversal is to continue and <code>false</code> otherwise
- */
- boolean visit(Region region);
-
- /**
- * Prepares to traverse an edge with the given {@link RegionFilter} and determines whether or not to traverse the
- * edge.
- *
- * @param regionFilter the {@link RegionFilter} of the edge to be traversed
- * @return <code>true</code> if the edge is to be traversed and <code>false</code> otherwise
- */
- boolean preEdgeTraverse(RegionFilter regionFilter);
-
- /**
- * This is called after traversing an edge with the given {@link RegionFilter}.
- *
- * @param regionFilter the {@link RegionFilter} of the edge that has just been traversed
- */
- void postEdgeTraverse(RegionFilter regionFilter);
-
-} \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionFilter.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionFilter.java
deleted file mode 100644
index 95d80bd6..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionFilter.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * This file is part of the Virgo Web Server.
- *
- * Copyright (c) 2010 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SpringSource, a division of VMware - initial API and implementation and/or initial documentation
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region;
-
-import java.util.Collection;
-import java.util.Map;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.wiring.BundleCapability;
-import org.osgi.framework.wiring.BundleRevision;
-
-/**
- * A {@link RegionFilter} is associated with a connection from one region to another and determines the bundles,
- * packages, services and other capabilities which are visible across the connection. A region filter is constant; its
- * sharing policy cannot be changed after construction. Instances of region filters can be created with a
- * {@link RegionFilterBuilder}.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- *
- * Implementations must be thread safe.
- *
- */
-public interface RegionFilter {
-
- /**
- * Name space for sharing package capabilities.
- *
- * @see BundleRevision#PACKAGE_NAMESPACE
- */
- public static final String VISIBLE_PACKAGE_NAMESPACE = BundleRevision.PACKAGE_NAMESPACE;
-
- /**
- * Name space for sharing bundle capabilities for require bundle constraints.
- *
- * @see BundleRevision#BUNDLE_NAMESPACE
- */
- public static final String VISIBLE_REQUIRE_NAMESPACE = BundleRevision.BUNDLE_NAMESPACE;
-
- /**
- * Name space for sharing host capabilities.
- *
- * @see BundleRevision#HOST_NAMESPACE
- */
- public static final String VISIBLE_HOST_NAMESPACE = BundleRevision.HOST_NAMESPACE;
-
- /**
- * Name space for sharing services. The filters specified in this name space will be used to match
- * {@link ServiceReference services}.
- */
- public static final String VISIBLE_SERVICE_NAMESPACE = "org.eclipse.equinox.allow.service";
-
- /**
- * Name space for sharing bundles. The filters specified in this name space will be use to match against a bundle's
- * symbolic name and version. The attribute {@link Constants#BUNDLE_SYMBOLICNAME_ATTRIBUTE bundle-symbolic-name} is
- * used for the symbolic name and the attribute {@link Constants#BUNDLE_VERSION_ATTRIBUTE bundle-version} is used
- * for the bundle version.
- */
- public static final String VISIBLE_BUNDLE_NAMESPACE = "org.eclipse.equinox.allow.bundle";
-
- /**
- * Name space for matching against all capabilities. The filters specified in this name space will be used to match
- * all capabilities.
- */
- public static final String VISIBLE_ALL_NAMESPACE = "org.eclipse.equinox.allow.all";
-
- /**
- * Determines whether this filter allows the given bundle
- *
- * @param bundle the bundle
- * @return <code>true</code> if the bundle is allowed and <code>false</code>otherwise
- */
- public boolean isAllowed(Bundle bundle);
-
- /**
- * Determines whether this filter allows the given bundle
- *
- * @param bundle the bundle revision
- * @return <code>true</code> if the bundle is allowed and <code>false</code>otherwise
- */
- public boolean isAllowed(BundleRevision bundle);
-
- /**
- * Determines whether this filter allows the given service reference.
- *
- * @param service the service reference of the service
- * @return <code>true</code> if the service is allowed and <code>false</code>otherwise
- */
- public boolean isAllowed(ServiceReference<?> service);
-
- /**
- * Determines whether this filter allows the given capability.
- *
- * @param capability the bundle capability
- * @return <code>true</code> if the capability is allowed and <code>false</code>otherwise
- */
- public boolean isAllowed(BundleCapability capability);
-
- /**
- * Returns a map of the filters used by each name space for this region filter. The may key is the name space and
- * the value is a collection of filters for the name space. The returned map is a snapshot of the sharing policy.
- * Changes made to the returned map have no affect on this region filter.
- *
- * @return a map containing the sharing policy used by this region filter
- */
- public Map<String, Collection<String>> getSharingPolicy();
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionFilterBuilder.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionFilterBuilder.java
deleted file mode 100644
index 6b95fea9..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionFilterBuilder.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region;
-
-import org.osgi.framework.InvalidSyntaxException;
-
-/**
- * A builder for creating {@link RegionFilter} instances. A builder instance can be obtained from the
- * {@link RegionDigraph#createRegionFilterBuilder()} method.
- * <p />
- * <strong>Concurrent Semantics</strong><br />
- *
- * Implementations of this interface must be thread safe.
- */
-public interface RegionFilterBuilder {
-
- /**
- * Allow capabilities with the given name space matching the given filter.
- *
- * @param namespace the name space of the capabilities to be allowed
- * @param filter the filter matching the capabilities to be allowed
- * @return this builder (for method chaining)
- */
- RegionFilterBuilder allow(String namespace, String filter) throws InvalidSyntaxException;
-
- /**
- * Allow all capabilities with the given name space.
- *
- * @param namespace the name space of the capabilities to be allowed
- * @return this builder (for method chaining)
- */
- RegionFilterBuilder allowAll(String namespace);
-
- /**
- * Build a {@link RegionFilter} from the current state of this builder.
- *
- * @return the {@link RegionFilter} built
- */
- RegionFilter build();
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionManager.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionManager.java
deleted file mode 100644
index 4b67d194..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionManager.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.eclipse.virgo.kernel.osgi.region.hook.RegionBundleEventHook;
-import org.eclipse.virgo.kernel.osgi.region.hook.RegionBundleFindHook;
-import org.eclipse.virgo.kernel.osgi.region.hook.RegionResolverHookFactory;
-import org.eclipse.virgo.kernel.osgi.region.hook.RegionServiceEventHook;
-import org.eclipse.virgo.kernel.osgi.region.hook.RegionServiceFindHook;
-import org.eclipse.virgo.kernel.osgi.region.internal.StandardRegionDigraph;
-import org.eclipse.virgo.kernel.osgi.region.management.internal.StandardManageableRegionDigraph;
-import org.eclipse.virgo.util.osgi.ServiceRegistrationTracker;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.hooks.bundle.EventHook;
-import org.osgi.framework.hooks.bundle.FindHook;
-import org.osgi.framework.hooks.resolver.ResolverHookFactory;
-
-/**
- * Creates and manages the user {@link Region regions}.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- *
- * Threadsafe.
- *
- */
-final class RegionManager {
-
- private static final String REGION_KERNEL = "org.eclipse.virgo.region.kernel";
-
- private final ServiceRegistrationTracker tracker = new ServiceRegistrationTracker();
-
- private final BundleContext bundleContext;
-
- private final ThreadLocal<Region> threadLocal;
-
- private final String domain;
-
- public RegionManager(BundleContext bundleContext, String domain) {
- this.bundleContext = bundleContext;
- this.threadLocal = new ThreadLocal<Region>();
- this.domain = domain;
- }
-
- public void start() throws BundleException {
- RegionDigraph regionDigraph = createRegionDigraph();
- registerRegionHooks(regionDigraph);
- }
-
- private RegionDigraph createRegionDigraph() throws BundleException {
- RegionDigraph regionDigraph = new StandardRegionDigraph(this.bundleContext, this.threadLocal);
- registerDigraphMbean(regionDigraph);
- createKernelRegion(regionDigraph);
- registerRegionDigraph(regionDigraph);
- return regionDigraph;
- }
-
- private void registerDigraphMbean(RegionDigraph regionDigraph) {
- StandardManageableRegionDigraph standardManageableRegionDigraph = new StandardManageableRegionDigraph(regionDigraph, this.domain,
- this.bundleContext);
- standardManageableRegionDigraph.registerMBean();
- }
-
- private Region createKernelRegion(RegionDigraph regionDigraph) throws BundleException {
- Region kernelRegion = regionDigraph.createRegion(REGION_KERNEL);
-
- for (Bundle bundle : this.bundleContext.getBundles()) {
- kernelRegion.addBundle(bundle);
- }
-
- registerRegionService(kernelRegion);
-
- return kernelRegion;
- }
-
- private void registerRegionHooks(RegionDigraph regionDigraph) {
- registerResolverHookFactory(new RegionResolverHookFactory(regionDigraph));
-
- RegionBundleFindHook bundleFindHook = new RegionBundleFindHook(regionDigraph, bundleContext.getBundle().getBundleId());
-
- registerBundleFindHook(bundleFindHook);
-
- registerBundleEventHook(new RegionBundleEventHook(regionDigraph, bundleFindHook, this.threadLocal));
-
- RegionServiceFindHook serviceFindHook = new RegionServiceFindHook(regionDigraph);
-
- registerServiceFindHook(serviceFindHook);
-
- registerServiceEventHook(new RegionServiceEventHook(serviceFindHook));
- }
-
- private void registerRegionDigraph(RegionDigraph regionDigraph) {
- this.tracker.track(this.bundleContext.registerService(RegionDigraph.class, regionDigraph, null));
- }
-
- private void registerServiceFindHook(org.osgi.framework.hooks.service.FindHook serviceFindHook) {
- this.tracker.track(this.bundleContext.registerService(org.osgi.framework.hooks.service.FindHook.class, serviceFindHook, null));
- }
-
- @SuppressWarnings("deprecation")
- private void registerServiceEventHook(org.osgi.framework.hooks.service.EventHook serviceEventHook) {
- this.tracker.track(this.bundleContext.registerService(org.osgi.framework.hooks.service.EventHook.class, serviceEventHook, null));
- }
-
- private void registerBundleFindHook(FindHook findHook) {
- this.tracker.track(this.bundleContext.registerService(FindHook.class, findHook, null));
- }
-
- private void registerBundleEventHook(EventHook eventHook) {
- this.tracker.track(this.bundleContext.registerService(EventHook.class, eventHook, null));
-
- }
-
- private void registerResolverHookFactory(ResolverHookFactory resolverHookFactory) {
- this.tracker.track(this.bundleContext.registerService(ResolverHookFactory.class, resolverHookFactory, null));
- }
-
- private void registerRegionService(Region region) {
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("org.eclipse.virgo.kernel.region.name", region.getName());
- this.tracker.track(this.bundleContext.registerService(Region.class, region, props));
- }
-
- public void stop() {
- this.tracker.unregisterAll();
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleEventHook.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleEventHook.java
deleted file mode 100644
index e4380ba4..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleEventHook.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * This file is part of the Eclipse Virgo project.
- *
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- */
-
-package org.eclipse.virgo.kernel.osgi.region.hook;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.virgo.kernel.core.FatalKernelException;
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.hooks.bundle.EventHook;
-import org.osgi.framework.hooks.bundle.FindHook;
-
-/**
- * {@link RegionBundleEventHook} manages the visibility of bundle events across regions according to the
- * {@link RegionDigraph}.
- * <p>
- * The current implementation delegates to {@link RegionBundleFindHook}. This is likely to perform adequately because of
- * the low frequency of bundle events and the typically small number of bundle listeners.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- * Thread safe.
- */
-public final class RegionBundleEventHook implements EventHook {
-
- private final RegionDigraph regionDigraph;
-
- private final FindHook bundleFindHook;
-
- private final ThreadLocal<Region> threadLocal;
-
- public RegionBundleEventHook(RegionDigraph regionDigraph, FindHook bundleFindBook, ThreadLocal<Region> threadLocal) {
- this.regionDigraph = regionDigraph;
- this.bundleFindHook = bundleFindBook;
- this.threadLocal = threadLocal;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void event(BundleEvent event, Collection<BundleContext> contexts) {
- Bundle eventBundle = event.getBundle();
- if (event.getType() == BundleEvent.INSTALLED) {
- bundleInstalled(eventBundle, event.getOrigin());
- }
- Iterator<BundleContext> i = contexts.iterator();
- while (i.hasNext()) {
- if (!find(i.next(), eventBundle)) {
- i.remove();
- }
- }
- if (event.getType() == BundleEvent.UNINSTALLED) {
- bundleUninstalled(eventBundle);
- }
- }
-
- private boolean find(BundleContext finderBundleContext, Bundle candidateBundle) {
- Collection<Bundle> candidates = new ArrayList<Bundle>(1);
- candidates.add(candidateBundle);
- this.bundleFindHook.find(finderBundleContext, candidates);
- return !candidates.isEmpty();
- }
-
- private void bundleInstalled(Bundle eventBundle, Bundle originBundle) {
- /*
- * BundleIdBasedRegion sets thread local to install bundles into arbitrary regions. If this is not set, the
- * bundle inherits the region of the origin bundle.
- */
- Region installRegion = this.threadLocal.get();
- if (installRegion != null) {
- try {
- installRegion.addBundle(eventBundle);
- } catch (BundleException e) {
- e.printStackTrace();
- throw new FatalKernelException("Bundle could not be added to region", e);
- }
- } else {
- Region originRegion = this.regionDigraph.getRegion(originBundle);
- if (originRegion != null) {
- try {
- originRegion.addBundle(eventBundle);
- } catch (BundleException e) {
- e.printStackTrace();
- throw new FatalKernelException("Bundle could not be added to region", e);
- }
- }
- }
- }
-
- private void bundleUninstalled(Bundle eventBundle) {
- Region region = this.regionDigraph.getRegion(eventBundle);
- if (region != null) {
- region.removeBundle(eventBundle);
- }
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleFindHook.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleFindHook.java
deleted file mode 100644
index f3c12e24..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleFindHook.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.hook;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.hooks.bundle.FindHook;
-
-/**
- * {@link RegionBundleFindHook} manages the visibility of bundles across regions according to the {@link RegionDigraph}.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- * Thread safe.
- */
-public final class RegionBundleFindHook implements FindHook {
-
- private final RegionDigraph regionDigraph;
-
- private final long hookImplID;
-
- public RegionBundleFindHook(RegionDigraph regionDigraph, long hookImplID) {
- this.regionDigraph = regionDigraph;
- this.hookImplID = hookImplID;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void find(BundleContext context, Collection<Bundle> bundles) {
- long bundleID = context.getBundle().getBundleId();
-
- if (bundleID == 0 || bundleID == hookImplID) {
- // The system bundle and the hook impl bundle can see all bundles
- return;
- }
-
- Region finderRegion = getRegion(context);
- if (finderRegion == null) {
- bundles.clear();
- return;
- }
-
- Visitor visitor = new Visitor(bundles);
- finderRegion.visitSubgraph(visitor);
- Set<Bundle> allowed = visitor.getAllowed();
-
- bundles.retainAll(allowed);
- }
-
- private class Visitor extends RegionDigraphVisitorBase<Bundle> {
-
- private Visitor(Collection<Bundle> candidates) {
- super(candidates);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean contains(Region region, Bundle candidate) {
- return region.contains(candidate);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean isAllowed(Bundle candidate, RegionFilter filter) {
- return filter.isAllowed(candidate);
- }
-
- }
-
- private Region getRegion(BundleContext context) {
- return this.regionDigraph.getRegion(context.getBundle());
- }
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionDigraphVisitorBase.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionDigraphVisitorBase.java
deleted file mode 100644
index 84b8b7ff..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionDigraphVisitorBase.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * This file is part of the Virgo Web Server.
- *
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SpringSource, a division of VMware - initial API and implementation and/or initial documentation
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.hook;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.Stack;
-
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraphVisitor;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-
-/**
- * {@link RegionDigraphVisitorBase} is an abstract base class for {@link RegionDigraphVisitor} implementations in the
- * framework hooks.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- * This class is thread safe.
- */
-abstract class RegionDigraphVisitorBase<C> implements RegionDigraphVisitor {
-
- private final Collection<C> allCandidates;
-
- private final Stack<Set<C>> allowedStack = new Stack<Set<C>>();
-
- private Object monitor = new Object();
-
- private Set<C> allowed;
-
- protected RegionDigraphVisitorBase(Collection<C> candidates) {
- this.allCandidates = candidates;
- synchronized (this.monitor) {
- this.allowed = new HashSet<C>();
- }
- }
-
- Set<C> getAllowed() {
- synchronized (this.monitor) {
- return this.allowed;
- }
- }
-
- private void allow(C candidate) {
- synchronized (this.monitor) {
- this.allowed.add(candidate);
- }
- }
-
- private void allow(Set<C> candidates) {
- synchronized (this.monitor) {
- this.allowed.addAll(candidates);
- }
- }
-
- private void pushAllowed() {
- synchronized (this.monitor) {
- this.allowedStack.push(this.allowed);
- this.allowed = new HashSet<C>();
- }
- }
-
- private Set<C> popAllowed() {
- synchronized (this.monitor) {
- Set<C> a = this.allowed;
- this.allowed = this.allowedStack.pop();
- return a;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean visit(Region region) {
- for (C candidate : this.allCandidates) {
- if (contains(region, candidate)) {
- allow(candidate);
- }
- }
- return true;
- }
-
- /**
- * Determines whether the given region contains the given candidate.
- *
- * @param region the {@link Region}
- * @param candidate the candidate
- * @return <code>true</code> if and only if the given region contains the given candidate
- */
- protected abstract boolean contains(Region region, C candidate);
-
- /**
- * {@inheritDoc}
- */
- public boolean preEdgeTraverse(RegionFilter regionFilter) {
- pushAllowed();
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public void postEdgeTraverse(RegionFilter regionFilter) {
- Set<C> candidates = popAllowed();
- filter(candidates, regionFilter);
- allow(candidates);
- }
-
- private void filter(Set<C> candidates, RegionFilter filter) {
- Iterator<C> i = candidates.iterator();
- while (i.hasNext()) {
- C candidate = i.next();
- if (!isAllowed(candidate, filter)) {
- i.remove();
- }
- }
- }
-
- /**
- * Determines whether the given candidate is allowed by the given {@link RegionFilter}.
- *
- * @param candidate the candidate
- * @param filter the filter
- * @return <code>true</code> if and only if the given candidate is allowed by the given filter
- */
- protected abstract boolean isAllowed(C candidate, RegionFilter filter);
-
-} \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionResolverHook.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionResolverHook.java
deleted file mode 100644
index 8adedb56..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionResolverHook.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.hook;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.osgi.service.resolver.BundleDescription;
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.eclipse.virgo.kernel.serviceability.Assert;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.hooks.resolver.ResolverHook;
-import org.osgi.framework.wiring.BundleCapability;
-import org.osgi.framework.wiring.BundleRequirement;
-import org.osgi.framework.wiring.BundleRevision;
-
-/**
- * {@link RegionResolverHook} manages the visibility of bundles across regions according to the {@link RegionDigraph}.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- * Thread safe.
- */
-final class RegionResolverHook implements ResolverHook {
-
- private static final long INVALID_BUNDLE_ID = -1L;
-
- private static final Boolean DEBUG = false;
-
- private final RegionDigraph regionDigraph;
-
- RegionResolverHook(RegionDigraph regionDigraph) {
- this.regionDigraph = regionDigraph;
- }
-
- @Override
- public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) {
- BundleRevision requirer = requirement.getRevision();
- try {
- if (DEBUG) {
- debugEntry(requirer, candidates);
- }
-
- if (getBundleId(requirer) == 0L) {
- return;
- }
-
- Region requirerRegion = getRegion(requirer);
- if (requirerRegion == null) {
- candidates.clear();
- return;
- }
-
- Visitor visitor = new Visitor(candidates);
- requirerRegion.visitSubgraph(visitor);
- Set<BundleCapability> allowed = visitor.getAllowed();
-
- candidates.retainAll(allowed);
- } finally {
- if (DEBUG) {
- debugExit(requirer, candidates);
- }
- }
- }
-
- private class Visitor extends RegionDigraphVisitorBase<BundleCapability> {
-
- private Visitor(Collection<BundleCapability> candidates) {
- super(candidates);
- }
-
- @Override
- protected boolean contains(Region region, BundleCapability candidate) {
- return region.equals(getRegion(candidate.getRevision()));
- }
-
- @Override
- protected boolean isAllowed(BundleCapability candidate, RegionFilter filter) {
- return filter.isAllowed(candidate) || filter.isAllowed(candidate.getRevision());
- }
-
- }
-
- private Region getRegion(BundleRevision bundleRevision) {
- Bundle bundle = bundleRevision.getBundle();
- if (bundle != null) {
- return getRegion(bundle);
- }
- Long bundleId = getBundleId(bundleRevision);
- return getRegion(bundleId);
- }
-
- private Region getRegion(Long bundleId) {
- return this.regionDigraph.getRegion(bundleId);
- }
-
- private Long getBundleId(BundleRevision bundleRevision) {
- // For testability, use the bundle revision's bundle before casting to ResolverBundle.
- Bundle bundle = bundleRevision.getBundle();
- if (bundle != null) {
- return bundle.getBundleId();
- }
- if (bundleRevision instanceof BundleDescription) {
- BundleDescription bundleDescription = (BundleDescription) bundleRevision;
- return bundleDescription.getBundleId();
- }
- Assert.isTrue(false, "Cannot determine bundle id of BundleRevision '%s'", bundleRevision);
- return INVALID_BUNDLE_ID;
- }
-
- private Region getRegion(Bundle bundle) {
- return this.regionDigraph.getRegion(bundle);
- }
-
- @Override
- public void end() {
- }
-
- @Override
- public void filterResolvable(Collection<BundleRevision> candidates) {
- }
-
- @Override
- public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) {
- collisionCandidates.clear(); // XXX temporary hack in lieu of Borislav's changes
- }
-
- private void debugEntry(BundleRevision requirer, Collection<BundleCapability> candidates) {
- System.out.println("Requirer: " + requirer.getSymbolicName() + "_" + requirer.getVersion() + "[" + getBundleId(requirer) + "]");
- System.out.println(" Candidates: ");
- Iterator<BundleCapability> i = candidates.iterator();
- while (i.hasNext()) {
- BundleCapability c = i.next();
- String namespace = c.getNamespace();
- if (BundleRevision.PACKAGE_NAMESPACE.equals(namespace)) {
- BundleRevision providerRevision = c.getRevision();
- String pkg = (String) c.getAttributes().get(BundleRevision.PACKAGE_NAMESPACE);
- System.out.println(" Package " + pkg + " from provider " + providerRevision.getSymbolicName() + "_"
- + providerRevision.getVersion() + "[" + getBundleId(providerRevision) + "]");
- if (pkg.equals("slow")) {
- System.out.println(">>> put breakpoint here <<<");
- }
- } else {
- BundleRevision providerRevision = c.getRevision();
- System.out.println(" Bundle from provider " + providerRevision.getSymbolicName() + "_" + providerRevision.getVersion() + "["
- + getBundleId(providerRevision) + "]");
- }
- }
- }
-
- private void debugExit(BundleRevision requirer, Collection<BundleCapability> candidates) {
- System.out.println(" Filtered candidates: ");
- Iterator<BundleCapability> i = candidates.iterator();
- while (i.hasNext()) {
- BundleCapability c = i.next();
- String namespace = c.getNamespace();
- if (BundleRevision.PACKAGE_NAMESPACE.equals(namespace)) {
- BundleRevision providerRevision = c.getRevision();
- String pkg = (String) c.getAttributes().get(BundleRevision.PACKAGE_NAMESPACE);
- System.out.println(" Package " + pkg + " from provider " + providerRevision.getSymbolicName() + "_"
- + providerRevision.getVersion() + "[" + getBundleId(providerRevision) + "]");
- if (pkg.equals("slow")) {
- System.out.println(">>> put breakpoint here <<<");
- }
- } else {
- BundleRevision providerRevision = c.getRevision();
- System.out.println(" Bundle from provider " + providerRevision.getSymbolicName() + "_" + providerRevision.getVersion() + "["
- + getBundleId(providerRevision) + "]");
- }
- }
- }
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionResolverHookFactory.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionResolverHookFactory.java
deleted file mode 100644
index 57815cf3..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionResolverHookFactory.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * This file is part of the Virgo Web Server.
- *
- * Copyright (c) 2010 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SpringSource, a division of VMware - initial API and implementation and/or initial documentation
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.hook;
-
-import java.util.Collection;
-
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.osgi.framework.hooks.resolver.ResolverHook;
-import org.osgi.framework.hooks.resolver.ResolverHookFactory;
-import org.osgi.framework.wiring.BundleRevision;
-
-/**
- * {@link RegionResolverHook} constructs an instance of {@link RegionResolverHook} for a particular resolution
- * operation.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- *
- * Thread safe.
- */
-public final class RegionResolverHookFactory implements ResolverHookFactory {
-
- private final RegionDigraph regionDigraph;
-
- public RegionResolverHookFactory(RegionDigraph regionDigraph) {
- this.regionDigraph = regionDigraph;
- }
-
- @Override
- public ResolverHook begin(Collection<BundleRevision> triggers) {
- return new RegionResolverHook(this.regionDigraph);
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionServiceEventHook.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionServiceEventHook.java
deleted file mode 100644
index 56610acb..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionServiceEventHook.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * This file is part of the Eclipse Virgo project.
- *
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- */
-
-package org.eclipse.virgo.kernel.osgi.region.hook;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.hooks.service.EventHook;
-import org.osgi.framework.hooks.service.FindHook;
-
-/**
- * {@link RegionServiceEventHook} manages the visibility of service events across regions according to the
- * {@link RegionDigraph}.
- * <p>
- * The current implementation delegates to {@link RegionServiceFindHook}. This is likely to perform adequately because
- * of the relatively low frequency (compared to service lookups) of service events and the typically small number of
- * service listeners.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- * Thread safe.
- */
-@SuppressWarnings("deprecation")
-public final class RegionServiceEventHook implements EventHook {
-
- private final FindHook serviceFindHook;
-
- public RegionServiceEventHook(FindHook bundleFindBook) {
- this.serviceFindHook = bundleFindBook;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void event(ServiceEvent event, Collection<BundleContext> contexts) {
- ServiceReference<?> eventBundle = event.getServiceReference();
- Iterator<BundleContext> i = contexts.iterator();
- while (i.hasNext()) {
- if (!find(i.next(), eventBundle)) {
- i.remove();
- }
- }
- }
-
- private boolean find(BundleContext finderBundleContext, ServiceReference<?> candidateServiceReference) {
- Set<ServiceReference<?>> candidates = new HashSet<ServiceReference<?>>();
- candidates.add(candidateServiceReference);
- this.serviceFindHook.find(finderBundleContext, "", "", false, candidates);
- return !candidates.isEmpty();
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionServiceFindHook.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionServiceFindHook.java
deleted file mode 100644
index a027c33c..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionServiceFindHook.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.hook;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.hooks.service.FindHook;
-
-/**
- * {@link RegionServiceFindHook} manages the visibility of services across regions according to the
- * {@link RegionDigraph}.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- * Thread safe.
- */
-public final class RegionServiceFindHook implements FindHook {
-
- private final RegionDigraph regionDigraph;
-
- public RegionServiceFindHook(RegionDigraph regionDigraph) {
- this.regionDigraph = regionDigraph;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void find(BundleContext context, String name, String filter, boolean allServices, Collection<ServiceReference<?>> references) {
- if (context.getBundle().getBundleId() == 0L) {
- return;
- }
-
- Region finderRegion = getRegion(context);
- if (finderRegion == null) {
- references.clear();
- return;
- }
-
- Visitor visitor = new Visitor(references);
- finderRegion.visitSubgraph(visitor);
- Set<ServiceReference<?>> allowed = visitor.getAllowed();
-
- references.retainAll(allowed);
- }
-
- private class Visitor extends RegionDigraphVisitorBase<ServiceReference<?>> {
-
- private Visitor(Collection<ServiceReference<?>> candidates) {
- super(candidates);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean contains(Region region, ServiceReference<?> candidate) {
- return region.contains(candidate.getBundle());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean isAllowed(ServiceReference<?> candidate, RegionFilter filter) {
- return filter.isAllowed(candidate) || filter.isAllowed(candidate.getBundle());
- }
-
- }
-
- private Region getRegion(BundleContext context) {
- return this.regionDigraph.getRegion(context.getBundle());
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/BundleIdBasedRegion.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/BundleIdBasedRegion.java
deleted file mode 100644
index cfdb39dd..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/BundleIdBasedRegion.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.internal;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph.FilteredRegion;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraphVisitor;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.eclipse.virgo.kernel.serviceability.NonNull;
-import org.eclipse.virgo.util.math.ConcurrentHashSet;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Version;
-
-/**
- * {@link BundleIdBasedRegion} is an implementation of {@link Region} which keeps a track of the bundles in the region
- * by recording their bundle identifiers.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- * Thread safe.
- */
-final class BundleIdBasedRegion implements Region {
-
- private static final String REGION_LOCATION_DELIMITER = "@";
-
- private static final String REFERENCE_SCHEME = "reference:";
-
- private static final String FILE_SCHEME = "file:";
-
- // A concurrent data structure ensures the contains method does not need synchronisation.
- private final Set<Long> bundleIds = new ConcurrentHashSet<Long>();
-
- // Updates do need synchronising to avoid races.
- private final Object updateMonitor = new Object();
-
- private final String regionName;
-
- private final RegionDigraph regionDigraph;
-
- private final BundleContext bundleContext;
-
- private final ThreadLocal<Region> threadLocal;
-
- BundleIdBasedRegion(@NonNull String regionName, @NonNull RegionDigraph regionDigraph, BundleContext bundleContext, ThreadLocal<Region> threadLocal) {
- this.regionName = regionName;
- this.regionDigraph = regionDigraph;
- this.bundleContext = bundleContext;
- this.threadLocal = threadLocal;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getName() {
- return this.regionName;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addBundle(Bundle bundle) throws BundleException {
- synchronized (this.updateMonitor) {
- checkBundleNotAssociatedWithAnotherRegion(bundle);
-
- this.bundleIds.add(bundle.getBundleId());
- }
- }
-
- private void checkBundleNotAssociatedWithAnotherRegion(Bundle bundle) throws BundleException {
- for (Region r : this.regionDigraph) {
- if (!this.equals(r) && r.contains(bundle)) {
- throw new BundleException("Bundle '" + bundle + "' is already associated with region '" + r + "'", BundleException.INVALID_OPERATION);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addBundle(long bundleId) {
- synchronized (this.updateMonitor) {
- this.bundleIds.add(bundleId);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Bundle installBundle(String location, InputStream input) throws BundleException {
- if (this.bundleContext == null)
- throw new BundleException("This region is not connected to an OSGi Framework.", BundleException.INVALID_OPERATION);
- setRegionThreadLocal();
- try {
- return this.bundleContext.installBundle(this.regionName + REGION_LOCATION_DELIMITER + location, input);
- } finally {
- removeRegionThreadLocal();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Bundle installBundle(String location) throws BundleException {
- if (this.bundleContext == null)
- throw new BundleException("This region is not connected to an OSGi Framework.", BundleException.INVALID_OPERATION);
- setRegionThreadLocal();
- try {
- return this.bundleContext.installBundle(this.regionName + REGION_LOCATION_DELIMITER + location, openBundleStream(location));
- } finally {
- removeRegionThreadLocal();
- }
- }
-
- private void setRegionThreadLocal() {
- if (this.threadLocal != null)
- this.threadLocal.set(this);
- }
-
- private void removeRegionThreadLocal() {
- if (this.threadLocal != null)
- this.threadLocal.remove();
- }
-
- private InputStream openBundleStream(String location) throws BundleException {
- String absoluteBundleUriString = getAbsoluteUriString(location);
-
- try {
- // Use the reference: scheme to obtain an InputStream for either a file or a directory.
- return new URL(REFERENCE_SCHEME + absoluteBundleUriString).openStream();
-
- } catch (MalformedURLException e) {
- throw new BundleException("Location '" + location + "' resulted in an invalid bundle URI '" + absoluteBundleUriString + "'", e);
- } catch (IOException e) {
- throw new BundleException("Location '" + location + "' referred to an invalid bundle at URI '" + absoluteBundleUriString + "'", e);
- }
- }
-
- private String getAbsoluteUriString(String location) throws BundleException {
- if (!location.startsWith(FILE_SCHEME)) {
- throw new BundleException("Cannot install from location '" + location + "' which did not start with '" + FILE_SCHEME + "'");
- }
-
- String filePath = location.substring(FILE_SCHEME.length());
-
- return FILE_SCHEME + new File(filePath).getAbsolutePath();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Bundle getBundle(@NonNull String symbolicName, @NonNull Version version) {
- if (bundleContext == null)
- return null; // this region is not connected to an OSGi framework
-
- // The following iteration is weakly consistent and will never throw ConcurrentModificationException.
- for (long bundleId : this.bundleIds) {
- Bundle bundle = bundleContext.getBundle(bundleId);
- if (bundle != null && symbolicName.equals(bundle.getSymbolicName()) && version.equals(bundle.getVersion())) {
- return bundle;
- }
- }
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void connectRegion(Region headRegion, RegionFilter filter) throws BundleException {
- synchronized (this.updateMonitor) {
- this.regionDigraph.connect(this, filter, headRegion);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean contains(Bundle bundle) {
- return this.bundleIds.contains(bundle.getBundleId());
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + this.regionName.hashCode();
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof BundleIdBasedRegion)) {
- return false;
- }
- BundleIdBasedRegion other = (BundleIdBasedRegion) obj;
- return this.regionName.equals(other.regionName);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean contains(long bundleId) {
- return this.bundleIds.contains(bundleId);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void removeBundle(Bundle bundle) {
- removeBundle(bundle.getBundleId());
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void removeBundle(long bundleId) {
- synchronized (this.updateMonitor) {
- this.bundleIds.remove(bundleId);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return getName();
- }
-
- @Override
- public Set<Long> getBundleIds() {
- Set<Long> bundleIds = new HashSet<Long>();
- synchronized (this.updateMonitor) {
- bundleIds.addAll(this.bundleIds);
- }
- return bundleIds;
- }
-
- /**
- * @return
- */
- @Override
- public Set<FilteredRegion> getEdges() {
- return this.regionDigraph.getEdges(this);
- }
-
- @Override
- public void visitSubgraph(RegionDigraphVisitor visitor) {
- this.regionDigraph.visitSubgraph(this, visitor);
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/RegionLifecycleListener.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/RegionLifecycleListener.java
deleted file mode 100644
index c12f0b8d..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/RegionLifecycleListener.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.internal;
-
-import org.eclipse.virgo.kernel.osgi.region.Region;
-
-/**
- * {@link RegionLifecycleListener} is a service interface to listen for regions being added to and deleted from the
- * region digraph.
- * <p />
- * Note that this is an internal interface and is not intended for external use.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- * Implementations of this interface must be thread safe.
- */
-public interface RegionLifecycleListener {
-
- /**
- * Called after the given region is added to the digraph.
- *
- * @param region the region which has been added
- */
- void regionAdded(Region region);
-
- /**
- * Called before the given region is removed from the digraph.
- *
- * @param region the region which is about to be removed
- */
- void regionRemoving(Region region);
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraph.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraph.java
deleted file mode 100644
index 52cab661..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraph.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*******************************************************************************
- * This file is part of the Virgo Web Server.
- *
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SpringSource, a division of VMware - initial API and implementation and/or initial documentation
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.internal;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraphPersistence;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraphVisitor;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilterBuilder;
-import org.eclipse.virgo.kernel.serviceability.NonNull;
-import org.eclipse.virgo.util.math.OrderedPair;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-
-/**
- * {@link StandardRegionDigraph} is the default implementation of {@link RegionDigraph}.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- *
- * Thread safe.
- *
- */
-public final class StandardRegionDigraph implements RegionDigraph {
-
- private final Object monitor = new Object();
-
- private final Set<Region> regions = new HashSet<Region>();
-
- private final Map<OrderedPair<Region, Region>, RegionFilter> filter = new HashMap<OrderedPair<Region, Region>, RegionFilter>();
-
- private final BundleContext bundleContext;
-
- private final ThreadLocal<Region> threadLocal;
-
- private final SubgraphTraverser subgraphTraverser;
-
- StandardRegionDigraph() {
- this(null, null);
- }
-
- public StandardRegionDigraph(BundleContext bundleContext, ThreadLocal<Region> threadLocal) {
- this.subgraphTraverser = new SubgraphTraverser();
- this.bundleContext = bundleContext;
- this.threadLocal = threadLocal;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Region createRegion(String regionName) throws BundleException {
- Region region = new BundleIdBasedRegion(regionName, this, this.bundleContext, this.threadLocal);
- synchronized (this.monitor) {
- if (getRegion(regionName) != null) {
- throw new BundleException("Region '" + regionName + "' already exists", BundleException.UNSUPPORTED_OPERATION);
- }
- this.regions.add(region);
- }
- notifyAdded(region);
- return region;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void connect(@NonNull Region tailRegion, @NonNull RegionFilter filter, @NonNull Region headRegion) throws BundleException {
- if (headRegion.equals(tailRegion)) {
- throw new BundleException("Cannot connect region '" + headRegion + "' to itself", BundleException.UNSUPPORTED_OPERATION);
- }
- OrderedPair<Region, Region> nodePair = new OrderedPair<Region, Region>(tailRegion, headRegion);
- boolean tailAdded = false;
- boolean headAdded = false;
- synchronized (this.monitor) {
- if (this.filter.containsKey(nodePair)) {
- throw new BundleException("Region '" + tailRegion + "' is already connected to region '" + headRegion,
- BundleException.UNSUPPORTED_OPERATION);
- } else {
- checkFilterDoesNotAllowExistingBundle(tailRegion, filter);
- tailAdded = this.regions.add(tailRegion);
- headAdded = this.regions.add(headRegion);
- this.filter.put(nodePair, filter);
- }
- }
- if (tailAdded) {
- notifyAdded(tailRegion);
- }
- if (headAdded) {
- notifyAdded(headRegion);
- }
- }
-
- private void checkFilterDoesNotAllowExistingBundle(Region tailRegion, RegionFilter filter) throws BundleException {
- // TODO: enumerate the bundles in the region and check the filter does not allow any of them
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Iterator<Region> iterator() {
- synchronized (this.monitor) {
- Set<Region> snapshot = new HashSet<Region>(this.regions.size());
- snapshot.addAll(this.regions);
- return snapshot.iterator();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Set<FilteredRegion> getEdges(Region tailRegion) {
- Set<FilteredRegion> edges = new HashSet<FilteredRegion>();
- synchronized (this.monitor) {
- Set<OrderedPair<Region, Region>> regionPairs = this.filter.keySet();
- for (OrderedPair<Region, Region> regionPair : regionPairs) {
- if (tailRegion.equals(regionPair.getFirst())) {
- edges.add(new StandardFilteredRegion(regionPair.getSecond(), this.filter.get(regionPair)));
- }
- }
- }
- return edges;
- }
-
- private static class StandardFilteredRegion implements FilteredRegion {
-
- private Region region;
-
- private RegionFilter regionFilter;
-
- private StandardFilteredRegion(Region region, RegionFilter regionFilter) {
- this.region = region;
- this.regionFilter = regionFilter;
- }
-
- @Override
- public Region getRegion() {
- return this.region;
- }
-
- @Override
- public RegionFilter getFilter() {
- return this.regionFilter;
- }
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Region getRegion(@NonNull String regionName) {
- synchronized (this.monitor) {
- for (Region region : this) {
- if (regionName.equals(region.getName())) {
- return region;
- }
- }
- return null;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Region getRegion(@NonNull Bundle bundle) {
- synchronized (this.monitor) {
- for (Region region : this) {
- if (region.contains(bundle)) {
- return region;
- }
- }
- return null;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Region getRegion(long bundleId) {
- synchronized (this.monitor) {
- for (Region region : this) {
- if (region.contains(bundleId)) {
- return region;
- }
- }
- return null;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void removeRegion(@NonNull Region region) {
- notifyRemoving(region);
- synchronized (this.monitor) {
- this.regions.remove(region);
- Iterator<OrderedPair<Region, Region>> i = this.filter.keySet().iterator();
- while (i.hasNext()) {
- OrderedPair<Region, Region> regionPair = i.next();
- if (region.equals(regionPair.getFirst()) || region.equals(regionPair.getSecond())) {
- i.remove();
- }
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- synchronized (this.monitor) {
- StringBuffer s = new StringBuffer();
- boolean first = true;
- s.append("RegionDigraph{");
- for (Region r : this) {
- if (!first) {
- s.append(", ");
- }
- s.append(r);
- first = false;
- }
- s.append("}");
- s.append("[");
- first = true;
- for (OrderedPair<Region, Region> regionPair : this.filter.keySet()) {
- if (!first) {
- s.append(", ");
- }
- s.append(regionPair.getFirst() + "->" + regionPair.getSecond());
- first = false;
- }
- s.append("]");
- return s.toString();
- }
- }
-
- @Override
- public Set<Region> getRegions() {
- Set<Region> result = new HashSet<Region>();
- synchronized (this.monitor) {
- result.addAll(this.regions);
- }
- return result;
- }
-
- @Override
- public RegionFilterBuilder createRegionFilterBuilder() {
- return new StandardRegionFilterBuilder();
- }
-
- private void notifyAdded(Region region) {
- Set<RegionLifecycleListener> listeners = getListeners();
- for (RegionLifecycleListener listener : listeners) {
- listener.regionAdded(region);
- }
- }
-
- private void notifyRemoving(Region region) {
- Set<RegionLifecycleListener> listeners = getListeners();
- for (RegionLifecycleListener listener : listeners) {
- listener.regionRemoving(region);
- }
- }
-
- private Set<RegionLifecycleListener> getListeners() {
- Set<RegionLifecycleListener> listeners = new HashSet<RegionLifecycleListener>();
- if (this.bundleContext == null)
- return listeners;
- try {
- Collection<ServiceReference<RegionLifecycleListener>> listenerServiceReferences = this.bundleContext.getServiceReferences(
- RegionLifecycleListener.class, null);
- for (ServiceReference<RegionLifecycleListener> listenerServiceReference : listenerServiceReferences) {
- RegionLifecycleListener regionLifecycleListener = this.bundleContext.getService(listenerServiceReference);
- if (regionLifecycleListener != null) {
- listeners.add(regionLifecycleListener);
- }
- }
- } catch (InvalidSyntaxException e) {
- e.printStackTrace();
- }
- return listeners;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void visitSubgraph(Region startingRegion, RegionDigraphVisitor visitor) {
- this.subgraphTraverser.visitSubgraph(startingRegion, visitor);
- }
-
- /**
- * Returns a snapshot of filtered regions
- *
- * @return a snapshot of filtered regions
- */
- Map<Region, Set<FilteredRegion>> getFilteredRegions() {
- Map<Region, Set<FilteredRegion>> result = new HashMap<Region, Set<FilteredRegion>>();
- synchronized (this.monitor) {
- for (Region region : regions) {
- result.put(region, getEdges(region));
- }
- }
- return result;
- }
-
- @Override
- public RegionDigraphPersistence getRegionDigraphPersistence() {
- return new StandardRegionDigraphPersistence();
- }
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraphPersistence.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraphPersistence.java
deleted file mode 100644
index 057f39a6..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraphPersistence.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.internal;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph.FilteredRegion;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraphPersistence;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilterBuilder;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.InvalidSyntaxException;
-
-/**
- *
- * Class used for reading and writing a region digraph to persistent storage.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- * Thread safe.
- */
-final class StandardRegionDigraphPersistence implements RegionDigraphPersistence {
-
- private static final String PERSISTENT_NAME = "virgo region digraph";
-
- private static final int PERSISTENT_VERSION = 1;
-
- static void writeRegionDigraph(DataOutputStream out, RegionDigraph digraph) throws IOException {
- if (!(digraph instanceof StandardRegionDigraph))
- throw new IllegalArgumentException("Only digraphs of type '" + StandardRegionDigraph.class.getName() + "' are allowed: "
- + digraph.getClass().getName());
- Map<Region, Set<FilteredRegion>> filteredRegions = ((StandardRegionDigraph) digraph).getFilteredRegions();
-
- try {
- // write the persistent name and version
- out.writeUTF(PERSISTENT_NAME);
- out.writeInt(PERSISTENT_VERSION);
- // write the number of regions
- out.writeInt(filteredRegions.size());
- // write each region
- for (Region region : filteredRegions.keySet()) {
- writeRegion(out, region);
- }
- // write each edge
- // write number of tail regions
- out.writeInt(filteredRegions.size());
- for (Map.Entry<Region, Set<FilteredRegion>> edges : filteredRegions.entrySet()) {
- // write the number of edges for this tail
- out.writeInt(edges.getValue().size());
- for (FilteredRegion edge : edges.getValue()) {
- writeEdge(out, edges.getKey(), edge.getFilter(), edge.getRegion());
- }
- }
- } finally {
- // note that the output is flushed even on exception
- out.flush();
- }
- }
-
- private static void writeRegion(DataOutputStream out, Region region) throws IOException {
- // write region name
- out.writeUTF(region.getName());
-
- Set<Long> ids = region.getBundleIds();
- // write number of bundles
- out.writeInt(ids.size());
- for (Long id : ids) {
- // write each bundle id
- out.writeLong(id);
- }
- }
-
- private static void writeEdge(DataOutputStream out, Region tail, RegionFilter filter, Region head) throws IOException {
- // write tail region name
- out.writeUTF(tail.getName());
- // write head region name
- out.writeUTF(head.getName());
- // save the sharing policy
- Map<String, Collection<String>> policy = filter.getSharingPolicy();
- // write the number of name spaces
- out.writeInt(policy.size());
- // write each name space policy
- for (Map.Entry<String, Collection<String>> namespace : policy.entrySet()) {
- // write the name space name
- out.writeUTF(namespace.getKey());
- Collection<String> filters = namespace.getValue();
- // write the number of filters
- out.writeInt(filters.size());
- for (String filterSpec : filters) {
- // write each filter
- out.writeUTF(filterSpec);
- }
- }
- }
-
- static RegionDigraph readRegionDigraph(DataInputStream in) throws IOException, InvalidSyntaxException, BundleException {
- RegionDigraph digraph = new StandardRegionDigraph();
-
- // Read and check the persistent name and version
- String persistentName = in.readUTF();
- if (!PERSISTENT_NAME.equals(persistentName)) {
- throw new IllegalArgumentException("Input stream does not represent a digraph");
- }
- int persistentVersion = in.readInt();
- if (PERSISTENT_VERSION != persistentVersion) {
- throw new IllegalArgumentException("Input stream contains a digraph with an incompatible version '" + persistentVersion + "'");
- }
- // read the number of regions
- int numRegions = in.readInt();
- for (int i = 0; i < numRegions; i++) {
- readRegion(in, digraph);
- }
- // read each edge
- // read number of tail regions
- int numTails = in.readInt();
- for (int i = 0; i < numTails; i++) {
- // read the number of edges for this tail
- int numEdges = in.readInt();
- for (int j = 0; j < numEdges; j++) {
- readEdge(in, digraph);
- }
- }
-
- return digraph;
- }
-
- private static Region readRegion(DataInputStream in, RegionDigraph digraph) throws IOException, BundleException {
- // read region name
- String name = in.readUTF();
- Region region = digraph.createRegion(name);
-
- // read number of bundles
- int numIds = in.readInt();
- for (int i = 0; i < numIds; i++) {
- region.addBundle(in.readLong());
- }
- return region;
- }
-
- private static void readEdge(DataInputStream in, RegionDigraph digraph) throws IOException, InvalidSyntaxException, BundleException {
- // read tail region name
- String tailName = in.readUTF();
- Region tail = digraph.getRegion(tailName);
- if (tail == null)
- throw new IOException("Could not find tail region: " + tailName);
- // read head region name
- String headName = in.readUTF();
- Region head = digraph.getRegion(headName);
- if (head == null)
- throw new IOException("Could not find head region: " + headName);
- // read the sharing policy
- RegionFilterBuilder builder = digraph.createRegionFilterBuilder();
- // read the number of name spaces
- int numSpaces = in.readInt();
- // read each name space policy
- for (int i = 0; i < numSpaces; i++) {
- // read the name space name
- String namespace = in.readUTF();
- // read the number of filters
- int numFilters = in.readInt();
- for (int j = 0; j < numFilters; j++) {
- String filter = in.readUTF();
- builder.allow(namespace, filter);
- }
- }
- digraph.connect(tail, builder.build(), head);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public RegionDigraph load(InputStream input) throws IOException {
- try {
- return readRegionDigraph(new DataInputStream(input));
- } catch (InvalidSyntaxException e) {
- // This should never happen since the filters were valid on save
- // propagate as IllegalStateException
- throw new IllegalStateException("Internal error reading a filter", e);
- } catch (BundleException e) {
- // This should never happen since the digraph was valid on save
- // propagate as IllegalStateException
- throw new IllegalStateException("Internal error creating the digraph", e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void save(RegionDigraph digraph, OutputStream output) throws IOException {
- writeRegionDigraph(new DataOutputStream(output), digraph);
- }
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionFilter.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionFilter.java
deleted file mode 100644
index f251bb1a..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionFilter.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.wiring.BundleCapability;
-import org.osgi.framework.wiring.BundleRevision;
-
-final class StandardRegionFilter implements RegionFilter {
-
- private final Map<String, Collection<Filter>> filters;
-
- StandardRegionFilter(Map<String, Collection<Filter>> filters) {
- if (filters == null) {
- throw new IllegalArgumentException("filters must not be null.");
- }
- // must perform deep copy to avoid external changes
- this.filters = new HashMap<String, Collection<Filter>>((int) ((filters.size() / 0.75) + 1));
- for (Map.Entry<String, Collection<Filter>> namespace : filters.entrySet()) {
- Collection<Filter> namespaceFilters = new ArrayList<Filter>(namespace.getValue());
- this.filters.put(namespace.getKey(), namespaceFilters);
- }
- }
-
- /**
- * Determines whether this filter allows the given bundle
- *
- * @param bundle the bundle
- * @return <code>true</code> if the bundle is allowed and <code>false</code>otherwise
- */
- public boolean isAllowed(Bundle bundle) {
- HashMap<String, Object> attrs = new HashMap<String, Object>(3);
- String bsn = bundle.getSymbolicName();
- if (bsn != null)
- attrs.put(VISIBLE_BUNDLE_NAMESPACE, bsn);
- attrs.put(org.osgi.framework.Constants.BUNDLE_VERSION_ATTRIBUTE, bundle.getVersion());
- return isBundleAllowed(attrs);
- }
-
- /**
- * Determines whether this filter allows the given bundle
- *
- * @param bundle the bundle revision
- * @return <code>true</code> if the bundle is allowed and <code>false</code>otherwise
- */
- public boolean isAllowed(BundleRevision bundle) {
- HashMap<String, Object> attrs = new HashMap<String, Object>(3);
- String bsn = bundle.getSymbolicName();
- if (bsn != null)
- attrs.put(VISIBLE_BUNDLE_NAMESPACE, bsn);
- attrs.put(org.osgi.framework.Constants.BUNDLE_VERSION_ATTRIBUTE, bundle.getVersion());
- return isBundleAllowed(attrs);
- }
-
- /**
- * Determines whether this filter allows the bundle with the given attributes
- *
- * @param bundleAttributes the bundle attributes
- * @return <code>true</code> if the bundle is allowed and <code>false</code>otherwise
- */
- private boolean isBundleAllowed(Map<String, ?> bundleAttributes) {
- if (match(filters.get(VISIBLE_BUNDLE_NAMESPACE), bundleAttributes))
- return true;
- return match(filters.get(VISIBLE_ALL_NAMESPACE), bundleAttributes);
- }
-
- private boolean match(Collection<Filter> filters, Map<String, ?> attrs) {
- if (filters == null)
- return false;
- for (Filter filter : filters) {
- if (filter.matches(attrs))
- return true;
- }
- return false;
- }
-
- private boolean match(Collection<Filter> filters, ServiceReference<?> service) {
- if (filters == null)
- return false;
- for (Filter filter : filters) {
- if (filter.match(service))
- return true;
- }
- return false;
- }
-
- /**
- * Determines whether this filter allows the given service reference.
- *
- * @param service the service reference of the service
- * @return <code>true</code> if the service is allowed and <code>false</code>otherwise
- */
- public boolean isAllowed(ServiceReference<?> service) {
- if (match(filters.get(VISIBLE_SERVICE_NAMESPACE), service))
- return true;
- return match(filters.get(VISIBLE_ALL_NAMESPACE), service);
- }
-
- /**
- * Determines whether this filter allows the given capability.
- *
- * @param capability the bundle capability
- * @return <code>true</code> if the capability is allowed and <code>false</code>otherwise
- */
- public boolean isAllowed(BundleCapability capability) {
- String namespace = capability.getNamespace();
- Map<String, ?> attrs = capability.getAttributes();
- if (match(filters.get(namespace), attrs))
- return true;
- return match(filters.get(VISIBLE_ALL_NAMESPACE), attrs);
- }
-
- public Map<String, Collection<String>> getSharingPolicy() {
- Map<String, Collection<String>> result = new HashMap<String, Collection<String>>((int) ((filters.size() / 0.75) + 1));
- for (Map.Entry<String, Collection<Filter>> namespace : filters.entrySet()) {
- result.put(namespace.getKey(), getFilters(namespace.getValue()));
- }
- return result;
- }
-
- private static Collection<String> getFilters(Collection<Filter> filters) {
- Collection<String> result = new ArrayList<String>(filters.size());
- for (Filter filter : filters) {
- result.add(filter.toString());
- }
- return result;
- }
-
- public String toString() {
- return getSharingPolicy().toString();
- }
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionFilterBuilder.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionFilterBuilder.java
deleted file mode 100644
index 421429fd..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionFilterBuilder.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilterBuilder;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.InvalidSyntaxException;
-
-final class StandardRegionFilterBuilder implements RegionFilterBuilder {
-
- private final static String ALL_SPEC = "(|(!(all=*))(all=*))";
-
- private final static Filter ALL;
- static {
- try {
- ALL = FrameworkUtil.createFilter(ALL_SPEC);
- } catch (InvalidSyntaxException e) {
- // should never happen!
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
-
- private final Object monitor = new Object();
-
- private final Map<String, Collection<Filter>> policy = new HashMap<String, Collection<Filter>>();
-
- @Override
- public RegionFilterBuilder allow(String namespace, String filter) throws InvalidSyntaxException {
- if (namespace == null)
- throw new IllegalArgumentException("The namespace must not be null.");
- if (filter == null)
- throw new IllegalArgumentException("The filter must not be null.");
- synchronized (this.monitor) {
- Collection<Filter> namespaceFilters = policy.get(namespace);
- if (namespaceFilters == null) {
- namespaceFilters = new ArrayList<Filter>();
- policy.put(namespace, namespaceFilters);
- }
- // TODO need to use BundleContext.createFilter here
- namespaceFilters.add(FrameworkUtil.createFilter(filter));
- }
- return this;
- }
-
- public RegionFilterBuilder allowAll(String namespace) {
- if (namespace == null)
- throw new IllegalArgumentException("The namespace must not be null.");
- synchronized (this.monitor) {
- Collection<Filter> namespaceFilters = policy.get(namespace);
- if (namespaceFilters == null) {
- namespaceFilters = new ArrayList<Filter>();
- policy.put(namespace, namespaceFilters);
- }
- // remove any other filters since this will override them all.
- namespaceFilters.clear();
- namespaceFilters.add(ALL);
- }
- return this;
- }
-
- @Override
- public RegionFilter build() {
- synchronized (this.monitor) {
- return new StandardRegionFilter(policy);
- }
- }
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/SubgraphTraverser.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/SubgraphTraverser.java
deleted file mode 100644
index 21f8c6f8..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/SubgraphTraverser.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * This file is part of the Virgo Web Server.
- *
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SpringSource, a division of VMware - initial API and implementation and/or initial documentation
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.internal;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraphVisitor;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph.FilteredRegion;
-
-/**
- * {@link SubgraphTraverser} is a utility for traversing a subgraph of a {@link RegionDigraph} calling a
- * {@link RegionDigraphVisitor} on the way.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- * Thread safe.
- */
-final class SubgraphTraverser {
-
- void visitSubgraph(Region startingRegion, RegionDigraphVisitor visitor) {
- visitRemainingSubgraph(startingRegion, visitor, new HashSet<Region>());
- }
-
- private void visitRemainingSubgraph(Region r, RegionDigraphVisitor visitor, Set<Region> path) {
- if (!path.contains(r)) {
- if (visitor.visit(r)) {
- traverseEdges(r, visitor, path);
- }
- }
- }
-
- private void traverseEdges(Region r, RegionDigraphVisitor visitor, Set<Region> path) {
- for (FilteredRegion fr : r.getEdges()) {
- if (visitor.preEdgeTraverse(fr.getFilter())) {
- try {
- visitRemainingSubgraph(fr.getRegion(), visitor, extendPath(r, path));
- } finally {
- visitor.postEdgeTraverse(fr.getFilter());
- }
- }
- }
- }
-
- private Set<Region> extendPath(Region r, Set<Region> path) {
- Set<Region> newPath = new HashSet<Region>(path);
- newPath.add(r);
- return newPath;
- }
-
-} \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/ManageableRegion.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/ManageableRegion.java
deleted file mode 100644
index 1617a220..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/ManageableRegion.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.management;
-
-import javax.management.MXBean;
-
-import org.eclipse.virgo.kernel.osgi.region.Region;
-
-/**
- * A {@link ManageableRegion} is a JMX representation of a {@link Region}.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- * Thread safe.
- */
-@MXBean
-public interface ManageableRegion {
-
- /**
- * Returns the region name.
- *
- * @return the region name
- */
- String getName();
-
- /**
- * Returns the {@ManageableRegion}s that this region depends upon.
- *
- * @return an array of {@link ManageableRegion}s
- */
- ManageableRegion[] getDependencies();
-
- /**
- * Returns the bundle ids belonging to this region.
- *
- * @return an array of bundle ids
- */
- long[] getBundleIds();
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/ManageableRegionDigraph.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/ManageableRegionDigraph.java
deleted file mode 100644
index 4dfc2b51..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/ManageableRegionDigraph.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.management;
-
-import javax.management.MXBean;
-
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-
-/**
- * {@link ManageableRegionDigraph} is a JMX representation of the {@link RegionDigraph}.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- * Thread safe.
- */
-@MXBean
-public interface ManageableRegionDigraph {
-
- /**
- * Gets the {@link ManageableRegion}s in the digraph.
- *
- * @return an array of {@link ManageableRegion}s
- */
- ManageableRegion[] getRegions();
-
- /**
- * Gets the {@link ManageableRegion} with the given name.
- *
- * @param regionName the region name
- * @return a {@link ManageableRegion} or <code>null</code> if there is no region with the given name
- */
- ManageableRegion getRegion(String regionName);
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/internal/RegionObjectNameCreator.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/internal/RegionObjectNameCreator.java
deleted file mode 100644
index d57d87e9..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/internal/RegionObjectNameCreator.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.management.internal;
-
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.eclipse.virgo.kernel.osgi.region.management.ManageableRegion;
-
-/**
- * {@link RegionObjectNameCreator} is responsible for creating {@link ObjectName}s for {@link ManageableRegion}s.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- * Thread safe.
- */
-final class RegionObjectNameCreator {
-
- private final String domain;
-
- RegionObjectNameCreator(String domain) {
- this.domain = domain;
- }
-
- ObjectName getRegionObjectName(String regionName) {
- try {
- return new ObjectName(this.domain + ":type=Region,name=" + regionName);
- } catch (MalformedObjectNameException e) {
- e.printStackTrace();
- return null;
- }
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/internal/StandardManageableRegion.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/internal/StandardManageableRegion.java
deleted file mode 100644
index 2914d33c..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/internal/StandardManageableRegion.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.management.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph.FilteredRegion;
-import org.eclipse.virgo.kernel.osgi.region.management.ManageableRegion;
-import org.eclipse.virgo.kernel.osgi.region.management.ManageableRegionDigraph;
-
-/**
- * {@link StandardManageableRegion} is the default implementation of {@link ManageableRegion}.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- * Thread safe.
- */
-public class StandardManageableRegion implements ManageableRegion {
-
- private final Region region;
-
- private final ManageableRegionDigraph manageableRegionDigraph;
-
- private final RegionDigraph regionDigraph;
-
- public StandardManageableRegion(Region region, ManageableRegionDigraph manageableRegionDigraph, RegionDigraph regionDigraph) {
- this.region = region;
- this.manageableRegionDigraph = manageableRegionDigraph;
- this.regionDigraph = regionDigraph;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getName() {
- return region.getName();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ManageableRegion[] getDependencies() {
- Set<FilteredRegion> edges = this.regionDigraph.getEdges(this.region);
- List<ManageableRegion> dependencies = new ArrayList<ManageableRegion>();
- for (FilteredRegion edge : edges) {
- ManageableRegion manageableRegion = this.manageableRegionDigraph.getRegion(edge.getRegion().getName());
- if (manageableRegion != null) {
- dependencies.add(manageableRegion);
- }
- }
- return dependencies.toArray(new ManageableRegion[dependencies.size()]);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public long[] getBundleIds() {
- Set<Long> bundleIds = this.region.getBundleIds();
- long[] result = new long[bundleIds.size()];
- int i = 0;
- for (Long bundleId : bundleIds) {
- result[i++] = bundleId;
- }
- return result;
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/internal/StandardManageableRegionDigraph.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/internal/StandardManageableRegionDigraph.java
deleted file mode 100644
index 147eff6e..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/management/internal/StandardManageableRegionDigraph.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.management.internal;
-
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.eclipse.virgo.kernel.osgi.region.internal.RegionLifecycleListener;
-import org.eclipse.virgo.kernel.osgi.region.management.ManageableRegion;
-import org.eclipse.virgo.kernel.osgi.region.management.ManageableRegionDigraph;
-import org.osgi.framework.BundleContext;
-
-/**
- * {@link StandardManageableRegionDigraph} is a {@link ManageableRegionDigraph} that delegates to the
- * {@link RegionDigraph}.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- * Thread safe.
- */
-public final class StandardManageableRegionDigraph implements ManageableRegionDigraph {
-
- private final RegionDigraph regionDigraph;
-
- private final String domain;
-
- private final RegionObjectNameCreator regionObjectNameCreator;
-
- private final Map<String, ManageableRegion> manageableRegions = new ConcurrentHashMap<String, ManageableRegion>();
-
- private final BundleContext bundleContext;
-
- private final Object monitor = new Object();
-
- private final MBeanServer mbeanServer;
-
- public StandardManageableRegionDigraph(RegionDigraph regionDigraph, String domain, BundleContext bundleContext) {
- this.regionDigraph = regionDigraph;
- this.domain = domain;
- this.regionObjectNameCreator = new RegionObjectNameCreator(domain);
- this.bundleContext = bundleContext;
- this.mbeanServer = ManagementFactory.getPlatformMBeanServer();
- }
-
- private void registerRegionLifecycleListener() {
- RegionLifecycleListener regionLifecycleListener = new RegionLifecycleListener() {
-
- @Override
- public void regionAdded(Region region) {
- addRegion(region);
- }
-
- @Override
- public void regionRemoving(Region region) {
- removeRegion(region);
- }
-
- };
- this.bundleContext.registerService(RegionLifecycleListener.class, regionLifecycleListener, null);
- }
-
- public void registerMBean() {
- registerRegionLifecycleListener();
- synchronized (this.monitor) {
- // The following alien call is unavoidable to ensure consistency.
- Set<Region> regions = this.regionDigraph.getRegions();
- for (Region region : regions) {
- addRegion(region);
- }
- }
-
- ObjectName name;
- try {
- name = new ObjectName(this.domain + ":type=RegionDigraph");
- } catch (MalformedObjectNameException e) {
- e.printStackTrace();
- throw new RuntimeException("Invalid domain name '" + this.domain + "'", e);
- }
-
- safelyRegisterMBean(this, name);
- }
-
- private void safelyRegisterMBean(Object mbean, ObjectName name) {
- try {
- try {
- this.mbeanServer.registerMBean(mbean, name);
- } catch (InstanceAlreadyExistsException e) {
- // Recover as this happens when a JVM is reused.
- this.mbeanServer.unregisterMBean(name);
- this.mbeanServer.registerMBean(mbean, name);
- }
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException("MBean registration failed", e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ManageableRegion[] getRegions() {
- List<ManageableRegion> regions = new ArrayList<ManageableRegion>();
- synchronized (this.monitor) {
- for (ManageableRegion manageableRegion : this.manageableRegions.values()) {
- regions.add(manageableRegion);
- }
- }
- return regions.toArray(new ManageableRegion[regions.size()]);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ManageableRegion getRegion(String regionName) {
- return this.manageableRegions.get(regionName);
- }
-
- private void addRegion(Region region) {
- StandardManageableRegion manageableRegion = new StandardManageableRegion(region, this, this.regionDigraph);
- safelyRegisterMBean(manageableRegion, this.regionObjectNameCreator.getRegionObjectName(region.getName()));
- synchronized (this.monitor) {
- this.manageableRegions.put(region.getName(), manageableRegion);
- }
- }
-
- private void removeRegion(Region region) {
- String regionName = region.getName();
- synchronized (this.monitor) {
- this.manageableRegions.remove(regionName);
- }
- try {
- this.mbeanServer.unregisterMBean(this.regionObjectNameCreator.getRegionObjectName(regionName));
- } catch (MBeanRegistrationException e) {
- e.printStackTrace();
- throw new RuntimeException("Problem unregistering mbean", e);
- } catch (InstanceNotFoundException e) {
- }
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/resources/META-INF/spring/internal-osgi-context.xml b/org.eclipse.virgo.kernel.osgi/src/main/resources/META-INF/spring/internal-osgi-context.xml
index 0bf7b74c..1c5a2cd1 100644
--- a/org.eclipse.virgo.kernel.osgi/src/main/resources/META-INF/spring/internal-osgi-context.xml
+++ b/org.eclipse.virgo.kernel.osgi/src/main/resources/META-INF/spring/internal-osgi-context.xml
@@ -21,9 +21,6 @@
<osgi:reference id="repository"
interface="org.eclipse.virgo.repository.Repository" />
- <osgi:reference id="compositeBundleFactory"
- interface="org.osgi.service.framework.CompositeBundleFactory" />
-
<osgi:reference id="eventAdmin" interface="org.osgi.service.event.EventAdmin" />
<osgi:reference id="configAdmin"
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/resources/META-INF/spring/osgi-framework-context.xml b/org.eclipse.virgo.kernel.osgi/src/main/resources/META-INF/spring/osgi-framework-context.xml
deleted file mode 100644
index c68c957c..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/resources/META-INF/spring/osgi-framework-context.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
-
- <bean class="org.eclipse.virgo.kernel.osgi.region.RegionManager" init-method="start" destroy-method="stop">
- <constructor-arg ref="bundleContext"/>
- <constructor-arg type="java.lang.String" value="${domain}"/>
- </bean>
-
-</beans>
diff --git a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/RegionManagerTests.java b/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/RegionManagerTests.java
deleted file mode 100644
index 955b4937..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/RegionManagerTests.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.List;
-
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundle;
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
-import org.eclipse.virgo.teststubs.osgi.framework.StubServiceRegistration;
-import org.junit.Test;
-import org.osgi.framework.Version;
-
-public class RegionManagerTests {
-
- @Test
- public void testStartAndStop() throws Exception {
- StubBundleContext bundleContext = new StubBundleContext();
-
- StubBundle stubUserRegionFactoryBundle = new StubBundle("org.eclipse.virgo.kernel.userregionfactory", new Version("2.2.0"));
- bundleContext.addInstalledBundle(stubUserRegionFactoryBundle);
-
- StubBundle stubSystemBundle = new StubBundle(0L, "org.osgi.framework", new Version("0"), "");
- bundleContext.addInstalledBundle(stubSystemBundle);
-
- RegionManager manager = new RegionManager(bundleContext, "test.domain");
- manager.start();
-
- List<StubServiceRegistration<Object>> serviceRegistrations = bundleContext.getServiceRegistrations();
- assertEquals("Region services not registered", 8, serviceRegistrations.size());
-
- manager.stop();
-
- }
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleEventHookTests.java b/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleEventHookTests.java
deleted file mode 100644
index 7c570f81..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleEventHookTests.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * This file is part of the Eclipse Virgo project.
- *
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- */
-
-package org.eclipse.virgo.kernel.osgi.region.hook;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import org.easymock.EasyMock;
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundle;
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.hooks.bundle.EventHook;
-import org.osgi.framework.hooks.bundle.FindHook;
-
-public class RegionBundleEventHookTests {
-
- private FindHook mockFindHook;
-
- private BundleEvent bundleEvent;
-
- private Collection<BundleContext> contexts;
-
- private Bundle eventBundle;
-
- private RegionDigraph mockRegionDigraph;
-
- private ThreadLocal<Region> threadLocal;
-
- @Before
- public void setUp() throws Exception {
- this.mockRegionDigraph = EasyMock.createMock(RegionDigraph.class);
- this.mockFindHook = EasyMock.createMock(FindHook.class);
- this.eventBundle = new StubBundle();
- this.bundleEvent = new BundleEvent(BundleEvent.STARTED, this.eventBundle, this.eventBundle);
- this.contexts = new HashSet<BundleContext>();
- StubBundleContext stubListenerBundleContext = new StubBundleContext();
- this.contexts.add(stubListenerBundleContext);
- this.threadLocal = new ThreadLocal<Region>();
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testEventAllowed() {
- this.mockFindHook = new FindHook() {
-
- @Override
- public void find(BundleContext context, Collection<Bundle> bundles) {
- }
- };
- EventHook eventHook = new RegionBundleEventHook(this.mockRegionDigraph, this.mockFindHook, this.threadLocal);
- eventHook.event(this.bundleEvent, this.contexts);
- assertEquals(1, this.contexts.size());
- }
-
- @Test
- public void testEventNotAllowed() {
- this.mockFindHook = new FindHook() {
-
- @Override
- public void find(BundleContext context, Collection<Bundle> bundles) {
- bundles.clear();
- }
- };
- EventHook eventHook = new RegionBundleEventHook(this.mockRegionDigraph, this.mockFindHook, this.threadLocal);
- eventHook.event(this.bundleEvent, this.contexts);
- assertTrue(this.contexts.isEmpty());
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleFindHookTests.java b/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleFindHookTests.java
deleted file mode 100644
index cdf923dd..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleFindHookTests.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.hook;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilterBuilder;
-import org.eclipse.virgo.kernel.osgi.region.internal.StandardRegionDigraph;
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundle;
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.Version;
-import org.osgi.framework.hooks.bundle.FindHook;
-
-public class RegionBundleFindHookTests {
-
- private static final String BUNDLE_X = "X";
-
- private static final Version BUNDLE_VERSION = new Version("0");
-
- private long bundleId;
-
- private static final String REGION_A = "RegionA";
-
- private static final String BUNDLE_A = "BundleA";
-
- private static final String REGION_B = "RegionB";
-
- private static final String BUNDLE_B = "BundleB";
-
- private static final String REGION_C = "RegionC";
-
- private static final String BUNDLE_C = "BundleC";
-
- private static final String REGION_D = "RegionD";
-
- private static final String BUNDLE_D = "BundleD";
-
- private StandardRegionDigraph digraph;
-
- private FindHook bundleFindHook;
-
- private Map<String, Region> regions;
-
- private Map<String, Bundle> bundles;
-
- private Collection<Bundle> candidates;
-
- private ThreadLocal<Region> threadLocal;
-
- @Before
- public void setUp() throws Exception {
- this.bundleId = 1L;
- this.regions = new HashMap<String, Region>();
- this.bundles = new HashMap<String, Bundle>();
-
- StubBundle stubSystemBundle = new StubBundle(0L, "osgi.framework", new Version("0"), "loc");
- StubBundleContext stubBundleContext = new StubBundleContext();
- stubBundleContext.addInstalledBundle(stubSystemBundle);
- this.threadLocal = new ThreadLocal<Region>();
- this.digraph = new StandardRegionDigraph(stubBundleContext, this.threadLocal);
- this.bundleFindHook = new RegionBundleFindHook(this.digraph, stubSystemBundle.getBundleId());
- this.candidates = new HashSet<Bundle>();
-
- // Create regions A, B, C, D containing bundles A, B, C, D, respectively.
- createRegion(REGION_A, BUNDLE_A);
- createRegion(REGION_B, BUNDLE_B);
- createRegion(REGION_C, BUNDLE_C);
- createRegion(REGION_D, BUNDLE_D);
-
- createBundle(BUNDLE_X);
-
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testFindInSameRegion() {
- this.candidates.add(bundle(BUNDLE_A));
- this.bundleFindHook.find(bundleContext(BUNDLE_A), this.candidates);
- assertTrue(this.candidates.contains(bundle(BUNDLE_A)));
- }
-
- @Test
- public void testFindInDisconnectedRegion() {
- this.candidates.add(bundle(BUNDLE_B));
- this.bundleFindHook.find(bundleContext(BUNDLE_A), this.candidates);
- assertFalse(this.candidates.contains(bundle(BUNDLE_B)));
- }
-
- @Test
- public void testFindConnectedRegionAllowed() throws BundleException, InvalidSyntaxException {
- RegionFilter filter = createFilter(BUNDLE_B);
- region(REGION_A).connectRegion(region(REGION_B), filter);
-
- this.candidates.add(bundle(BUNDLE_B));
- this.bundleFindHook.find(bundleContext(BUNDLE_A), this.candidates);
- assertTrue(this.candidates.contains(bundle(BUNDLE_B)));
- }
-
- @Test
- public void testFindConnectedRegionFiltering() throws BundleException, InvalidSyntaxException {
- region(REGION_A).connectRegion(region(REGION_B), createFilter(BUNDLE_B));
- Bundle x = createBundle(BUNDLE_X);
- region(REGION_B).addBundle(x);
-
- this.candidates.add(bundle(BUNDLE_B));
- this.candidates.add(x);
- this.bundleFindHook.find(bundleContext(BUNDLE_A), this.candidates);
- assertTrue(this.candidates.contains(bundle(BUNDLE_B)));
- assertFalse(this.candidates.contains(x));
- }
-
- @Test
- public void testFindTransitive() throws BundleException, InvalidSyntaxException {
- region(REGION_A).connectRegion(region(REGION_B), createFilter(BUNDLE_C));
- region(REGION_B).connectRegion(region(REGION_C), createFilter(BUNDLE_C));
- region(REGION_C).addBundle(bundle(BUNDLE_X));
-
- this.candidates.add(bundle(BUNDLE_B));
- this.candidates.add(bundle(BUNDLE_C));
- this.candidates.add(bundle(BUNDLE_X));
- this.bundleFindHook.find(bundleContext(BUNDLE_A), this.candidates);
- assertTrue(this.candidates.contains(bundle(BUNDLE_C)));
- assertFalse(this.candidates.contains(bundle(BUNDLE_B)));
- assertFalse(this.candidates.contains(bundle(BUNDLE_X)));
-
- }
-
- @Test
- public void testFindInCyclicGraph() throws BundleException, InvalidSyntaxException {
- region(REGION_D).addBundle(bundle(BUNDLE_X));
-
- region(REGION_A).connectRegion(region(REGION_B), createFilter(BUNDLE_D, BUNDLE_X));
- region(REGION_B).connectRegion(region(REGION_A), createFilter());
-
- region(REGION_B).connectRegion(region(REGION_D), createFilter(BUNDLE_D));
- region(REGION_D).connectRegion(region(REGION_B), createFilter());
-
- region(REGION_B).connectRegion(region(REGION_C), createFilter(BUNDLE_X));
- region(REGION_C).connectRegion(region(REGION_B), createFilter());
-
- region(REGION_C).connectRegion(region(REGION_D), createFilter(BUNDLE_X));
- region(REGION_D).connectRegion(region(REGION_C), createFilter());
-
- region(REGION_A).connectRegion(region(REGION_C), createFilter());
- region(REGION_C).connectRegion(region(REGION_A), createFilter());
-
- region(REGION_D).connectRegion(region(REGION_A), createFilter());
- region(REGION_A).connectRegion(region(REGION_D), createFilter());
-
- // Find from region A.
- this.candidates.add(bundle(BUNDLE_B));
- this.candidates.add(bundle(BUNDLE_C));
- this.candidates.add(bundle(BUNDLE_D));
- this.candidates.add(bundle(BUNDLE_X));
-
- this.bundleFindHook.find(bundleContext(BUNDLE_A), this.candidates);
- assertEquals(2, this.candidates.size());
- assertTrue(this.candidates.contains(bundle(BUNDLE_D)));
- assertTrue(this.candidates.contains(bundle(BUNDLE_X)));
-
- // Find from region B
- this.candidates.add(bundle(BUNDLE_B));
- this.candidates.add(bundle(BUNDLE_C));
- this.candidates.add(bundle(BUNDLE_D));
- this.candidates.add(bundle(BUNDLE_X));
-
- this.bundleFindHook.find(bundleContext(BUNDLE_B), this.candidates);
- assertEquals(3, this.candidates.size());
- assertTrue(this.candidates.contains(bundle(BUNDLE_B)));
- assertTrue(this.candidates.contains(bundle(BUNDLE_D)));
- assertTrue(this.candidates.contains(bundle(BUNDLE_X)));
- }
-
- @Test
- public void testFindFromSystemBundle() {
- this.candidates.add(bundle(BUNDLE_A));
-
- Bundle stubBundle = new StubBundle(0L, "sys", BUNDLE_VERSION, "");
- this.bundleFindHook.find(stubBundle.getBundleContext(), this.candidates);
- assertEquals(1, this.candidates.size());
- assertTrue(this.candidates.contains(bundle(BUNDLE_A)));
- }
-
- @Test
- public void testFindFromBundleInNoRegion() {
- this.candidates.add(bundle(BUNDLE_A));
-
- Bundle stranger = createBundle("stranger");
- this.bundleFindHook.find(stranger.getBundleContext(), this.candidates);
- assertEquals(0, this.candidates.size());
- }
-
- private Region createRegion(String regionName, String... bundleSymbolicNames) throws BundleException {
- Region region = this.digraph.createRegion(regionName);
- for (String bundleSymbolicName : bundleSymbolicNames) {
- Bundle stubBundle = createBundle(bundleSymbolicName);
- region.addBundle(stubBundle);
- }
- this.regions.put(regionName, region);
- return region;
- }
-
- private Region region(String regionName) {
- return this.regions.get(regionName);
- }
-
- private RegionFilter createFilter(String... bundleSymbolicNames) throws InvalidSyntaxException {
- Collection<String> filters = new ArrayList<String>(bundleSymbolicNames.length);
- for (String bundleSymbolicName : bundleSymbolicNames) {
- filters.add('(' + RegionFilter.VISIBLE_BUNDLE_NAMESPACE + '=' + bundleSymbolicName + ')');
- }
- RegionFilterBuilder builder = digraph.createRegionFilterBuilder();
- for (String filter : filters) {
- builder.allow(RegionFilter.VISIBLE_BUNDLE_NAMESPACE, filter);
- }
- return builder.build();
- }
-
- private Bundle createBundle(String bundleSymbolicName) {
- Bundle stubBundle = new StubBundle(this.bundleId++, bundleSymbolicName, BUNDLE_VERSION, "loc:" + bundleSymbolicName);
- this.bundles.put(bundleSymbolicName, stubBundle);
- return stubBundle;
- }
-
- private BundleContext bundleContext(String bundleSymbolicName) {
- return bundle(bundleSymbolicName).getBundleContext();
- }
-
- private Bundle bundle(String bundleSymbolicName) {
- Bundle bundleA = this.bundles.get(bundleSymbolicName);
- return bundleA;
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionResolverHookTests.java b/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionResolverHookTests.java
deleted file mode 100644
index df294de3..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionResolverHookTests.java
+++ /dev/null
@@ -1,547 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.hook;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilterBuilder;
-import org.eclipse.virgo.kernel.osgi.region.internal.StandardRegionDigraph;
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundle;
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.Version;
-import org.osgi.framework.hooks.resolver.ResolverHook;
-import org.osgi.framework.wiring.BundleCapability;
-import org.osgi.framework.wiring.BundleRequirement;
-import org.osgi.framework.wiring.BundleRevision;
-import org.osgi.framework.wiring.BundleWiring;
-
-public class RegionResolverHookTests {
-
- private static final String PACKAGE_A = "package.a";
-
- private static final String PACKAGE_B = "package.b";
-
- private static final String PACKAGE_C = "package.c";
-
- private static final String PACKAGE_D = "package.d";
-
- private static final String PACKAGE_X = "package.x";
-
- private static final String BUNDLE_X = "X";
-
- private static final Version BUNDLE_VERSION = new Version("0");
-
- private long bundleId;
-
- private static final String REGION_A = "RegionA";
-
- private static final String BUNDLE_A = "BundleA";
-
- private static final String REGION_B = "RegionB";
-
- private static final String BUNDLE_B = "BundleB";
-
- private static final String REGION_C = "RegionC";
-
- private static final String BUNDLE_C = "BundleC";
-
- private static final String REGION_D = "RegionD";
-
- private static final String BUNDLE_D = "BundleD";
-
- private StandardRegionDigraph digraph;
-
- private ResolverHook resolverHook;
-
- private Map<String, Region> regions;
-
- private Map<String, Bundle> bundles;
-
- private Collection<BundleCapability> candidates;
-
- private ThreadLocal<Region> threadLocal;
-
- @Before
- public void setUp() throws Exception {
- this.bundleId = 1L;
- this.regions = new HashMap<String, Region>();
- this.bundles = new HashMap<String, Bundle>();
- this.threadLocal = new ThreadLocal<Region>();
- StubBundle stubSystemBundle = new StubBundle(0L, "osgi.framework", new Version("0"), "loc");
- StubBundleContext stubBundleContext = new StubBundleContext();
- stubBundleContext.addInstalledBundle(stubSystemBundle);
- this.digraph = new StandardRegionDigraph(stubBundleContext, this.threadLocal);
- this.resolverHook = new RegionResolverHook(this.digraph);
- this.candidates = new HashSet<BundleCapability>();
-
- // Create regions A, B, C, D containing bundles A, B, C, D, respectively.
- createRegion(REGION_A, BUNDLE_A);
- createRegion(REGION_B, BUNDLE_B);
- createRegion(REGION_C, BUNDLE_C);
- createRegion(REGION_D, BUNDLE_D);
-
- createBundle(BUNDLE_X);
-
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testResolveInSameRegion() {
- this.candidates.add(packageCapability(BUNDLE_A, PACKAGE_A));
- this.resolverHook.filterMatches(bundleRequirement(BUNDLE_A), this.candidates);
- assertTrue(this.candidates.contains(packageCapability(BUNDLE_A, PACKAGE_A)));
- }
-
- @Test
- public void testResolveInDisconnectedRegion() {
- this.candidates.add(packageCapability(BUNDLE_B, PACKAGE_B));
- this.resolverHook.filterMatches(bundleRequirement(BUNDLE_A), this.candidates);
- assertFalse(this.candidates.contains(packageCapability(BUNDLE_B, PACKAGE_B)));
- }
-
- @Test
- public void testResolveConnectedRegionAllowed() throws BundleException, InvalidSyntaxException {
- RegionFilter filter = createFilter(PACKAGE_B);
- region(REGION_A).connectRegion(region(REGION_B), filter);
-
- this.candidates.add(packageCapability(BUNDLE_B, PACKAGE_B));
- this.resolverHook.filterMatches(bundleRequirement(BUNDLE_A), this.candidates);
- assertTrue(this.candidates.contains(packageCapability(BUNDLE_B, PACKAGE_B)));
- }
-
- @Test
- public void testResolveBundleCapabilityConnectedRegionAllowed() throws BundleException, InvalidSyntaxException {
- RegionFilter filter = createBundleFilter(BUNDLE_B, BUNDLE_VERSION);
- region(REGION_A).connectRegion(region(REGION_B), filter);
-
- this.candidates.add(bundleCapability(BUNDLE_B));
- this.resolverHook.filterMatches(bundleRequirement(BUNDLE_A), this.candidates);
- assertTrue(this.candidates.contains(bundleCapability(BUNDLE_B)));
- }
-
- @Test
- public void testResolveConnectedRegionFiltering() throws BundleException, InvalidSyntaxException {
- region(REGION_A).connectRegion(region(REGION_B), createFilter(PACKAGE_B));
- Bundle x = createBundle(BUNDLE_X);
- region(REGION_B).addBundle(x);
-
- this.candidates.add(packageCapability(BUNDLE_B, PACKAGE_B));
- this.candidates.add(packageCapability(BUNDLE_X, PACKAGE_X));
- this.resolverHook.filterMatches(bundleRequirement(BUNDLE_A), this.candidates);
- assertTrue(this.candidates.contains(packageCapability(BUNDLE_B, PACKAGE_B)));
- assertFalse(this.candidates.contains(packageCapability(BUNDLE_X, PACKAGE_X)));
- }
-
- @Test
- public void testResolveBundleConnectedRegionFiltering() throws BundleException, InvalidSyntaxException {
- RegionFilter filter = createBundleFilter(BUNDLE_B, BUNDLE_VERSION);
- region(REGION_A).connectRegion(region(REGION_B), filter);
- Bundle x = createBundle(BUNDLE_X);
- region(REGION_B).addBundle(x);
-
- this.candidates.add(bundleCapability(BUNDLE_B));
- this.candidates.add(bundleCapability(BUNDLE_X));
- this.resolverHook.filterMatches(bundleRequirement(BUNDLE_A), this.candidates);
- assertTrue(this.candidates.contains(bundleCapability(BUNDLE_B)));
- assertFalse(this.candidates.contains(bundleCapability(BUNDLE_X)));
- }
-
- @Test
- public void testResolveTransitive() throws BundleException, InvalidSyntaxException {
- region(REGION_A).connectRegion(region(REGION_B), createFilter(PACKAGE_C));
- region(REGION_B).connectRegion(region(REGION_C), createFilter(PACKAGE_C));
- region(REGION_C).addBundle(bundle(BUNDLE_X));
-
- this.candidates.add(packageCapability(BUNDLE_B, PACKAGE_B));
- this.candidates.add(packageCapability(BUNDLE_C, PACKAGE_C));
- this.candidates.add(packageCapability(BUNDLE_X, PACKAGE_X));
- this.resolverHook.filterMatches(bundleRequirement(BUNDLE_A), this.candidates);
- assertTrue(this.candidates.contains(packageCapability(BUNDLE_C, PACKAGE_C)));
- assertFalse(this.candidates.contains(packageCapability(BUNDLE_B, PACKAGE_B)));
- assertFalse(this.candidates.contains(packageCapability(BUNDLE_X, PACKAGE_X)));
-
- }
-
- @Test
- public void testResolveInCyclicGraph() throws BundleException, InvalidSyntaxException {
- region(REGION_D).addBundle(bundle(BUNDLE_X));
-
- region(REGION_A).connectRegion(region(REGION_B), createFilter(PACKAGE_D, PACKAGE_X));
- region(REGION_B).connectRegion(region(REGION_A), createFilter());
-
- region(REGION_B).connectRegion(region(REGION_D), createFilter(PACKAGE_D));
- region(REGION_D).connectRegion(region(REGION_B), createFilter());
-
- region(REGION_B).connectRegion(region(REGION_C), createFilter(PACKAGE_X));
- region(REGION_C).connectRegion(region(REGION_B), createFilter());
-
- region(REGION_C).connectRegion(region(REGION_D), createFilter(PACKAGE_X));
- region(REGION_D).connectRegion(region(REGION_C), createFilter());
-
- region(REGION_A).connectRegion(region(REGION_C), createFilter());
- region(REGION_C).connectRegion(region(REGION_A), createFilter());
-
- region(REGION_D).connectRegion(region(REGION_A), createFilter());
- region(REGION_A).connectRegion(region(REGION_D), createFilter());
-
- // Find from region A.
- this.candidates.add(packageCapability(BUNDLE_B, PACKAGE_B));
- this.candidates.add(packageCapability(BUNDLE_C, PACKAGE_C));
- this.candidates.add(packageCapability(BUNDLE_D, PACKAGE_D));
- this.candidates.add(packageCapability(BUNDLE_X, PACKAGE_X));
-
- this.resolverHook.filterMatches(bundleRequirement(BUNDLE_A), this.candidates);
- assertEquals(2, this.candidates.size());
- assertTrue(this.candidates.contains(packageCapability(BUNDLE_D, PACKAGE_D)));
- assertTrue(this.candidates.contains(packageCapability(BUNDLE_X, PACKAGE_X)));
-
- // Find from region B
- this.candidates.add(packageCapability(BUNDLE_B, PACKAGE_B));
- this.candidates.add(packageCapability(BUNDLE_C, PACKAGE_C));
- this.candidates.add(packageCapability(BUNDLE_D, PACKAGE_D));
- this.candidates.add(packageCapability(BUNDLE_X, PACKAGE_X));
-
- this.resolverHook.filterMatches(bundleRequirement(BUNDLE_B), this.candidates);
- assertEquals(3, this.candidates.size());
- assertTrue(this.candidates.contains(packageCapability(BUNDLE_B, PACKAGE_B)));
- assertTrue(this.candidates.contains(packageCapability(BUNDLE_D, PACKAGE_D)));
- assertTrue(this.candidates.contains(packageCapability(BUNDLE_X, PACKAGE_X)));
- }
-
- @Test
- public void testResolveFromSystemBundle() {
- this.candidates.add(packageCapability(BUNDLE_A, PACKAGE_A));
-
- Bundle stubBundle = new StubBundle(0L, "sys", BUNDLE_VERSION, "");
- this.resolverHook.filterMatches(new StubBundleRequirement(stubBundle), this.candidates);
- assertEquals(1, this.candidates.size());
- assertTrue(this.candidates.contains(packageCapability(BUNDLE_A, PACKAGE_A)));
- }
-
- @Test
- public void testResolveFromBundleInNoRegion() {
- this.candidates.add(packageCapability(BUNDLE_A, PACKAGE_A));
-
- Bundle stranger = createBundle("stranger");
- this.resolverHook.filterMatches(new StubBundleRequirement(stranger), this.candidates);
- assertEquals(0, this.candidates.size());
- }
-
- @Test
- public void testUnimplementedMethods() {
- this.resolverHook.filterResolvable(null);
- this.resolverHook.end();
- }
-
- private BundleCapability packageCapability(final String bundleSymbolicName, String packageName) {
- return new StubPackageCapability(bundleSymbolicName, packageName);
- }
-
- private BundleCapability bundleCapability(String bundleSymbolicName) {
- return new StubBundleCapability(bundleSymbolicName);
- }
-
- private Region createRegion(String regionName, String... bundleSymbolicNames) throws BundleException {
- Region region = this.digraph.createRegion(regionName);
- for (String bundleSymbolicName : bundleSymbolicNames) {
- Bundle stubBundle = createBundle(bundleSymbolicName);
- region.addBundle(stubBundle);
- }
- this.regions.put(regionName, region);
- return region;
- }
-
- private Region region(String regionName) {
- return this.regions.get(regionName);
- }
-
- private RegionFilter createFilter(final String... packageNames) throws InvalidSyntaxException {
- Collection<String> filters = new ArrayList<String>(packageNames.length);
- for (String pkg : packageNames) {
- filters.add('(' + RegionFilter.VISIBLE_PACKAGE_NAMESPACE + '=' + pkg + ')');
- }
- RegionFilterBuilder builder = digraph.createRegionFilterBuilder();
- for (String filter : filters) {
- builder.allow(RegionFilter.VISIBLE_PACKAGE_NAMESPACE, filter);
- }
- return builder.build();
- }
-
- private RegionFilter createBundleFilter(String bundleSymbolicName, Version bundleVersion) throws InvalidSyntaxException {
- String bundleFilter = "(&(" + RegionFilter.VISIBLE_BUNDLE_NAMESPACE + '=' + bundleSymbolicName + ')' + '('
- + Constants.BUNDLE_VERSION_ATTRIBUTE + ">=" + (bundleVersion == null ? "0" : bundleVersion.toString()) + "))";
- RegionFilterBuilder builder = digraph.createRegionFilterBuilder();
- return builder.allow(RegionFilter.VISIBLE_BUNDLE_NAMESPACE, bundleFilter).build();
- }
-
- private Bundle createBundle(String bundleSymbolicName) {
- Bundle stubBundle = new StubBundle(this.bundleId++, bundleSymbolicName, BUNDLE_VERSION, "loc:" + bundleSymbolicName);
- this.bundles.put(bundleSymbolicName, stubBundle);
- return stubBundle;
- }
-
- private BundleRequirement bundleRequirement(String bundleSymbolicName) {
- return new StubBundleRequirement(bundle(bundleSymbolicName));
- }
-
- private Bundle bundle(String bundleSymbolicName) {
- Bundle bundleA = this.bundles.get(bundleSymbolicName);
- return bundleA;
- }
-
- private final class StubPackageCapability implements BundleCapability {
-
- private final String bundleSymbolicName;
-
- private final String packageName;
-
- private StubPackageCapability(String bundleSymbolicName, String packageName) {
- this.bundleSymbolicName = bundleSymbolicName;
- this.packageName = packageName;
- }
-
- @Override
- public String getNamespace() {
- return BundleRevision.PACKAGE_NAMESPACE;
- }
-
- @Override
- public Map<String, String> getDirectives() {
- return new HashMap<String, String>();
- }
-
- @Override
- public Map<String, Object> getAttributes() {
- HashMap<String, Object> attributes = new HashMap<String, Object>();
- attributes.put(BundleRevision.PACKAGE_NAMESPACE, this.packageName);
- return attributes;
- }
-
- @Override
- public BundleRevision getRevision() {
- return new StubBundleRevision(bundle(this.bundleSymbolicName));
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + getOuterType().hashCode();
- result = prime * result + (this.bundleSymbolicName == null ? 0 : this.bundleSymbolicName.hashCode());
- result = prime * result + (this.packageName == null ? 0 : this.packageName.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof StubPackageCapability)) {
- return false;
- }
- StubPackageCapability other = (StubPackageCapability) obj;
- if (!getOuterType().equals(other.getOuterType())) {
- return false;
- }
- if (this.bundleSymbolicName == null) {
- if (other.bundleSymbolicName != null) {
- return false;
- }
- } else if (!this.bundleSymbolicName.equals(other.bundleSymbolicName)) {
- return false;
- }
- if (this.packageName == null) {
- if (other.packageName != null) {
- return false;
- }
- } else if (!this.packageName.equals(other.packageName)) {
- return false;
- }
- return true;
- }
-
- private RegionResolverHookTests getOuterType() {
- return RegionResolverHookTests.this;
- }
-
- }
-
- private final class StubBundleCapability implements BundleCapability {
-
- private final String bundleSymbolicName;
-
- private StubBundleCapability(String bundleSymbolicName) {
- this.bundleSymbolicName = bundleSymbolicName;
- }
-
- @Override
- public String getNamespace() {
- return BundleRevision.BUNDLE_NAMESPACE;
- }
-
- @Override
- public Map<String, String> getDirectives() {
- return new HashMap<String, String>();
- }
-
- @Override
- public Map<String, Object> getAttributes() {
- HashMap<String, Object> attributes = new HashMap<String, Object>();
- attributes.put(BundleRevision.BUNDLE_NAMESPACE, bundleSymbolicName);
- return attributes;
- }
-
- @Override
- public BundleRevision getRevision() {
- return new StubBundleRevision(bundle(this.bundleSymbolicName));
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + getOuterType().hashCode();
- result = prime * result + ((bundleSymbolicName == null) ? 0 : bundleSymbolicName.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof StubBundleCapability))
- return false;
- StubBundleCapability other = (StubBundleCapability) obj;
- if (!getOuterType().equals(other.getOuterType()))
- return false;
- if (bundleSymbolicName == null) {
- if (other.bundleSymbolicName != null)
- return false;
- } else if (!bundleSymbolicName.equals(other.bundleSymbolicName))
- return false;
- return true;
- }
-
- private RegionResolverHookTests getOuterType() {
- return RegionResolverHookTests.this;
- }
-
- }
-
- private final class StubBundleRequirement implements BundleRequirement {
-
- private final StubBundleRevision bundleRevision;
-
- private StubBundleRequirement(Bundle bundle) {
- this.bundleRevision = new StubBundleRevision(bundle);
- }
-
- @Override
- public String getNamespace() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Map<String, String> getDirectives() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Map<String, Object> getAttributes() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BundleRevision getRevision() {
- return this.bundleRevision;
- }
-
- @Override
- public boolean matches(BundleCapability capability) {
- throw new UnsupportedOperationException();
- }
-
- }
-
- private final class StubBundleRevision implements BundleRevision {
-
- private final Bundle bundle;
-
- private StubBundleRevision(Bundle bundle) {
- this.bundle = bundle;
- }
-
- @Override
- public Bundle getBundle() {
- return this.bundle;
- }
-
- @Override
- public String getSymbolicName() {
- return this.bundle.getSymbolicName();
- }
-
- @Override
- public Version getVersion() {
- return this.bundle.getVersion();
- }
-
- @Override
- public List<BundleCapability> getDeclaredCapabilities(String namespace) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getTypes() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public List<BundleRequirement> getDeclaredRequirements(String namespace) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BundleWiring getWiring() {
- throw new UnsupportedOperationException();
- }
-
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionServiceEventHookTests.java b/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionServiceEventHookTests.java
deleted file mode 100644
index 40553936..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionServiceEventHookTests.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * This file is part of the Eclipse Virgo project.
- *
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- */
-
-package org.eclipse.virgo.kernel.osgi.region.hook;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import org.easymock.EasyMock;
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundle;
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
-import org.eclipse.virgo.teststubs.osgi.framework.StubServiceReference;
-import org.eclipse.virgo.teststubs.osgi.framework.StubServiceRegistration;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.hooks.service.EventHook;
-import org.osgi.framework.hooks.service.FindHook;
-
-@SuppressWarnings("deprecation")
-public class RegionServiceEventHookTests {
-
- private FindHook mockFindHook;
-
- private ServiceEvent serviceEvent;
-
- private Collection<BundleContext> contexts;
-
- private Bundle eventBundle;
-
- @Before
- public void setUp() throws Exception {
- this.mockFindHook = EasyMock.createMock(FindHook.class);
- this.eventBundle = new StubBundle();
- StubServiceReference<Object> stubServiceReference = new StubServiceReference<Object>(new StubServiceRegistration<Object>(
- (StubBundleContext) this.eventBundle.getBundleContext(), Object.class.getName()));
- this.serviceEvent = new ServiceEvent(ServiceEvent.REGISTERED, stubServiceReference);
- this.contexts = new HashSet<BundleContext>();
- StubBundleContext stubListenerBundleContext = new StubBundleContext();
- this.contexts.add(stubListenerBundleContext);
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testEventAllowed() {
- this.mockFindHook = new FindHook() {
-
- @Override
- public void find(BundleContext context, String name, String filter, boolean allServices, Collection<ServiceReference<?>> references) {
- }
- };
- EventHook eventHook = new RegionServiceEventHook(this.mockFindHook);
- eventHook.event(this.serviceEvent, this.contexts);
- assertEquals(1, this.contexts.size());
- }
-
- @Test
- public void testEventNotAllowed() {
- this.mockFindHook = new FindHook() {
-
- @Override
- public void find(BundleContext context, String name, String filter, boolean allServices, Collection<ServiceReference<?>> references) {
- references.clear();
- }
- };
- EventHook eventHook = new RegionServiceEventHook(this.mockFindHook);
- eventHook.event(this.serviceEvent, this.contexts);
- assertTrue(this.contexts.isEmpty());
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionServiceFindHookTests.java b/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionServiceFindHookTests.java
deleted file mode 100644
index 46e72882..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionServiceFindHookTests.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.hook;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilterBuilder;
-import org.eclipse.virgo.kernel.osgi.region.internal.StandardRegionDigraph;
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundle;
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
-import org.eclipse.virgo.teststubs.osgi.framework.StubServiceReference;
-import org.eclipse.virgo.teststubs.osgi.framework.StubServiceRegistration;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.Version;
-import org.osgi.framework.hooks.service.FindHook;
-
-/**
- * This testcase was based on {@link RegionBundleFindHookTests}.
- */
-public class RegionServiceFindHookTests {
-
- private static final String BUNDLE_X = "X";
-
- private static final Version BUNDLE_VERSION = new Version("0");
-
- private long bundleId;
-
- private static final String REGION_A = "RegionA";
-
- private static final String BUNDLE_A = "BundleA";
-
- private static final String REGION_B = "RegionB";
-
- private static final String BUNDLE_B = "BundleB";
-
- private static final String REGION_C = "RegionC";
-
- private static final String BUNDLE_C = "BundleC";
-
- private static final String REGION_D = "RegionD";
-
- private static final String BUNDLE_D = "BundleD";
-
- private StandardRegionDigraph digraph;
-
- private FindHook bundleFindHook;
-
- private Map<String, Region> regions;
-
- private Map<String, Bundle> bundles;
-
- private Map<String, ServiceReference<Object>> serviceReferences;
-
- private Collection<ServiceReference<?>> candidates;
-
- private ThreadLocal<Region> threadLocal;
-
- @Before
- public void setUp() throws Exception {
- this.bundleId = 1L;
- this.regions = new HashMap<String, Region>();
- this.bundles = new HashMap<String, Bundle>();
- this.serviceReferences = new HashMap<String, ServiceReference<Object>>();
-
- StubBundle stubSystemBundle = new StubBundle(0L, "osgi.framework", new Version("0"), "loc");
- StubBundleContext stubBundleContext = new StubBundleContext();
- stubBundleContext.addInstalledBundle(stubSystemBundle);
- this.threadLocal = new ThreadLocal<Region>();
- this.digraph = new StandardRegionDigraph(stubBundleContext, this.threadLocal);
- this.bundleFindHook = new RegionServiceFindHook(this.digraph);
- this.candidates = new HashSet<ServiceReference<?>>();
-
- // Create regions A, B, C, D containing bundles A, B, C, D, respectively.
- createRegion(REGION_A, BUNDLE_A);
- createRegion(REGION_B, BUNDLE_B);
- createRegion(REGION_C, BUNDLE_C);
- createRegion(REGION_D, BUNDLE_D);
-
- createBundle(BUNDLE_X);
-
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testFindInSameRegion() {
- this.candidates.add(serviceReference(BUNDLE_A));
- this.bundleFindHook.find(bundleContext(BUNDLE_A), "", "", false, this.candidates);
- assertTrue(this.candidates.contains(serviceReference(BUNDLE_A)));
- }
-
- @Test
- public void testFindInDisconnectedRegion() {
- this.candidates.add(serviceReference(BUNDLE_B));
- this.bundleFindHook.find(bundleContext(BUNDLE_A), "", "", false, this.candidates);
- assertFalse(this.candidates.contains(serviceReference(BUNDLE_B)));
- }
-
- @Test
- public void testFindConnectedRegionAllowed() throws BundleException, InvalidSyntaxException {
- RegionFilter filter = createFilter(BUNDLE_B);
- region(REGION_A).connectRegion(region(REGION_B), filter);
-
- this.candidates.add(serviceReference(BUNDLE_B));
- this.bundleFindHook.find(bundleContext(BUNDLE_A), "", "", false, this.candidates);
- assertTrue(this.candidates.contains(serviceReference(BUNDLE_B)));
- }
-
- @Test
- public void testFindConnectedRegionFiltering() throws BundleException, InvalidSyntaxException {
- region(REGION_A).connectRegion(region(REGION_B), createFilter(BUNDLE_B));
- Bundle x = createBundle(BUNDLE_X);
- region(REGION_B).addBundle(x);
-
- this.candidates.add(serviceReference(BUNDLE_B));
- this.candidates.add(serviceReference(BUNDLE_X));
- this.bundleFindHook.find(bundleContext(BUNDLE_A), "", "", false, this.candidates);
- assertTrue(this.candidates.contains(serviceReference(BUNDLE_B)));
- assertFalse(this.candidates.contains(serviceReference(BUNDLE_X)));
- }
-
- @Test
- public void testFindTransitive() throws BundleException, InvalidSyntaxException {
- region(REGION_A).connectRegion(region(REGION_B), createFilter(BUNDLE_C));
- region(REGION_B).connectRegion(region(REGION_C), createFilter(BUNDLE_C));
- region(REGION_C).addBundle(bundle(BUNDLE_X));
-
- this.candidates.add(serviceReference(BUNDLE_B));
- this.candidates.add(serviceReference(BUNDLE_C));
- this.bundleFindHook.find(bundleContext(BUNDLE_A), "", "", false, this.candidates);
- assertTrue(this.candidates.contains(serviceReference(BUNDLE_C)));
- assertFalse(this.candidates.contains(serviceReference(BUNDLE_B)));
- assertFalse(this.candidates.contains(serviceReference(BUNDLE_X)));
-
- }
-
- @Test
- public void testFindInCyclicGraph() throws BundleException, InvalidSyntaxException {
- region(REGION_D).addBundle(bundle(BUNDLE_X));
-
- region(REGION_A).connectRegion(region(REGION_B), createFilter(BUNDLE_D, BUNDLE_X));
- region(REGION_B).connectRegion(region(REGION_A), createFilter());
-
- region(REGION_B).connectRegion(region(REGION_D), createFilter(BUNDLE_D));
- region(REGION_D).connectRegion(region(REGION_B), createFilter());
-
- region(REGION_B).connectRegion(region(REGION_C), createFilter(BUNDLE_X));
- region(REGION_C).connectRegion(region(REGION_B), createFilter());
-
- region(REGION_C).connectRegion(region(REGION_D), createFilter(BUNDLE_X));
- region(REGION_D).connectRegion(region(REGION_C), createFilter());
-
- region(REGION_A).connectRegion(region(REGION_C), createFilter());
- region(REGION_C).connectRegion(region(REGION_A), createFilter());
-
- region(REGION_D).connectRegion(region(REGION_A), createFilter());
- region(REGION_A).connectRegion(region(REGION_D), createFilter());
-
- // Find from region A.
- this.candidates.add(serviceReference(BUNDLE_B));
- this.candidates.add(serviceReference(BUNDLE_C));
- this.candidates.add(serviceReference(BUNDLE_D));
- this.candidates.add(serviceReference(BUNDLE_X));
-
- this.bundleFindHook.find(bundleContext(BUNDLE_A), "", "", false, this.candidates);
- assertEquals(2, this.candidates.size());
- assertTrue(this.candidates.contains(serviceReference(BUNDLE_D)));
- assertTrue(this.candidates.contains(serviceReference(BUNDLE_X)));
-
- // Find from region B
- this.candidates.add(serviceReference(BUNDLE_B));
- this.candidates.add(serviceReference(BUNDLE_C));
- this.candidates.add(serviceReference(BUNDLE_D));
- this.candidates.add(serviceReference(BUNDLE_X));
-
- this.bundleFindHook.find(bundleContext(BUNDLE_B), "", "", false, this.candidates);
- assertEquals(3, this.candidates.size());
- assertTrue(this.candidates.contains(serviceReference(BUNDLE_B)));
- assertTrue(this.candidates.contains(serviceReference(BUNDLE_D)));
- assertTrue(this.candidates.contains(serviceReference(BUNDLE_X)));
- }
-
- @Test
- public void testFindFromSystemBundle() {
- this.candidates.add(serviceReference(BUNDLE_A));
-
- Bundle stubBundle = new StubBundle(0L, "sys", BUNDLE_VERSION, "");
- this.bundleFindHook.find(stubBundle.getBundleContext(), "", "", false, this.candidates);
- assertEquals(1, this.candidates.size());
- assertTrue(this.candidates.contains(serviceReference(BUNDLE_A)));
- }
-
- @Test
- public void testFindFromBundleInNoRegion() {
- this.candidates.add(serviceReference(BUNDLE_A));
-
- Bundle stranger = createBundle("stranger");
- this.bundleFindHook.find(stranger.getBundleContext(), "", "", false, this.candidates);
- assertEquals(0, this.candidates.size());
- }
-
- private Region createRegion(String regionName, String... bundleSymbolicNames) throws BundleException {
- Region region = this.digraph.createRegion(regionName);
- for (String bundleSymbolicName : bundleSymbolicNames) {
- Bundle stubBundle = createBundle(bundleSymbolicName);
- region.addBundle(stubBundle);
- }
- this.regions.put(regionName, region);
- return region;
- }
-
- private Region region(String regionName) {
- return this.regions.get(regionName);
- }
-
- private RegionFilter createFilter(final String... referenceNames) throws InvalidSyntaxException {
- Collection<String> filters = new ArrayList<String>(referenceNames.length);
- for (String referenceName : referenceNames) {
- filters.add('(' + Constants.OBJECTCLASS + '=' + referenceName + ')');
- }
- RegionFilterBuilder builder = digraph.createRegionFilterBuilder();
- for (String filter : filters) {
- builder.allow(RegionFilter.VISIBLE_SERVICE_NAMESPACE, filter);
- }
- return builder.build();
- }
-
- private Bundle createBundle(String bundleSymbolicName) {
- Bundle stubBundle = new StubBundle(this.bundleId++, bundleSymbolicName, BUNDLE_VERSION, "loc:" + bundleSymbolicName);
- this.bundles.put(bundleSymbolicName, stubBundle);
- createServiceReference(stubBundle, bundleSymbolicName);
- return stubBundle;
- }
-
- private StubServiceReference<Object> createServiceReference(Bundle stubBundle, String referenceName) {
- StubServiceRegistration<Object> stubServiceRegistration = new StubServiceRegistration<Object>(
- (StubBundleContext) stubBundle.getBundleContext(), referenceName);
- StubServiceReference<Object> stubServiceReference = new StubServiceReference<Object>(stubServiceRegistration);
- this.serviceReferences.put(referenceName, stubServiceReference);
- return stubServiceReference;
- }
-
- private BundleContext bundleContext(String bundleSymbolicName) {
- return bundle(bundleSymbolicName).getBundleContext();
- }
-
- private Bundle bundle(String bundleSymbolicName) {
- Bundle bundleA = this.bundles.get(bundleSymbolicName);
- return bundleA;
- }
-
- private ServiceReference<Object> serviceReference(String referenceName) {
- return this.serviceReferences.get(referenceName);
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/internal/BundleIdBasedRegionTests.java b/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/internal/BundleIdBasedRegionTests.java
deleted file mode 100644
index 3af2eb7e..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/internal/BundleIdBasedRegionTests.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.internal;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.easymock.EasyMock;
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph.FilteredRegion;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.eclipse.virgo.util.math.OrderedPair;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Version;
-
-public class BundleIdBasedRegionTests {
-
- private static final String OTHER_REGION_NAME = "other";
-
- private static final String BUNDLE_SYMBOLIC_NAME = "b";
-
- private static final String BUNDLE_SYMBOLIC_NAME_2 = "c";
-
- private static final Version BUNDLE_VERSION = new Version("1");
-
- private static final long BUNDLE_ID = 1L;
-
- private static final long BUNDLE_ID_2 = 2L;
-
- private static final String REGION_NAME = "reg";
-
- private static final long TEST_BUNDLE_ID = 99L;
-
- private Bundle mockBundle;
-
- private RegionDigraph mockGraph;
-
- private Iterator<Region> regionIterator;
-
- private BundleContext mockBundleContext;
-
- private Region mockRegion;
-
- private Region mockRegion2;
-
- private RegionFilter mockRegionFilter;
-
- private ThreadLocal<Region> threadLocal;
-
- @Before
- public void setUp() throws Exception {
- this.threadLocal = new ThreadLocal<Region>();
- this.mockBundle = EasyMock.createMock(Bundle.class);
- EasyMock.expect(this.mockBundle.getSymbolicName()).andReturn(BUNDLE_SYMBOLIC_NAME).anyTimes();
- EasyMock.expect(this.mockBundle.getVersion()).andReturn(BUNDLE_VERSION).anyTimes();
- EasyMock.expect(this.mockBundle.getBundleId()).andReturn(BUNDLE_ID).anyTimes();
-
- this.mockBundleContext = EasyMock.createMock(BundleContext.class);
- EasyMock.expect(this.mockBundleContext.getBundle(BUNDLE_ID)).andReturn(this.mockBundle).anyTimes();
-
- this.mockRegion = EasyMock.createMock(Region.class);
- this.mockRegion2 = EasyMock.createMock(Region.class);
-
- this.mockRegionFilter = EasyMock.createMock(RegionFilter.class);
-
- this.regionIterator = new Iterator<Region>() {
-
- @Override
- public boolean hasNext() {
- return false;
- }
-
- @Override
- public Region next() {
- return null;
- }
-
- @Override
- public void remove() {
- }
- };
- this.mockGraph = EasyMock.createMock(RegionDigraph.class);
- this.mockGraph.connect(EasyMock.isA(Region.class), EasyMock.eq(this.mockRegionFilter), EasyMock.eq(this.mockRegion));
- EasyMock.expectLastCall().anyTimes();
- }
-
- private void replayMocks() {
- EasyMock.replay(this.mockBundleContext, this.mockBundle, this.mockRegion, this.mockRegion2, this.mockRegionFilter, this.mockGraph);
- }
-
- @After
- public void tearDown() throws Exception {
- EasyMock.verify(this.mockBundleContext, this.mockBundle, this.mockRegion, this.mockRegion2, this.mockRegionFilter, this.mockGraph);
- }
-
- @Test
- public void testGetName() {
- defaultSetUp();
-
- Region r = new BundleIdBasedRegion(REGION_NAME, this.mockGraph, this.mockBundleContext, this.threadLocal);
- assertEquals(REGION_NAME, r.getName());
- }
-
- private void defaultSetUp() {
- EasyMock.expect(this.mockGraph.iterator()).andReturn(this.regionIterator).anyTimes();
- EasyMock.expect(this.mockGraph.getEdges(EasyMock.isA(Region.class))).andReturn(new HashSet<FilteredRegion>()).anyTimes();
- replayMocks();
- }
-
- @Test
- public void testAddBundle() throws BundleException {
- EasyMock.expect(this.mockGraph.iterator()).andReturn(this.regionIterator).anyTimes();
-
- HashSet<FilteredRegion> edges = new HashSet<FilteredRegion>();
- edges.add(new FilteredRegion() {
-
- @Override
- public Region getRegion() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public RegionFilter getFilter() {
- return mockRegionFilter;
- }
- });
- EasyMock.expect(this.mockGraph.getEdges(EasyMock.isA(Region.class))).andReturn(edges).anyTimes();
- Set<OrderedPair<String, Version>> allowedBundles = new HashSet<OrderedPair<String, Version>>();
- allowedBundles.add(new OrderedPair<String, Version>(BUNDLE_SYMBOLIC_NAME_2, BUNDLE_VERSION));
- replayMocks();
-
- Region r = new BundleIdBasedRegion(REGION_NAME, this.mockGraph, this.mockBundleContext, this.threadLocal);
- r.addBundle(this.mockBundle);
- }
-
- @Test
- public void testAddExistingBundle() throws BundleException {
- defaultSetUp();
-
- Region r = new BundleIdBasedRegion(REGION_NAME, this.mockGraph, this.mockBundleContext, this.threadLocal);
- r.addBundle(this.mockBundle);
- r.addBundle(this.mockBundle);
- }
-
- // This restriction was removed, so no exception should be thrown.
- public void testAddConflictingBundle() throws BundleException {
- defaultSetUp();
-
- Bundle mockBundle2 = EasyMock.createMock(Bundle.class);
- EasyMock.expect(mockBundle2.getSymbolicName()).andReturn(BUNDLE_SYMBOLIC_NAME).anyTimes();
- EasyMock.expect(mockBundle2.getVersion()).andReturn(BUNDLE_VERSION).anyTimes();
- EasyMock.expect(mockBundle2.getBundleId()).andReturn(BUNDLE_ID_2).anyTimes();
- EasyMock.replay(mockBundle2);
-
- Region r = new BundleIdBasedRegion(REGION_NAME, this.mockGraph, this.mockBundleContext, this.threadLocal);
- r.addBundle(this.mockBundle);
- r.addBundle(mockBundle2);
- }
-
- @Test(expected = BundleException.class)
- public void testAddBundlePresentInAnotherRegion() throws BundleException {
- this.regionIterator = new Iterator<Region>() {
-
- private int next = 2;
-
- @Override
- public boolean hasNext() {
- return this.next > 0;
- }
-
- @Override
- public Region next() {
- switch (next--) {
- case 2:
- return mockRegion;
- default:
- return mockRegion2;
- }
- }
-
- @Override
- public void remove() {
- }
- };
- EasyMock.expect(this.mockGraph.iterator()).andReturn(this.regionIterator).anyTimes();
- EasyMock.expect(this.mockGraph.getEdges(EasyMock.isA(Region.class))).andReturn(new HashSet<FilteredRegion>()).anyTimes();
- EasyMock.expect(this.mockRegion.contains(EasyMock.eq(this.mockBundle))).andReturn(true).anyTimes();
- EasyMock.expect(this.mockRegion2.contains(EasyMock.eq(this.mockBundle))).andReturn(false).anyTimes();
-
- replayMocks();
-
- Region r = new BundleIdBasedRegion(REGION_NAME, this.mockGraph, this.mockBundleContext, this.threadLocal);
- r.addBundle(this.mockBundle);
- }
-
- @Test
- public void testInstallBundleStringInputStream() {
- defaultSetUp();
-
- // TODO
- }
-
- @Test
- public void testInstallBundleString() {
- defaultSetUp();
-
- // TODO
- }
-
- @Test
- public void testContains() throws BundleException {
- defaultSetUp();
-
- Region r = new BundleIdBasedRegion(REGION_NAME, this.mockGraph, this.mockBundleContext, this.threadLocal);
- r.addBundle(this.mockBundle);
- assertTrue(r.contains(this.mockBundle));
- }
-
- @Test
- public void testDoesNotContain() throws BundleException {
- defaultSetUp();
-
- Region r = new BundleIdBasedRegion(REGION_NAME, this.mockGraph, this.mockBundleContext, this.threadLocal);
- assertFalse(r.contains(this.mockBundle));
- }
-
- @Test
- public void testGetBundle() throws BundleException {
- defaultSetUp();
-
- Region r = new BundleIdBasedRegion(REGION_NAME, this.mockGraph, this.mockBundleContext, this.threadLocal);
- r.addBundle(this.mockBundle);
- assertEquals(this.mockBundle, r.getBundle(BUNDLE_SYMBOLIC_NAME, BUNDLE_VERSION));
- }
-
- @Test
- public void testGetBundleNotFound() throws BundleException {
- defaultSetUp();
-
- Region r = new BundleIdBasedRegion(REGION_NAME, this.mockGraph, this.mockBundleContext, this.threadLocal);
- r.addBundle(this.mockBundle);
- assertNull(r.getBundle(BUNDLE_SYMBOLIC_NAME_2, BUNDLE_VERSION));
- }
-
- @Test
- public void testConnectRegion() throws BundleException {
- defaultSetUp();
-
- Region r = new BundleIdBasedRegion(REGION_NAME, this.mockGraph, this.mockBundleContext, this.threadLocal);
- r.connectRegion(this.mockRegion, this.mockRegionFilter);
- }
-
- @Test
- public void testEquals() {
- defaultSetUp();
-
- Region r = new BundleIdBasedRegion(REGION_NAME, this.mockGraph, this.mockBundleContext, this.threadLocal);
- Region s = new BundleIdBasedRegion(REGION_NAME, this.mockGraph, this.mockBundleContext, this.threadLocal);
- assertEquals(r, r);
- assertEquals(r, s);
- assertEquals(r.hashCode(), s.hashCode());
- }
-
- @Test
- public void testNotEqual() {
- defaultSetUp();
-
- Region r = new BundleIdBasedRegion(REGION_NAME, this.mockGraph, this.mockBundleContext, this.threadLocal);
- Region s = new BundleIdBasedRegion(OTHER_REGION_NAME, this.mockGraph, this.mockBundleContext, this.threadLocal);
- assertFalse(r.equals(s));
- assertFalse(r.equals(null));
- }
-
- @Test
- public void testAddRemoveBundleId() {
- defaultSetUp();
- Region r = new BundleIdBasedRegion(REGION_NAME, this.mockGraph, this.mockBundleContext, this.threadLocal);
- r.addBundle(TEST_BUNDLE_ID);
- assertTrue(r.contains(TEST_BUNDLE_ID));
- r.removeBundle(TEST_BUNDLE_ID);
- assertFalse(r.contains(TEST_BUNDLE_ID));
-
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraphPeristenceTests.java b/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraphPeristenceTests.java
deleted file mode 100644
index e42b8c27..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraphPeristenceTests.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*******************************************************************************
- * This file is part of the Virgo Web Server.
- *
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SpringSource, a division of VMware - initial API and implementation and/or initial documentation
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.internal;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph.FilteredRegion;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilterBuilder;
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundle;
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.Version;
-
-public class StandardRegionDigraphPeristenceTests {
-
- private RegionDigraph digraph;
-
- private StubBundleContext systemBundleContext;
-
- private ThreadLocal<Region> threadLocal;
-
- private static final String BOOT_REGION = "boot";
-
- private static final Collection<String> regionNames = Arrays.asList("r0", "r1", "r2", "r3");
-
- @Before
- public void setUp() throws Exception {
- StubBundle stubSystemBundle = new StubBundle(0L, "osgi.framework", new Version("0"), "loc");
- systemBundleContext = (StubBundleContext) stubSystemBundle.getBundleContext();
- systemBundleContext.addInstalledBundle(stubSystemBundle);
- threadLocal = new ThreadLocal<Region>();
- this.digraph = new StandardRegionDigraph(systemBundleContext, threadLocal);
- Region boot = digraph.createRegion(BOOT_REGION);
- boot.addBundle(stubSystemBundle);
-
- for (String regionName : regionNames) {
- Region region = digraph.createRegion(regionName);
- for (int i = 0; i < 10; i++) {
- String bsn = region.getName() + "." + i;
- StubBundle b = (StubBundle) systemBundleContext.installBundle(bsn);
- systemBundleContext.addInstalledBundle(b);
- region.addBundle(b);
- }
- }
- }
-
- @After
- public void tearDown() throws Exception {
-
- }
-
- @Test
- public void testBasic() throws IOException, InvalidSyntaxException, BundleException {
- doTest();
- }
-
- @Test
- public void testSingleConnection() throws InvalidSyntaxException, BundleException, IOException {
- Region tail = null;
- // create a single connection between each region
- for (Region head : digraph) {
- if (tail != null) {
- String name = head.getName();
- tail.connectRegion(head, createFilter(name + "A", name + "B", name + "C"));
- }
- tail = head;
- }
- doTest();
- }
-
- @Test
- public void testMultiConnection() throws BundleException, InvalidSyntaxException, IOException {
- List<Region> tails = new ArrayList<Region>();
- // create multiple connections between each region
- for (Region head : digraph) {
- for (Region tail : tails) {
- String name = head.getName();
- tail.connectRegion(head, createFilter(name + "A", name + "B", name + "C"));
- }
- tails.add(head);
- }
- doTest();
- }
-
- @Test
- public void testMultiConnectionCycle() throws BundleException, InvalidSyntaxException, IOException {
- List<Region> tails = new ArrayList<Region>();
- for (Region region : digraph) {
- tails.add(region);
- }
- // create multiple connections between each region with cycles
- for (Region head : digraph) {
- for (Region tail : tails) {
- if (head == tail)
- continue;
- String name = head.getName();
- tail.connectRegion(head, createFilter(name + "A", name + "B", name + "C"));
- }
- }
- doTest();
- }
-
- @Test
- public void testInvalidOperations() throws IOException, InvalidSyntaxException, BundleException {
- Region boot = digraph.getRegion(BOOT_REGION);
- Bundle b = boot.installBundle("dynamic.add.a.1", null);
- // needed because we don't have a bundle hook to add it for us
- boot.addBundle(b);
- // needed because StubBundleContext.installBundle does not do this!
- systemBundleContext.addInstalledBundle((StubBundle) b);
- Bundle p = boot.getBundle(b.getSymbolicName(), b.getVersion());
- Assert.assertEquals(b, p);
- // TODO seems testing this will require a reference handler to be present
- // b = boot.installBundle("file:dynamic.add.a.2");
- // boot.addBundle(b); // needed because we don't have a bundle hook to add it for us
-
- RegionDigraph copy = copy(digraph);
- Region bootCopy = copy.getRegion(BOOT_REGION);
- p = bootCopy.getBundle(b.getSymbolicName(), b.getVersion());
- Assert.assertNull(p);
- try {
- bootCopy.installBundle("dynamic.add.b.1", null);
- } catch (BundleException e) {
- // expected
- }
- try {
- bootCopy.installBundle("dynamic.add.b.2");
- } catch (BundleException e) {
- // expected
- }
-
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testInvalidPersistentName() throws IOException, InvalidSyntaxException, BundleException {
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- DataOutputStream dataOut = new DataOutputStream(output);
- dataOut.writeUTF("test");
- dataOut.close();
- byte[] byteArray = output.toByteArray();
- readDigraph(byteArray);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testInvalidPersistentVersion() throws IOException, InvalidSyntaxException, BundleException {
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- DataOutputStream dataOut = new DataOutputStream(output);
- dataOut.writeUTF("virgo region digraph");
- dataOut.writeInt(-1);
- dataOut.close();
- byte[] byteArray = output.toByteArray();
- readDigraph(byteArray);
- }
-
- private void readDigraph(byte[] byteArray) throws IOException, InvalidSyntaxException, BundleException {
- ByteArrayInputStream input = new ByteArrayInputStream(byteArray);
- DataInputStream dataIn = new DataInputStream(input);
- try {
- StandardRegionDigraphPersistence.readRegionDigraph(dataIn);
- } finally {
- dataIn.close();
- }
- }
-
- private void doTest() throws IOException, InvalidSyntaxException, BundleException {
- // test a single write
- doTest(1);
- // test writing and reading the digraph multiple times to same stream
- doTest(10);
- }
-
- private RegionDigraph copy(RegionDigraph toCopy) throws IOException, InvalidSyntaxException, BundleException {
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- DataOutputStream dataOut = new DataOutputStream(output);
- StandardRegionDigraphPersistence.writeRegionDigraph(new DataOutputStream(output), digraph);
- dataOut.close();
-
- DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(output.toByteArray()));
- RegionDigraph copy = StandardRegionDigraphPersistence.readRegionDigraph(dataIn);
- dataIn.close();
- return copy;
- }
-
- private void doTest(int iterations) throws IOException, InvalidSyntaxException, BundleException {
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- DataOutputStream dataOut = new DataOutputStream(output);
- for (int i = 0; i < iterations; i++) {
- StandardRegionDigraphPersistence.writeRegionDigraph(new DataOutputStream(output), digraph);
- }
- dataOut.close();
-
- DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(output.toByteArray()));
- for (int i = 0; i < iterations; i++) {
- RegionDigraph copy = StandardRegionDigraphPersistence.readRegionDigraph(dataIn);
- assertEquals(digraph, copy);
- }
- dataIn.close();
- }
-
- private RegionFilter createFilter(String... input) throws InvalidSyntaxException {
- RegionFilterBuilder builder = digraph.createRegionFilterBuilder();
- for (String param : input) {
- builder.allow(RegionFilter.VISIBLE_BUNDLE_NAMESPACE, "(bundle-symbolic-name=" + param + ")");
- builder.allow(RegionFilter.VISIBLE_HOST_NAMESPACE, "(" + RegionFilter.VISIBLE_HOST_NAMESPACE + "=" + param + ")");
- builder.allow(RegionFilter.VISIBLE_PACKAGE_NAMESPACE, "(" + RegionFilter.VISIBLE_PACKAGE_NAMESPACE + "=" + param + ")");
- builder.allow(RegionFilter.VISIBLE_REQUIRE_NAMESPACE, "(" + RegionFilter.VISIBLE_REQUIRE_NAMESPACE + "=" + param + ")");
- builder.allow(RegionFilter.VISIBLE_SERVICE_NAMESPACE, "(" + Constants.OBJECTCLASS + "=" + param + ")");
- }
- return builder.build();
- }
-
- static void assertEquals(RegionDigraph d1, RegionDigraph d2) {
- int rCnt1 = countRegions(d1);
- int rCnt2 = countRegions(d2);
- Assert.assertEquals(rCnt1, rCnt2);
- for (Region r1 : d1) {
- Region r2 = d2.getRegion(r1.getName());
- assertEquals(r1, r2);
- }
- }
-
- static int countRegions(RegionDigraph digraph) {
- return digraph.getRegions().size();
- }
-
- static void assertEquals(Region r1, Region r2) {
- Assert.assertNotNull(r1);
- Assert.assertNotNull(r2);
- Assert.assertEquals("Wrong name", r1.getName(), r2.getName());
- Set<Long> r1IDs = r1.getBundleIds();
- Set<Long> r2IDs = r2.getBundleIds();
- Assert.assertEquals(r1IDs.size(), r2IDs.size());
- for (Long id : r1IDs) {
- Assert.assertTrue("Missing id: " + id, r2IDs.contains(id));
- }
- assertEquals(r1.getEdges(), r2.getEdges());
- }
-
- static void assertEquals(Set<FilteredRegion> edges1, Set<FilteredRegion> edges2) {
- Assert.assertEquals(edges1.size(), edges2.size());
- Map<String, RegionFilter> edges2Map = new HashMap<String, RegionFilter>();
- for (FilteredRegion edge2 : edges2) {
- edges2Map.put(edge2.getRegion().getName(), edge2.getFilter());
- }
- for (FilteredRegion edge1 : edges1) {
- RegionFilter filter2 = edges2Map.get(edge1.getRegion().getName());
- Assert.assertNotNull("No filter found: " + edge1.getRegion().getName(), filter2);
- Assert.assertEquals(edge1.getFilter().getSharingPolicy(), filter2.getSharingPolicy());
- }
- }
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraphTests.java b/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraphTests.java
deleted file mode 100644
index 64de3fec..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraphTests.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*******************************************************************************
- * This file is part of the Virgo Web Server.
- *
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SpringSource, a division of VMware - initial API and implementation and/or initial documentation
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgi.region.internal;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.Set;
-
-import org.easymock.EasyMock;
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph.FilteredRegion;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundle;
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
-import org.eclipse.virgo.util.math.OrderedPair;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.Version;
-
-public class StandardRegionDigraphTests {
-
- private RegionDigraph digraph;
-
- private Region mockRegion1;
-
- private Region mockRegion2;
-
- private Region mockRegion3;
-
- private RegionFilter regionFilter1;
-
- private RegionFilter regionFilter2;
-
- private Bundle mockBundle;
-
- @Before
- public void setUp() throws Exception {
- StubBundle stubSystemBundle = new StubBundle(0L, "osgi.framework", new Version("0"), "loc");
- StubBundleContext stubBundleContext = new StubBundleContext();
- stubBundleContext.addInstalledBundle(stubSystemBundle);
- this.digraph = new StandardRegionDigraph(stubBundleContext, new ThreadLocal<Region>());
-
- this.mockRegion1 = EasyMock.createMock(Region.class);
- EasyMock.expect(this.mockRegion1.getName()).andReturn("mockRegion1").anyTimes();
-
- this.mockRegion2 = EasyMock.createMock(Region.class);
- EasyMock.expect(this.mockRegion2.getName()).andReturn("mockRegion2").anyTimes();
-
- this.mockRegion3 = EasyMock.createMock(Region.class);
- EasyMock.expect(this.mockRegion3.getName()).andReturn("mockRegion3").anyTimes();
-
- this.mockBundle = EasyMock.createMock(Bundle.class);
- }
-
- private void setDefaultFilters() throws InvalidSyntaxException {
- this.regionFilter1 = digraph.createRegionFilterBuilder().build();
- this.regionFilter2 = digraph.createRegionFilterBuilder().build();
- }
-
- private void setAllowedFilters(OrderedPair<String, Version> b1, OrderedPair<String, Version> b2) throws InvalidSyntaxException {
- String filter1 = "(&(" + RegionFilter.VISIBLE_BUNDLE_NAMESPACE + "=" + b1.getFirst() + ")(" + Constants.BUNDLE_VERSION_ATTRIBUTE + "="
- + b1.getSecond() + "))";
- regionFilter1 = digraph.createRegionFilterBuilder().allow(RegionFilter.VISIBLE_BUNDLE_NAMESPACE, filter1).build();
-
- String filter2 = "(&(" + RegionFilter.VISIBLE_BUNDLE_NAMESPACE + "=" + b1.getFirst() + ")(" + Constants.BUNDLE_VERSION_ATTRIBUTE + "="
- + b1.getSecond() + "))";
- regionFilter2 = digraph.createRegionFilterBuilder().allow(RegionFilter.VISIBLE_BUNDLE_NAMESPACE, filter2).build();
-
- }
-
- private void replayMocks() {
- EasyMock.replay(this.mockRegion1, this.mockRegion2, this.mockRegion3, this.mockBundle);
- }
-
- @After
- public void tearDown() throws Exception {
- EasyMock.verify(this.mockRegion1, this.mockRegion2, this.mockRegion3, this.mockBundle);
- }
-
- @Test
- public void testConnect() throws BundleException, InvalidSyntaxException {
- setDefaultFilters();
- replayMocks();
-
- this.digraph.connect(this.mockRegion1, this.regionFilter1, this.mockRegion2);
- }
-
- @Test
- public void testConnectWithFilterContents() throws BundleException, InvalidSyntaxException {
- OrderedPair<String, Version> b1 = new OrderedPair<String, Version>("b1", new Version("0"));
- OrderedPair<String, Version> b2 = new OrderedPair<String, Version>("b2", new Version("0"));
- setAllowedFilters(b1, b2);
- EasyMock.expect(this.mockRegion1.getBundle(b1.getFirst(), b1.getSecond())).andReturn(null).anyTimes();
- EasyMock.expect(this.mockRegion1.getBundle(b2.getFirst(), b2.getSecond())).andReturn(null).anyTimes();
-
- replayMocks();
-
- this.digraph.connect(this.mockRegion1, this.regionFilter1, this.mockRegion2);
- this.digraph.connect(this.mockRegion1, this.regionFilter2, this.mockRegion3);
- }
-
- @Test(expected = BundleException.class)
- public void testConnectLoop() throws BundleException, InvalidSyntaxException {
- setDefaultFilters();
- replayMocks();
-
- this.digraph.connect(this.mockRegion1, this.regionFilter1, this.mockRegion1);
- }
-
- @Test(expected = BundleException.class)
- public void testDuplicateConnection() throws BundleException, InvalidSyntaxException {
- setDefaultFilters();
- replayMocks();
-
- this.digraph.connect(this.mockRegion1, this.regionFilter1, this.mockRegion2);
- this.digraph.connect(this.mockRegion1, this.regionFilter2, this.mockRegion2);
- }
-
- @Test
- public void testGetEdges() throws BundleException, InvalidSyntaxException {
- setDefaultFilters();
- replayMocks();
-
- this.digraph.connect(this.mockRegion1, this.regionFilter1, this.mockRegion2);
- this.digraph.connect(this.mockRegion1, this.regionFilter2, this.mockRegion3);
- this.digraph.connect(this.mockRegion2, this.regionFilter2, this.mockRegion1);
-
- Set<FilteredRegion> edges = this.digraph.getEdges(this.mockRegion1);
-
- assertEquals(2, edges.size());
-
- for (FilteredRegion edge : edges) {
- if (edge.getRegion().equals(this.mockRegion2)) {
- assertEquals(this.regionFilter1, edge.getFilter());
- } else if (edge.getRegion().equals(this.mockRegion3)) {
- assertEquals(this.regionFilter2, edge.getFilter());
- } else {
- fail("unexpected edge");
- }
- }
- }
-
- @Test
- public void testRemoveRegion() throws BundleException, InvalidSyntaxException {
- setDefaultFilters();
- replayMocks();
-
- this.digraph.connect(this.mockRegion1, this.regionFilter1, this.mockRegion2);
- this.digraph.connect(this.mockRegion2, this.regionFilter2, this.mockRegion1);
- assertNotNull(this.digraph.getRegion("mockRegion1"));
- assertNotNull(this.digraph.getRegion("mockRegion2"));
- this.digraph.removeRegion(this.mockRegion1);
- assertNull(this.digraph.getRegion("mockRegion1"));
- assertNotNull(this.digraph.getRegion("mockRegion2"));
- }
-
- @Test
- public void testGetRegions() throws BundleException, InvalidSyntaxException {
- setDefaultFilters();
- replayMocks();
-
- this.digraph.connect(this.mockRegion1, this.regionFilter1, this.mockRegion2);
- Set<Region> regions = this.digraph.getRegions();
- assertEquals(2, regions.size());
- assertTrue(regions.contains(this.mockRegion1));
- assertTrue(regions.contains(this.mockRegion2));
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionFilterTests.java b/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionFilterTests.java
deleted file mode 100644
index 5945f7da..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/test/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionFilterTests.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * This file is part of the Eclipse Virgo project.
- *
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- */
-
-package org.eclipse.virgo.kernel.osgi.region.internal;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.easymock.EasyMock;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundle;
-import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
-import org.eclipse.virgo.teststubs.osgi.framework.StubServiceRegistration;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.framework.Version;
-import org.osgi.framework.wiring.BundleCapability;
-import org.osgi.framework.wiring.BundleRevision;
-
-public class StandardRegionFilterTests {
-
- private static final String BUNDLE_SYMBOLIC_NAME = "A";
-
- private static final Version BUNDLE_VERSION = new Version("0");
-
- private StubBundle stubBundle;
-
- private String packageImportPolicy = "(" + BundleRevision.PACKAGE_NAMESPACE + "=foo)";
-
- private String serviceImportPolicy = "(" + Constants.OBJECTCLASS + "=foo.Service)";
-
- private BundleCapability fooPackage;
-
- private BundleCapability barPackage;
-
- private ServiceRegistration<Object> fooService;
-
- private ServiceRegistration<Object> barService;
-
- @Before
- public void setUp() throws Exception {
- this.stubBundle = new StubBundle(BUNDLE_SYMBOLIC_NAME, BUNDLE_VERSION);
- this.fooService = new StubServiceRegistration<Object>(new StubBundleContext(), "foo.Service");
- this.barService = new StubServiceRegistration<Object>(new StubBundleContext(), "bar.Service");
-
- this.fooPackage = EasyMock.createMock(BundleCapability.class);
- Map<String, Object> fooAttrs = new HashMap<String, Object>();
- fooAttrs.put(BundleRevision.PACKAGE_NAMESPACE, "foo");
- EasyMock.expect(fooPackage.getNamespace()).andReturn(BundleRevision.PACKAGE_NAMESPACE).anyTimes();
- EasyMock.expect(fooPackage.getAttributes()).andReturn(fooAttrs).anyTimes();
- EasyMock.replay(fooPackage);
-
- this.barPackage = EasyMock.createMock(BundleCapability.class);
- Map<String, Object> barAttrs = new HashMap<String, Object>();
- barAttrs.put(BundleRevision.PACKAGE_NAMESPACE, "bar");
- EasyMock.expect(barPackage.getNamespace()).andReturn(BundleRevision.PACKAGE_NAMESPACE).anyTimes();
- EasyMock.expect(barPackage.getAttributes()).andReturn(barAttrs).anyTimes();
- EasyMock.replay(barPackage);
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- private RegionFilter createBundleFilter(String bundleSymbolicName, Version bundleVersion) throws InvalidSyntaxException {
- String filter = "(&(" + RegionFilter.VISIBLE_BUNDLE_NAMESPACE + "=" + bundleSymbolicName + ")(" + Constants.BUNDLE_VERSION_ATTRIBUTE + ">="
- + bundleVersion + "))";
- return new StandardRegionFilterBuilder().allow(RegionFilter.VISIBLE_BUNDLE_NAMESPACE, filter).build();
- }
-
- private RegionFilter createRegionFilter(String namespace, Collection<String> filters) throws InvalidSyntaxException {
- StandardRegionFilterBuilder builder = new StandardRegionFilterBuilder();
- for (String filter : filters) {
- builder.allow(namespace, filter);
- }
- return builder.build();
- }
-
- @Test
- public void testBundleAllow() throws InvalidSyntaxException {
- RegionFilter regionFilter = createBundleFilter(BUNDLE_SYMBOLIC_NAME, BUNDLE_VERSION);
- assertTrue(regionFilter.isAllowed(stubBundle));
- }
-
- @Test
- public void testBundleAllNotAllowed() {
- RegionFilter regionFilter = new StandardRegionFilterBuilder().build();
- assertFalse(regionFilter.isAllowed(stubBundle));
- }
-
- @Test
- public void testBundleAllAllowed() {
- RegionFilter regionFilter = new StandardRegionFilterBuilder().allowAll(RegionFilter.VISIBLE_BUNDLE_NAMESPACE).build();
- assertTrue(regionFilter.isAllowed(stubBundle));
- }
-
- @Test
- public void testBundleNotAllowedInRange() throws InvalidSyntaxException {
- RegionFilter regionFilter = createBundleFilter(BUNDLE_SYMBOLIC_NAME, new Version(1, 0, 0));
- assertFalse(regionFilter.isAllowed(stubBundle));
- }
-
- @Test
- public void testCapabilityAllowed() throws InvalidSyntaxException {
- RegionFilter regionFilter = createRegionFilter(RegionFilter.VISIBLE_PACKAGE_NAMESPACE, Arrays.asList(packageImportPolicy));
- assertTrue(regionFilter.isAllowed(fooPackage));
- assertEquals(Arrays.asList(this.packageImportPolicy), regionFilter.getSharingPolicy().get(RegionFilter.VISIBLE_PACKAGE_NAMESPACE));
- }
-
- @Test
- public void testCapabilityAllNotAllowed() {
- RegionFilter regionFilter = new StandardRegionFilterBuilder().build();
- assertFalse(regionFilter.isAllowed(barPackage));
- }
-
- @Test
- public void testCapabilityAllAllowed() {
- RegionFilter regionFilter = new StandardRegionFilterBuilder().allowAll(RegionFilter.VISIBLE_PACKAGE_NAMESPACE).build();
- assertTrue(regionFilter.isAllowed(barPackage));
- }
-
- @Test
- public void testCapabilityNotAllowed() throws InvalidSyntaxException {
- RegionFilter regionFilter = createRegionFilter(RegionFilter.VISIBLE_PACKAGE_NAMESPACE, Arrays.asList(packageImportPolicy));
- assertFalse(regionFilter.isAllowed(barPackage));
- assertEquals(Arrays.asList(this.packageImportPolicy), regionFilter.getSharingPolicy().get(RegionFilter.VISIBLE_PACKAGE_NAMESPACE));
- }
-
- @Test
- public void testServiceAllowed() throws InvalidSyntaxException {
- RegionFilter regionFilter = createRegionFilter(RegionFilter.VISIBLE_SERVICE_NAMESPACE, Arrays.asList(serviceImportPolicy));
- assertTrue(regionFilter.isAllowed(fooService.getReference()));
- assertEquals(Arrays.asList(serviceImportPolicy), regionFilter.getSharingPolicy().get(RegionFilter.VISIBLE_SERVICE_NAMESPACE));
- }
-
- @Test
- public void testServiceAllNotAllowed() {
- RegionFilter regionFilter = new StandardRegionFilterBuilder().build();
- assertFalse(regionFilter.isAllowed(fooService.getReference()));
- }
-
- @Test
- public void testServiceAllAllowed() {
- RegionFilter regionFilter = new StandardRegionFilterBuilder().allowAll(RegionFilter.VISIBLE_SERVICE_NAMESPACE).build();
- assertTrue(regionFilter.isAllowed(fooService.getReference()));
- }
-
- @Test
- public void testServiceNotAllowed() throws InvalidSyntaxException {
- RegionFilter regionFilter = createRegionFilter(RegionFilter.VISIBLE_SERVICE_NAMESPACE, Arrays.asList(serviceImportPolicy));
- assertFalse(regionFilter.isAllowed(barService.getReference()));
- assertEquals(Arrays.asList(serviceImportPolicy), regionFilter.getSharingPolicy().get(RegionFilter.VISIBLE_SERVICE_NAMESPACE));
- }
-
- @Test
- public void testAllNamespace() throws InvalidSyntaxException {
- RegionFilter regionFilterNotAllowed = new StandardRegionFilterBuilder().allow(RegionFilter.VISIBLE_ALL_NAMESPACE, "(all=namespace)").build();
- assertFalse(regionFilterNotAllowed.isAllowed(stubBundle));
- assertFalse(regionFilterNotAllowed.isAllowed(fooPackage));
- assertFalse(regionFilterNotAllowed.isAllowed(barPackage));
- assertFalse(regionFilterNotAllowed.isAllowed(fooService.getReference()));
- assertFalse(regionFilterNotAllowed.isAllowed(barService.getReference()));
-
- RegionFilter regionFilterAllAllowed = new StandardRegionFilterBuilder().allowAll(RegionFilter.VISIBLE_ALL_NAMESPACE).build();
- assertTrue(regionFilterAllAllowed.isAllowed(stubBundle));
- assertTrue(regionFilterAllAllowed.isAllowed(fooPackage));
- assertTrue(regionFilterAllAllowed.isAllowed(barPackage));
- assertTrue(regionFilterAllAllowed.isAllowed(fooService.getReference()));
- assertTrue(regionFilterAllAllowed.isAllowed(barService.getReference()));
- }
-}
diff --git a/org.eclipse.virgo.kernel.shell/.classpath b/org.eclipse.virgo.kernel.shell/.classpath
index 944f374d..4b2e1938 100644
--- a/org.eclipse.virgo.kernel.shell/.classpath
+++ b/org.eclipse.virgo.kernel.shell/.classpath
@@ -47,5 +47,6 @@
<classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.virgo.repository/org.eclipse.virgo.repository/3.0.0.D-20110504073608/org.eclipse.virgo.repository-3.0.0.D-20110504073608.jar" sourcepath="/KERNEL_IVY_CACHE/org.eclipse.virgo.repository/org.eclipse.virgo.repository/3.0.0.D-20110504073608/org.eclipse.virgo.repository-sources-3.0.0.D-20110504073608.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.virgo.kernel.model"/>
<classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.event/1.2.100.v20110110/org.eclipse.equinox.event-1.2.100.v20110110.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.region/1.0.0.v20110503/org.eclipse.equinox.region-1.0.0.v20110503.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/AbstractInstallArtifactBasedCommands.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/AbstractInstallArtifactBasedCommands.java
index 3d4cde83..3dc68db3 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/AbstractInstallArtifactBasedCommands.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/AbstractInstallArtifactBasedCommands.java
@@ -27,8 +27,8 @@ import org.osgi.framework.Version;
import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
import org.eclipse.virgo.kernel.model.management.RuntimeArtifactModelObjectNameCreator;
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
+import org.eclipse.equinox.region.Region;
+import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.virgo.kernel.shell.Command;
import org.eclipse.virgo.kernel.shell.internal.formatting.InstallArtifactCommandFormatter;
import org.eclipse.virgo.kernel.shell.internal.util.ArtifactRetriever;
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/BundleCommands.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/BundleCommands.java
index cb1bae39..503d2f8c 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/BundleCommands.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/BundleCommands.java
@@ -14,12 +14,12 @@ package org.eclipse.virgo.kernel.shell.internal.commands;
import java.util.Arrays;
import java.util.List;
+import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
import org.eclipse.virgo.kernel.model.management.RuntimeArtifactModelObjectNameCreator;
import org.eclipse.virgo.kernel.module.ModuleContextAccessor;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiBundle;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiResolutionFailure;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
import org.eclipse.virgo.kernel.shell.Command;
import org.eclipse.virgo.kernel.shell.internal.formatting.BundleInstallArtifactCommandFormatter;
import org.eclipse.virgo.kernel.shell.state.StateService;
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/util/ArtifactRetriever.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/util/ArtifactRetriever.java
index 9b2695b6..600a55c6 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/util/ArtifactRetriever.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/util/ArtifactRetriever.java
@@ -18,11 +18,10 @@ import javax.management.JMX;
import javax.management.MBeanServer;
import javax.management.ObjectName;
-import org.osgi.framework.Version;
-
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
import org.eclipse.virgo.kernel.model.management.RuntimeArtifactModelObjectNameCreator;
-import org.eclipse.virgo.kernel.osgi.region.Region;
+import org.osgi.framework.Version;
/**
* <p>
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/model/helper/StandardRamAccessorHelper.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/model/helper/StandardRamAccessorHelper.java
index 87979ff9..650051a9 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/model/helper/StandardRamAccessorHelper.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/model/helper/StandardRamAccessorHelper.java
@@ -185,7 +185,7 @@ final public class StandardRamAccessorHelper implements RamAccessorHelper {
* {@inheritDoc}
*/
public ArtifactAccessor getArtifact(String type, String name, String version) {
- String kernelRegion = "org.eclipse.virgo.region.kernel";
+ String kernelRegion = "org.eclipse.equinox.region.kernel";
// should be a parameter, but note there is no region
// in the user region mbeans (for backward compatibility)
ArtifactAccessorPointer pointer = null;
@@ -209,7 +209,7 @@ final public class StandardRamAccessorHelper implements RamAccessorHelper {
* {@inheritDoc}
*/
public ArtifactAccessor getArtifact(String type, String name, String version, String region) {
- String kernelRegion = "org.eclipse.virgo.region.kernel";
+ String kernelRegion = "org.eclipse.equinox.region.kernel";
// should be a parameter, but note there is no region
// in the user region mbeans (for backward compatibility)
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateService.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateService.java
index f8282614..62dab683 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateService.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateService.java
@@ -18,13 +18,13 @@ import java.util.Map.Entry;
import java.util.SortedMap;
import java.util.TreeMap;
+import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiBundle;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiExportPackage;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiFramework;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiFrameworkFactory;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiImportPackage;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiResolutionFailure;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
import org.eclipse.virgo.kernel.shell.state.QuasiLiveService;
import org.eclipse.virgo.kernel.shell.state.QuasiPackage;
import org.eclipse.virgo.kernel.shell.state.StateService;
diff --git a/org.eclipse.virgo.kernel.shell/src/main/resources/META-INF/spring/osgi-context.xml b/org.eclipse.virgo.kernel.shell/src/main/resources/META-INF/spring/osgi-context.xml
index 11c74046..c0c48e50 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/resources/META-INF/spring/osgi-context.xml
+++ b/org.eclipse.virgo.kernel.shell/src/main/resources/META-INF/spring/osgi-context.xml
@@ -29,7 +29,7 @@
<osgi:service ref="modelAccessorHelper" interface="org.eclipse.virgo.kernel.shell.model.helper.RamAccessorHelper" />
- <osgi:reference id="regionDigraph" interface="org.eclipse.virgo.kernel.osgi.region.RegionDigraph" />
+ <osgi:reference id="regionDigraph" interface="org.eclipse.equinox.region.RegionDigraph" />
<!-- SERVICES FOR THE TYPE CONVERTERS -->
diff --git a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/commands/StubRuntimeArtifactModelObjectNameCreator.java b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/commands/StubRuntimeArtifactModelObjectNameCreator.java
index 83925f2c..bf0d6158 100644
--- a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/commands/StubRuntimeArtifactModelObjectNameCreator.java
+++ b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/commands/StubRuntimeArtifactModelObjectNameCreator.java
@@ -14,11 +14,10 @@ package org.eclipse.virgo.kernel.shell.internal.commands;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
-import org.osgi.framework.Version;
-
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.management.RuntimeArtifactModelObjectNameCreator;
-import org.eclipse.virgo.kernel.osgi.region.Region;
+import org.osgi.framework.Version;
public final class StubRuntimeArtifactModelObjectNameCreator implements RuntimeArtifactModelObjectNameCreator {
diff --git a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateServiceTests.java b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateServiceTests.java
index f06f161b..b8b2ea8a 100644
--- a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateServiceTests.java
+++ b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateServiceTests.java
@@ -19,10 +19,10 @@ import java.io.File;
import java.util.List;
import org.easymock.EasyMock;
+import org.eclipse.equinox.region.Region;
+import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiBundle;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiFrameworkFactory;
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
import org.eclipse.virgo.kernel.shell.state.QuasiLiveService;
import org.eclipse.virgo.kernel.shell.stubs.StubQuasiFrameworkFactory;
import org.eclipse.virgo.teststubs.osgi.framework.StubBundle;
@@ -72,7 +72,7 @@ public class StandardStateServiceTests {
this.mockKernelRegion = EasyMock.createMock(Region.class);
this.mockRegionDigraph = EasyMock.createMock(RegionDigraph.class);
EasyMock.expect(this.mockRegionDigraph.getRegion(EasyMock.anyLong())).andReturn(this.mockUserRegion).anyTimes();
- EasyMock.expect(this.mockRegionDigraph.getRegion(EasyMock.eq("org.eclipse.virgo.region.kernel"))).andReturn(this.mockKernelRegion).anyTimes();
+ EasyMock.expect(this.mockRegionDigraph.getRegion(EasyMock.eq("org.eclipse.equinox.region.kernel"))).andReturn(this.mockKernelRegion).anyTimes();
EasyMock.replay(this.mockUserRegion, this.mockKernelRegion, this.mockRegionDigraph);
this.standardStateService = new StandardStateService(this.stubQuasiFrameworkFactory, this.stubBundleContext, this.mockRegionDigraph);
}
diff --git a/org.eclipse.virgo.kernel.shell/template.mf b/org.eclipse.virgo.kernel.shell/template.mf
index 4a34526b..2d17b9cd 100644
--- a/org.eclipse.virgo.kernel.shell/template.mf
+++ b/org.eclipse.virgo.kernel.shell/template.mf
@@ -21,6 +21,7 @@ Import-Template:
org.osgi.util.*;version="0",
org.osgi.service.cm.*;version="0",
org.osgi.service.event.*;version="0",
+ org.eclipse.equinox.region.*;version="${org.eclipse.equinox.region:[=.=.=, =.+1)}",
javax.management.*;version="0"
Excluded-Imports:
org.eclipse.virgo.kernel.shell.*,
diff --git a/org.eclipse.virgo.kernel.test/.classpath b/org.eclipse.virgo.kernel.test/.classpath
index 7e53ce25..b10882ab 100644
--- a/org.eclipse.virgo.kernel.test/.classpath
+++ b/org.eclipse.virgo.kernel.test/.classpath
@@ -21,5 +21,6 @@
<classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.parser.manifest/3.0.0.M04/org.eclipse.virgo.util.parser.manifest-3.0.0.M04.jar" sourcepath="/KERNEL_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.parser.manifest/3.0.0.M04/org.eclipse.virgo.util.parser.manifest-sources-3.0.0.M04.jar"/>
<classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.virgo.medic/org.eclipse.virgo.medic/3.0.0.D-20110504073214/org.eclipse.virgo.medic-3.0.0.D-20110504073214.jar" sourcepath="/KERNEL_IVY_CACHE/org.eclipse.virgo.medic/org.eclipse.virgo.medic/1.0.0.CI-B20/org.eclipse.virgo.medic-sources-1.0.0.CI-B20.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.virgo.kernel.osgicommand"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.region/1.0.0.v20110503/org.eclipse.equinox.region-1.0.0.v20110503.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
diff --git a/org.eclipse.virgo.kernel.test/src/test/java/org/eclipse/virgo/kernel/osgi/test/RegionTests.java b/org.eclipse.virgo.kernel.test/src/test/java/org/eclipse/virgo/kernel/osgi/test/RegionTests.java
index 6bf51bc4..b2250000 100644
--- a/org.eclipse.virgo.kernel.test/src/test/java/org/eclipse/virgo/kernel/osgi/test/RegionTests.java
+++ b/org.eclipse.virgo.kernel.test/src/test/java/org/eclipse/virgo/kernel/osgi/test/RegionTests.java
@@ -18,7 +18,7 @@ import org.junit.Test;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
-import org.eclipse.virgo.kernel.osgi.region.Region;
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.test.AbstractKernelIntegrationTest;
/**
diff --git a/org.eclipse.virgo.kernel.test/src/test/resources/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.test/src/test/resources/META-INF/MANIFEST.MF
index afded3d9..70b18528 100644
--- a/org.eclipse.virgo.kernel.test/src/test/resources/META-INF/MANIFEST.MF
+++ b/org.eclipse.virgo.kernel.test/src/test/resources/META-INF/MANIFEST.MF
@@ -21,7 +21,7 @@ Import-Package: javax.management;version="0",org.eclipse.virgo.kernel.
core;version="[3.0.0,4)",org.eclipse.virgo.kernel.deployer.core;versi
on="[3.0.0,4)",org.eclipse.virgo.kernel.osgi.framework;version="[3.0.
0,4)",org.eclipse.virgo.kernel.osgi.quasi;version="[3.0.0,4)",org.ecl
- ipse.virgo.kernel.osgi.region;version="[3.0.0,4)",org.eclipse.virgo.k
+ ipse.equinox.region;version="1",org.eclipse.virgo.k
ernel.osgicommand.helper;version="[3.0.0,4)",org.eclipse.virgo.util.i
o;version="[3.0.0,4)",org.eclipse.virgo.util.osgi.manifest;version="[
3.0.0,4)",org.junit;version="[4.7.0,5)",org.junit.runner;version="[4.
diff --git a/org.eclipse.virgo.kernel.test/src/test/resources/META-INF/test.config.properties b/org.eclipse.virgo.kernel.test/src/test/resources/META-INF/test.config.properties
index 22544bcc..10a1ddf7 100644
--- a/org.eclipse.virgo.kernel.test/src/test/resources/META-INF/test.config.properties
+++ b/org.eclipse.virgo.kernel.test/src/test/resources/META-INF/test.config.properties
@@ -1,4 +1,5 @@
launcher.bundles =\
+ file:../ivy-cache/repository/org.eclipse.osgi/org.eclipse.equinox.region/${org.eclipse.equinox.region}/org.eclipse.equinox.region-${org.eclipse.equinox.region}.jar@start,\
file:../ivy-cache/repository/org.slf4j/com.springsource.slf4j.api/${org.slf4j}/com.springsource.slf4j.api-${org.slf4j}.jar@start,\
file:../ivy-cache/repository/org.slf4j/com.springsource.slf4j.org.apache.commons.logging/${org.slf4j}/com.springsource.slf4j.org.apache.commons.logging-${org.slf4j}.jar@start,\
file:../ivy-cache/repository/org.aspectj/com.springsource.org.aspectj.runtime/${org.aspectj}/com.springsource.org.aspectj.runtime-${org.aspectj}.jar@start,\
diff --git a/org.eclipse.virgo.kernel.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties b/org.eclipse.virgo.kernel.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties
index 67849102..70a569f8 100644
--- a/org.eclipse.virgo.kernel.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties
+++ b/org.eclipse.virgo.kernel.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties
@@ -44,12 +44,13 @@ packageImports =\
org.junit.runner;version="[4.7.0,5.0.0)",\
org.osgi.service.cm;version="0",\
org.osgi.service.event;version="0",\
+ org.eclipse.equinox.region;version="1",\
org.slf4j;version="[1.6.1,2)",\
org.slf4j.spi;version="[1.6.1,2)"
serviceImports =\
- org.eclipse.virgo.kernel.osgi.region.Region,\
- org.eclipse.virgo.kernel.osgi.region.RegionDigraph,\
+ org.eclipse.equinox.region.Region,\
+ org.eclipse.equinox.region.RegionDigraph,\
org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer,\
org.eclipse.virgo.kernel.deployer.core.DeployUriNormaliser,\
org.eclipse.virgo.kernel.install.artifact.ScopeServiceRepository,\
diff --git a/org.eclipse.virgo.kernel.userregion/.classpath b/org.eclipse.virgo.kernel.userregion/.classpath
index aa68c7d8..dbbc269d 100644
--- a/org.eclipse.virgo.kernel.userregion/.classpath
+++ b/org.eclipse.virgo.kernel.userregion/.classpath
@@ -44,5 +44,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.virgo.kernel.deployer"/>
<classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi.services/3.3.0.v20110110/org.eclipse.osgi.services-3.3.0.v20110110.jar" sourcepath="/KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi.services/3.3.0.v20110110/org.eclipse.osgi.services-sources-3.3.0.v20110110.jar"/>
<classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.event/1.2.100.v20110110/org.eclipse.equinox.event-1.2.100.v20110110.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.region/1.0.0.v20110503/org.eclipse.equinox.region-1.0.0.v20110503.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
diff --git a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/Activator.java b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/Activator.java
index 14ede535..280707cf 100644
--- a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/Activator.java
+++ b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/Activator.java
@@ -19,6 +19,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.osgi.service.resolver.PlatformAdmin;
import org.eclipse.virgo.kernel.core.Shutdown;
import org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer;
@@ -31,7 +32,6 @@ import org.eclipse.virgo.kernel.osgi.framework.OsgiFrameworkUtils;
import org.eclipse.virgo.kernel.osgi.framework.OsgiServiceHolder;
import org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiFrameworkFactory;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
import org.eclipse.virgo.kernel.services.work.WorkArea;
import org.eclipse.virgo.kernel.shim.scope.ScopeFactory;
import org.eclipse.virgo.kernel.userregion.internal.dump.StandardDumpExtractor;
@@ -93,14 +93,14 @@ public class Activator implements BundleActivator {
*/
public void start(BundleContext context) throws Exception {
ResolutionFailureDetective rfd = createResolutionFailureDetective(context);
- Repository repository = OsgiFrameworkUtils.getService(context, Repository.class).getService();
- PackageAdmin packageAdmin = OsgiFrameworkUtils.getService(context, PackageAdmin.class).getService();
+ Repository repository = getPotentiallyDelayedService(context, Repository.class);
+ PackageAdmin packageAdmin = getPotentiallyDelayedService(context, PackageAdmin.class);
- EventLogger eventLogger = OsgiFrameworkUtils.getService(context, EventLoggerFactory.class).getService().createEventLogger(context.getBundle());
+ EventLogger eventLogger = getPotentiallyDelayedService(context, EventLoggerFactory.class).createEventLogger(context.getBundle());
- RegionDigraph regionDigraph = OsgiFrameworkUtils.getService(context, RegionDigraph.class).getService();
+ RegionDigraph regionDigraph = getPotentiallyDelayedService(context, RegionDigraph.class);
- WorkArea workArea = OsgiFrameworkUtils.getService(context, WorkArea.class).getService();
+ WorkArea workArea = getPotentiallyDelayedService(context, WorkArea.class);
ImportExpansionHandler importExpansionHandler = createImportExpansionHandler(context, packageAdmin, repository, eventLogger);
this.registrationTracker.track(context.registerService(ImportExpander.class.getName(), importExpansionHandler, null));
diff --git a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/RegionDigraphDumpContributor.java b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/RegionDigraphDumpContributor.java
index 7a320c9b..0fbf2b88 100644
--- a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/RegionDigraphDumpContributor.java
+++ b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/RegionDigraphDumpContributor.java
@@ -15,7 +15,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
+import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.virgo.kernel.serviceability.NonNull;
import org.eclipse.virgo.medic.dump.Dump;
import org.eclipse.virgo.medic.dump.DumpContributionFailedException;
diff --git a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/DependencyCalculator.java b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/DependencyCalculator.java
index 7c747bcd..3fc1b44f 100644
--- a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/DependencyCalculator.java
+++ b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/DependencyCalculator.java
@@ -25,6 +25,9 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
+import org.eclipse.equinox.region.Region;
+import org.eclipse.equinox.region.RegionDigraph.FilteredRegion;
+import org.eclipse.equinox.region.RegionFilter;
import org.eclipse.osgi.service.resolver.BundleDelta;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.BundleSpecification;
@@ -40,9 +43,6 @@ import org.eclipse.osgi.service.resolver.VersionRange;
import org.eclipse.virgo.kernel.artifact.bundle.BundleBridge;
import org.eclipse.virgo.kernel.osgi.framework.UnableToSatisfyBundleDependenciesException;
import org.eclipse.virgo.kernel.osgi.framework.UnableToSatisfyDependenciesException;
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph.FilteredRegion;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
import org.eclipse.virgo.kernel.userregion.internal.equinox.ResolutionDumpContributor;
import org.eclipse.virgo.kernel.userregion.internal.quasi.ResolutionFailureDetective.ResolverErrorsHolder;
import org.eclipse.virgo.medic.dump.DumpGenerator;
diff --git a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFramework.java b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFramework.java
index 75d32cdb..0eade93d 100644
--- a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFramework.java
+++ b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFramework.java
@@ -24,6 +24,9 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import org.eclipse.equinox.region.Region;
+import org.eclipse.equinox.region.RegionDigraph;
+import org.eclipse.equinox.region.RegionFilter;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
import org.eclipse.osgi.service.resolver.PlatformAdmin;
@@ -38,10 +41,6 @@ import org.eclipse.virgo.kernel.osgi.framework.UnableToSatisfyDependenciesExcept
import org.eclipse.virgo.kernel.osgi.quasi.QuasiBundle;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiFramework;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiResolutionFailure;
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.eclipse.virgo.kernel.osgi.region.hook.RegionResolverHookFactory;
import org.eclipse.virgo.kernel.userregion.internal.equinox.TransformedManifestProvidingBundleFileWrapper;
import org.eclipse.virgo.kernel.userregion.internal.quasi.ResolutionFailureDetective.ResolverErrorsHolder;
import org.eclipse.virgo.repository.Repository;
@@ -132,7 +131,7 @@ final class StandardQuasiFramework implements QuasiFramework {
* factory equivalent to the live hook factory. If the region digraph is disconnected (a reconstituted copy of a
* live region digraph), this will produce a hook factory independent of the live hook factory.
*/
- ResolverHookFactory resolverHookFactory = new RegionResolverHookFactory(this.regionDigraph);
+ ResolverHookFactory resolverHookFactory = this.regionDigraph.getResolverHookFactory();
this.state.setResolverHookFactory(resolverHookFactory);
}
diff --git a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFrameworkFactory.java b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFrameworkFactory.java
index ddc732cb..92ccc2dd 100644
--- a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFrameworkFactory.java
+++ b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFrameworkFactory.java
@@ -19,6 +19,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipException;
+import org.eclipse.equinox.region.RegionDigraph;
+import org.eclipse.equinox.region.RegionDigraphPersistence;
import org.eclipse.osgi.internal.baseadaptor.StateManager;
import org.eclipse.osgi.service.resolver.PlatformAdmin;
import org.eclipse.osgi.service.resolver.State;
@@ -27,8 +29,6 @@ import org.eclipse.virgo.kernel.osgi.framework.OsgiFrameworkUtils;
import org.eclipse.virgo.kernel.osgi.framework.OsgiServiceHolder;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiFramework;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiFrameworkFactory;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraphPersistence;
import org.eclipse.virgo.kernel.userregion.internal.DumpExtractor;
import org.eclipse.virgo.kernel.userregion.internal.equinox.TransformedManifestProvidingBundleFileWrapper;
import org.eclipse.virgo.repository.Repository;
diff --git a/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/AbstractOsgiFrameworkLaunchingTests.java b/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/AbstractOsgiFrameworkLaunchingTests.java
index d34b9796..f0710cc6 100644
--- a/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/AbstractOsgiFrameworkLaunchingTests.java
+++ b/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/AbstractOsgiFrameworkLaunchingTests.java
@@ -21,15 +21,15 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import org.eclipse.equinox.internal.region.StandardRegionDigraph;
+import org.eclipse.equinox.region.Region;
+import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.osgi.launch.Equinox;
import org.eclipse.osgi.service.resolver.PlatformAdmin;
import org.eclipse.virgo.kernel.artifact.bundle.BundleBridge;
import org.eclipse.virgo.kernel.artifact.library.LibraryBridge;
import org.eclipse.virgo.kernel.osgi.framework.ImportExpander;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiFramework;
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.eclipse.virgo.kernel.osgi.region.internal.StandardRegionDigraph;
import org.eclipse.virgo.kernel.services.repository.internal.RepositoryFactoryBean;
import org.eclipse.virgo.kernel.services.work.WorkArea;
import org.eclipse.virgo.kernel.userregion.internal.DumpExtractor;
diff --git a/org.eclipse.virgo.kernel.userregion/template.mf b/org.eclipse.virgo.kernel.userregion/template.mf
index e937ca1e..19f9721c 100644
--- a/org.eclipse.virgo.kernel.userregion/template.mf
+++ b/org.eclipse.virgo.kernel.userregion/template.mf
@@ -10,12 +10,14 @@ Excluded-Imports:
org.eclipse.virgo.osgi.extensions.*,
org.eclipse.virgo.repository.internal
Import-Template:
+ org.eclipse.equinox.region.*;version="${org.eclipse.equinox.region:[=.=.=, =.+1)}",
org.eclipse.virgo.kernel.*;version="${version:[=.=.=, =.+1)}",
org.eclipse.virgo.medic.*;version="${org.eclipse.virgo.medic:[=.=.=, =.+1)}",
org.eclipse.virgo.repository.*;version="${org.eclipse.virgo.repository:[=.=.=, =.+1)}",
org.eclipse.virgo.util.*;version="${org.eclipse.virgo.util:[=.=.=, =.+1)}",
org.aspectj.*;version="${org.aspectj:[=.=.=.=, +1)}",
org.eclipse.osgi.*;version="0",
+ org.eclipse.equinox.region.*;version="${org.eclipse.equinox.region:[=.=.=, =.+1)}",
org.osgi.framework.*;version="0",
org.osgi.service.*;version="0",
org.osgi.util.*;version="0",
diff --git a/org.eclipse.virgo.kernel.userregionfactory/.classpath b/org.eclipse.virgo.kernel.userregionfactory/.classpath
index 3a41e0be..d3d126d8 100644
--- a/org.eclipse.virgo.kernel.userregionfactory/.classpath
+++ b/org.eclipse.virgo.kernel.userregionfactory/.classpath
@@ -19,5 +19,6 @@
<classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi/3.0.0.M04/org.eclipse.virgo.util.osgi-3.0.0.M04.jar" sourcepath="/KERNEL_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi/2.2.0.D-20101207150035/org.eclipse.virgo.util.osgi-sources-2.2.0.D-20101207150035.jar"/>
<classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.parser.manifest/3.0.0.M04/org.eclipse.virgo.util.parser.manifest-3.0.0.M04.jar" sourcepath="/KERNEL_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.parser.manifest/2.2.0.D-20101207150035/org.eclipse.virgo.util.parser.manifest-sources-2.2.0.D-20101207150035.jar"/>
<classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.virgo.teststubs/org.eclipse.virgo.teststubs.osgi/3.0.0.M04/org.eclipse.virgo.teststubs.osgi-3.0.0.M04.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.region/1.0.0.v20110503/org.eclipse.equinox.region-1.0.0.v20110503.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
diff --git a/org.eclipse.virgo.kernel.userregionfactory/src/main/java/org/eclipse/virgo/kernel/userregionfactory/Activator.java b/org.eclipse.virgo.kernel.userregionfactory/src/main/java/org/eclipse/virgo/kernel/userregionfactory/Activator.java
index 795a14a3..32be193a 100644
--- a/org.eclipse.virgo.kernel.userregionfactory/src/main/java/org/eclipse/virgo/kernel/userregionfactory/Activator.java
+++ b/org.eclipse.virgo.kernel.userregionfactory/src/main/java/org/eclipse/virgo/kernel/userregionfactory/Activator.java
@@ -28,10 +28,10 @@ import java.util.concurrent.TimeoutException;
import org.eclipse.virgo.kernel.core.Shutdown;
import org.eclipse.virgo.kernel.osgi.framework.OsgiFrameworkUtils;
import org.eclipse.virgo.kernel.osgi.framework.OsgiServiceHolder;
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilterBuilder;
+import org.eclipse.equinox.region.Region;
+import org.eclipse.equinox.region.RegionDigraph;
+import org.eclipse.equinox.region.RegionFilter;
+import org.eclipse.equinox.region.RegionFilterBuilder;
import org.eclipse.virgo.medic.dump.DumpGenerator;
import org.eclipse.virgo.medic.eventlog.EventLogger;
import org.eclipse.virgo.osgi.launcher.parser.ArgumentParser;
@@ -66,6 +66,8 @@ import org.osgi.service.event.EventAdmin;
*/
public final class Activator implements BundleActivator {
+ private static final String KERNEL_REGION_NAME = "org.eclipse.equinox.region.kernel";
+
private static final String CLASS_LIST_SEPARATOR = ",";
private static final long MAX_SECONDS_WAIT_FOR_SERVICE = 30;
@@ -189,7 +191,7 @@ public final class Activator implements BundleActivator {
}
private Region getKernelRegion(RegionDigraph regionDigraph) {
- return regionDigraph.iterator().next();
+ return regionDigraph.getRegion(KERNEL_REGION_NAME);
}
private RegionFilter createKernelFilter(RegionDigraph digraph, BundleContext systemBundleContext, EventLogger eventLogger)
diff --git a/org.eclipse.virgo.kernel.userregionfactory/template.mf b/org.eclipse.virgo.kernel.userregionfactory/template.mf
index 228ea8cd..b645996e 100644
--- a/org.eclipse.virgo.kernel.userregionfactory/template.mf
+++ b/org.eclipse.virgo.kernel.userregionfactory/template.mf
@@ -10,7 +10,8 @@ Import-Template:
org.eclipse.osgi.service.resolver.*;version="0",
org.osgi.framework.*;version="0",
org.osgi.service.*;version="0",
- org.eclipse.virgo.medic.*;version="${org.eclipse.virgo.medic:[=.=.=, =.+1)}"
+ org.eclipse.virgo.medic.*;version="${org.eclipse.virgo.medic:[=.=.=, =.+1)}",
+ org.eclipse.equinox.region.*;version="${org.eclipse.equinox.region:[=.=.=, =.+1)}"
Import-Package: org.aspectj.lang;version="0"
Bundle-Activator: org.eclipse.virgo.kernel.userregionfactory.Activator
Excluded-Imports: org.easymock,

Back to the top