Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Frost2011-05-12 10:28:05 -0400
committerChristopher Frost2011-05-12 10:28:05 -0400
commitfc6db13af44c6d886d012171fa73675b800190e0 (patch)
tree0f5d6073cce0b93d8c262296fe2fa06333d2054a
parentebb1cd69e1dbb7a3ef20ac0ba59b7b0880a5b25e (diff)
parent79235ace8c503e4a8d3d62572563d166a8ad97aa (diff)
downloadorg.eclipse.virgo.kernel-fc6db13af44c6d886d012171fa73675b800190e0.tar.gz
org.eclipse.virgo.kernel-fc6db13af44c6d886d012171fa73675b800190e0.tar.xz
org.eclipse.virgo.kernel-fc6db13af44c6d886d012171fa73675b800190e0.zip
Merge branch 'globalRegion'
-rw-r--r--build-kernel/config/org.eclipse.virgo.kernel.userregion.properties2
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/NestedPlanIntegrationTests.java27
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties2
-rw-r--r--org.eclipse.virgo.kernel.model/ivy.xml15
-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.java32
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleArtifact.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListener.java3
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializer.java6
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ConfigurationArtifact.java5
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListener.java13
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListenerInitializer.java19
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerArtifact.java5
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerBundleArtifact.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifact.java5
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifactDependencyDeterminer.java15
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListener.java13
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerInitializer.java13
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DefaultRuntimeArtifactModelObjectNameCreator.java7
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/module-context.xml7
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/osgi-context.xml6
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubArtifactRepository.java12
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubCompositeArtifact.java10
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubRegion.java155
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/AbztractArtifactTests.java32
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/NotifyingArtifactRepositoryTests.java82
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializerTests.java14
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerTests.java5
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ConfgurationArtifactTests.java16
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListenerInitializerTests.java16
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListenerTests.java16
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerArtifactTests.java16
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifactDependencyDeterminerTests.java21
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifactTests.java14
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerInitializerTests.java17
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerTests.java16
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DefaultArtifactObjectNameCreatorTests.java2
-rw-r--r--org.eclipse.virgo.kernel.osgi/.classpath1
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/GlobalRegion.java203
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/resources/META-INF/spring/osgi-framework-context.xml18
-rw-r--r--org.eclipse.virgo.kernel.osgi/template.mf1
-rw-r--r--org.eclipse.virgo.kernel.shutdown/src/main/resources/.gitignore (renamed from org.eclipse.virgo.kernel.shutdown/src/test/java/.gitignore)0
-rw-r--r--org.eclipse.virgo.kernel.shutdown/src/test/resources/.gitignore0
-rw-r--r--org.eclipse.virgo.kernel.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties2
-rw-r--r--org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoaderTests.java1
-rw-r--r--org.eclipse.virgo.kernel.userregionfactory/src/main/java/.gitignore0
-rw-r--r--org.eclipse.virgo.kernel.userregionfactory/src/main/resources/.gitignore0
-rw-r--r--org.eclipse.virgo.kernel.userregionfactory/src/test/java/.gitignore0
48 files changed, 640 insertions, 231 deletions
diff --git a/build-kernel/config/org.eclipse.virgo.kernel.userregion.properties b/build-kernel/config/org.eclipse.virgo.kernel.userregion.properties
index de07c3e6..502a9c5d 100644
--- a/build-kernel/config/org.eclipse.virgo.kernel.userregion.properties
+++ b/build-kernel/config/org.eclipse.virgo.kernel.userregion.properties
@@ -69,7 +69,7 @@ serviceExports =\
org.eclipse.virgo.kernel.osgi.framework.OsgiFramework,\
org.eclipse.virgo.kernel.osgi.framework.ImportExpander,\
org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil,\
- org.eclipse.virgo.kernel.osgi.region.Region,\
+ org.eclipse.equinox.region.Region,\
org.osgi.service.event.EventHandler,\
org.osgi.service.cm.ConfigurationListener,\
org.osgi.service.cm.ManagedService,\
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 6893237c..ed06beeb 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
@@ -21,6 +21,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import java.util.Set;
@@ -106,6 +107,8 @@ public class NestedPlanIntegrationTests extends AbstractDeployerIntegrationTest
}
private RuntimeArtifactRepository ram;
+
+ private Region globalRegion;
private static TestPlanArtifactInfo[] PARENTS;
@@ -121,9 +124,14 @@ public class NestedPlanIntegrationTests extends AbstractDeployerIntegrationTest
@Before
public void setUp() throws Exception {
- ServiceReference<RuntimeArtifactRepository> serviceReference = context.getServiceReference(RuntimeArtifactRepository.class);
- if (serviceReference != null) {
- this.ram = context.getService(serviceReference);
+ ServiceReference<RuntimeArtifactRepository> runtimeArtifactRepositoryServiceReference = context.getServiceReference(RuntimeArtifactRepository.class);
+ if (runtimeArtifactRepositoryServiceReference != null) {
+ this.ram = context.getService(runtimeArtifactRepositoryServiceReference);
+ }
+
+ Collection<ServiceReference<Region>> regionServiceReferences = context.getServiceReferences(Region.class, "(org.eclipse.virgo.kernel.region.name=global)");
+ if (regionServiceReferences != null && regionServiceReferences.size() == 1) {
+ this.globalRegion = context.getService(regionServiceReferences.iterator().next());
}
globalBundleDeploymentIdentity = deploy(GLOBAL_BUNDLE_INFO);
@@ -364,7 +372,7 @@ public class NestedPlanIntegrationTests extends AbstractDeployerIntegrationTest
Artifact childArtifact;
if (parent.isScoped()) {
- childArtifact = getPlan(childPlan.getType(), model.getScopeName() + SCOPE_SEPARATOR + childPlan.getName(), childPlan.getVersion(), null);
+ childArtifact = getPlan(childPlan.getType(), model.getScopeName() + SCOPE_SEPARATOR + childPlan.getName(), childPlan.getVersion(), globalRegion);
} else {
childArtifact = getPlan(childPlan);
}
@@ -383,7 +391,7 @@ public class NestedPlanIntegrationTests extends AbstractDeployerIntegrationTest
}
private Artifact getPlan(TestPlanArtifactInfo plan) {
- return getPlan(plan.getType(), plan.getName(), plan.getVersion(), null);
+ return getPlan(plan.getType(), plan.getName(), plan.getVersion(), globalRegion);
}
private Artifact getPlan(String type, String name, Version version, Region region) {
@@ -660,17 +668,14 @@ public class NestedPlanIntegrationTests extends AbstractDeployerIntegrationTest
return identity;
}
- public static TestPlanArtifactInfo createPlanFile(String planName, Version planVersion, boolean scoped, boolean atomic,
- TestArtifactInfo... children) throws IOException {
+ public static TestPlanArtifactInfo createPlanFile(String planName, Version planVersion, boolean scoped, boolean atomic, TestArtifactInfo... children) throws IOException {
StringBuffer planContent = new StringBuffer(1024);
planContent.append(XML_HEADER);
- planContent.append("<plan name=\"" + planName + "\" version=\"" + planVersion + "\" scoped=\"" + new Boolean(scoped) + "\" atomic=\""
- + new Boolean(atomic) + "\" \n" + NAMESPACES + ">\n");
+ planContent.append("<plan name=\"" + planName + "\" version=\"" + planVersion + "\" scoped=\"" + new Boolean(scoped) + "\" atomic=\"" + new Boolean(atomic) + "\" \n" + NAMESPACES + ">\n");
for (TestArtifactInfo childInfo : children) {
Version childVersion = childInfo.getVersion();
- planContent.append(" <artifact type=\"" + childInfo.getType() + "\" name=\"" + childInfo.getName() + "\" version=\"[" + childVersion
- + ", " + childVersion + "]\"/>\n");
+ planContent.append(" <artifact type=\"" + childInfo.getType() + "\" name=\"" + childInfo.getName() + "\" version=\"[" + childVersion + ", " + childVersion + "]\"/>\n");
}
planContent.append("</plan>");
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 d0faac02..c211e3c0 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
@@ -86,7 +86,7 @@ serviceExports =\
org.eclipse.virgo.kernel.osgi.framework.OsgiFramework,\
org.eclipse.virgo.kernel.osgi.framework.ImportExpander,\
org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil,\
- org.eclipse.virgo.kernel.osgi.region.Region,\
+ org.eclipse.equinox.region.Region,\
org.osgi.service.event.EventHandler,\
org.osgi.service.cm.ConfigurationListener,\
org.osgi.service.cm.ManagedService,\
diff --git a/org.eclipse.virgo.kernel.model/ivy.xml b/org.eclipse.virgo.kernel.model/ivy.xml
index c4b536a8..b242c85f 100644
--- a/org.eclipse.virgo.kernel.model/ivy.xml
+++ b/org.eclipse.virgo.kernel.model/ivy.xml
@@ -17,23 +17,24 @@
<dependency org="org.junit" name="com.springsource.org.junit" rev="${org.junit}" conf="test->runtime"/>
<dependency org="org.easymock" name="com.springsource.org.easymock" rev="${org.easymock}" conf="test->runtime"/>
<dependency org="org.eclipse.virgo.teststubs" name="org.eclipse.virgo.teststubs.osgi" rev="${org.eclipse.virgo.teststubs}" conf="test->runtime"/>
- <dependency org="org.slf4j" name="com.springsource.slf4j.api" rev="${org.slf4j}" conf="compile->runtime"/>
<dependency org="org.slf4j" name="com.springsource.slf4j.nop" rev="${org.slf4j}" conf="test->runtime"/>
- <dependency org="org.springframework" name="org.springframework.context" rev="${org.springframework}" conf="compile->runtime"/>
- <dependency org="org.eclipse.virgo.medic" name="org.eclipse.virgo.medic" rev="${org.eclipse.virgo.medic}" conf="aspects, compile->runtime"/>
- <dependency org="org.eclipse.virgo.kernel" name="org.eclipse.virgo.kernel.osgi" rev="latest.integration" conf="compile->runtime"/>
- <dependency org="org.eclipse.virgo.kernel" name="org.eclipse.virgo.kernel.artifact" rev="latest.integration" conf="compile->runtime"/>
<dependency org="org.eclipse.virgo.kernel" name="org.eclipse.virgo.kernel.stubs" rev="latest.integration" conf="test->runtime"/>
+
+ <dependency org="org.slf4j" name="com.springsource.slf4j.api" rev="${org.slf4j}" conf="compile->compile"/>
+ <dependency org="org.springframework" name="org.springframework.context" rev="${org.springframework}" conf="compile->compile"/>
+ <dependency org="org.eclipse.virgo.medic" name="org.eclipse.virgo.medic" rev="${org.eclipse.virgo.medic}" conf="aspects, compile->runtime"/>
+ <dependency org="org.eclipse.virgo.kernel" name="org.eclipse.virgo.kernel.osgi" rev="latest.integration" conf="compile->compile"/>
+ <dependency org="org.eclipse.virgo.kernel" name="org.eclipse.virgo.kernel.artifact" rev="latest.integration" conf="compile->compile"/>
<dependency org="org.eclipse.virgo.kernel" name="org.eclipse.virgo.kernel.deployer" rev="latest.integration" conf="aspects->runtime"/>
<dependency org="org.eclipse.virgo.util" name="org.eclipse.virgo.util.common" rev="${org.eclipse.virgo.util}" conf="compile->compile"/>
<dependency org="org.eclipse.virgo.util" name="org.eclipse.virgo.util.osgi" rev="${org.eclipse.virgo.util}" conf="compile->compile"/>
<dependency org="org.eclipse.virgo.util" name="org.eclipse.virgo.util.jmx" rev="${org.eclipse.virgo.util}" conf="aspects->runtime"/>
+
<dependency org="org.eclipse.osgi" name="org.eclipse.osgi" rev="${org.eclipse.osgi}" conf="compile->runtime"/>
-
<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}"/>
<!-- Allow Equinox to be upgraded point-wise before rippling -->
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 921285ca..c9be1c91 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
@@ -56,7 +56,7 @@ public abstract class AbstractArtifact implements Artifact {
private final Region region;
- public AbstractArtifact(@NonNull BundleContext bundleContext, @NonNull String type, @NonNull String name, @NonNull Version version, Region region) {
+ public AbstractArtifact(@NonNull BundleContext bundleContext, @NonNull String type, @NonNull String name, @NonNull Version version, @NonNull Region region) {
this.type = type;
this.name = name;
this.version = version;
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 bd77f013..1eac929b 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
@@ -35,8 +35,6 @@ import org.slf4j.LoggerFactory;
* @see ArtifactRepositoryListener
*/
public final class NotifyingRuntimeArtifactRepository implements RuntimeArtifactRepository {
-
- private static final String USER_REGION_NAME = "org.eclipse.virgo.region.user";
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -103,33 +101,15 @@ public final class NotifyingRuntimeArtifactRepository implements RuntimeArtifact
*/
public Artifact getArtifact(String type, String name, Version version, Region region) {
synchronized (this.monitor) {
- Artifact fallBack = null;
for (Artifact artifact : this.artifacts) {
- if (artifact.getType().equals(type) && artifact.getName().equals(name) && artifact.getVersion().equals(version)){
- if(region == null){
- //Look everywhere because there is still plenty of code that doesn't know about regions
- if(artifact.getRegion() == null){
- return artifact;
- } else {
- //They might mean this artifact but don't know to give a region so return it if we don't find a better match
- String regionName = artifact.getRegion().getName();
- if(USER_REGION_NAME.equals(regionName)){
- //Give priority to the user region
- fallBack = artifact;
- } else if(fallBack == null) {
- //and only set it to the other (kernel) region if nothing has been set already
- fallBack = artifact;
- }
- }
- } else {
- //Otherwise only look in the requested region
- if(artifact.getRegion() != null && artifact.getRegion().equals(region)){
- return artifact;
- }
- }
+ if (artifact.getType().equals(type) &&
+ artifact.getName().equals(name) &&
+ artifact.getVersion().equals(version) &&
+ artifact.getRegion().getName().equals(region.getName())){
+ return artifact;
}
}
- return fallBack;
+ return null;
}
}
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 b5483719..1f25abc6 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
@@ -42,7 +42,7 @@ final class BundleArtifact extends AbstractArtifact {
private final Bundle bundle;
- public BundleArtifact(@NonNull BundleContext bundleContext, @NonNull PackageAdminUtil packageAdminUtil, @NonNull Bundle bundle, Region region) {
+ public BundleArtifact(@NonNull BundleContext bundleContext, @NonNull PackageAdminUtil packageAdminUtil, @NonNull Bundle bundle, @NonNull Region region) {
super(bundleContext, TYPE, bundle.getSymbolicName(), bundle.getVersion(), region);
this.packageAdminUtil = packageAdminUtil;
this.bundle = bundle;
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 391c0f55..cf8d311b 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
@@ -70,8 +70,7 @@ final class ModelBundleListener implements SynchronousBundleListener {
private void processInstalled(BundleEvent event) {
Bundle bundle = event.getBundle();
Region region = this.regionDigraph.getRegion(bundle);
- String regionName = region == null ? "?" : region.getName();
- logger.info("Processing installed event for '{}:{}' in region '" + regionName + "'", bundle.getSymbolicName(), bundle.getVersion().toString());
+ logger.info("Processing installed event for '{}:{}' in region '{}'", new Object[] {bundle.getSymbolicName(), bundle.getVersion().toString(), region.getName()});
this.artifactRepository.add(new BundleArtifact(bundleContext, packageAdminUtil, bundle, region));
}
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 d1894c3b..d40cda1a 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
@@ -49,8 +49,7 @@ public final class ModelBundleListenerInitializer {
private final RegionDigraph regionDigraph;
- public ModelBundleListenerInitializer(@NonNull RuntimeArtifactRepository artifactRepository, @NonNull PackageAdminUtil packageAdminUtil,
- @NonNull BundleContext kernelBundleContext, @NonNull RegionDigraph regionDigraph) {
+ public ModelBundleListenerInitializer(@NonNull RuntimeArtifactRepository artifactRepository, @NonNull PackageAdminUtil packageAdminUtil, @NonNull BundleContext kernelBundleContext, @NonNull RegionDigraph regionDigraph) {
this.artifactRepository = artifactRepository;
this.packageAdminUtil = packageAdminUtil;
this.kernelBundleContext = kernelBundleContext;
@@ -70,8 +69,7 @@ public final class ModelBundleListenerInitializer {
// Find bundles that the listener has almost certainly missed.
for (Bundle bundle : systemBundleContext.getBundles()) {
try {
- this.artifactRepository.add(new BundleArtifact(this.kernelBundleContext, this.packageAdminUtil, bundle,
- this.regionDigraph.getRegion(bundle)));
+ this.artifactRepository.add(new BundleArtifact(this.kernelBundleContext, this.packageAdminUtil, bundle, this.regionDigraph.getRegion(bundle)));
} catch (Exception e) {
this.logger.error(String.format("Exception adding bundle '%s:%s' to the repository", bundle.getSymbolicName(),
bundle.getVersion().toString()), e);
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ConfigurationArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ConfigurationArtifact.java
index cc52980e..796f6b19 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ConfigurationArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ConfigurationArtifact.java
@@ -15,6 +15,7 @@ import java.io.IOException;
import org.eclipse.virgo.kernel.model.ArtifactState;
import org.eclipse.virgo.kernel.model.internal.AbstractArtifact;
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.serviceability.NonNull;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Version;
@@ -42,8 +43,8 @@ final class ConfigurationArtifact extends AbstractArtifact {
private final String pid;
- public ConfigurationArtifact(@NonNull BundleContext bundleContext, @NonNull ConfigurationAdmin configurationAdmin, @NonNull String pid) {
- super(bundleContext, TYPE, pid, Version.emptyVersion, null);
+ public ConfigurationArtifact(@NonNull BundleContext bundleContext, @NonNull ConfigurationAdmin configurationAdmin, @NonNull String pid, @NonNull Region region) {
+ super(bundleContext, TYPE, pid, Version.emptyVersion, region);
this.configurationAdmin = configurationAdmin;
this.pid = pid;
}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListener.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListener.java
index 4798de6f..2f8e32fd 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListener.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListener.java
@@ -13,6 +13,7 @@ package org.eclipse.virgo.kernel.model.internal.configurationadmin;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.serviceability.NonNull;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Version;
@@ -44,11 +45,13 @@ final class ModelConfigurationListener implements ConfigurationListener {
private final ConfigurationAdmin configurationAdmin;
- public ModelConfigurationListener(@NonNull RuntimeArtifactRepository artifactRepository, @NonNull BundleContext bundleContext,
- @NonNull ConfigurationAdmin configurationAdmin) {
+ private final Region independentRegion;
+
+ public ModelConfigurationListener(@NonNull RuntimeArtifactRepository artifactRepository, @NonNull BundleContext bundleContext, @NonNull ConfigurationAdmin configurationAdmin, @NonNull Region independentRegion) {
this.artifactRepository = artifactRepository;
this.bundleContext = bundleContext;
this.configurationAdmin = configurationAdmin;
+ this.independentRegion = independentRegion;
}
/**
@@ -70,14 +73,14 @@ final class ModelConfigurationListener implements ConfigurationListener {
private void processDelete(ConfigurationEvent event) {
logger.info("Processing delete event for '{}'", event.getPid());
- Artifact artifact = this.artifactRepository.getArtifact(ConfigurationArtifact.TYPE, event.getPid(), Version.emptyVersion, null);//Config will never be in a region
+ Artifact artifact = this.artifactRepository.getArtifact(ConfigurationArtifact.TYPE, event.getPid(), Version.emptyVersion, independentRegion);
if (artifact instanceof ConfigurationArtifact) {
- this.artifactRepository.remove(ConfigurationArtifact.TYPE, event.getPid(), Version.emptyVersion, null);//Config will never be in a region
+ this.artifactRepository.remove(ConfigurationArtifact.TYPE, event.getPid(), Version.emptyVersion, independentRegion);
}
}
private ConfigurationArtifact createArtifact(ConfigurationEvent event) {
- return new ConfigurationArtifact(this.bundleContext, this.configurationAdmin, event.getPid());
+ return new ConfigurationArtifact(this.bundleContext, this.configurationAdmin, event.getPid(), independentRegion);
}
}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListenerInitializer.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListenerInitializer.java
index 0ae30b23..dc81f63f 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListenerInitializer.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListenerInitializer.java
@@ -16,6 +16,10 @@ import java.io.IOException;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
+import org.eclipse.equinox.region.Region;
+import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
+import org.eclipse.virgo.kernel.serviceability.NonNull;
+import org.eclipse.virgo.util.osgi.ServiceRegistrationTracker;
import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.service.cm.Configuration;
@@ -24,11 +28,6 @@ import org.osgi.service.cm.ConfigurationListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
-import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
-import org.eclipse.virgo.kernel.serviceability.NonNull;
-import org.eclipse.virgo.util.osgi.ServiceRegistrationTracker;
-
/**
* An initializer responsible for registering a {@link ModelConfigurationListener} and enumerating any existing
* {@link Configuration} objects from {@link ConfigurationAdmin}
@@ -52,11 +51,13 @@ public final class ModelConfigurationListenerInitializer {
private final ConfigurationAdmin configurationAdmin;
- public ModelConfigurationListenerInitializer(@NonNull RuntimeArtifactRepository artifactRepository, @NonNull BundleContext bundleContext,
- @NonNull ConfigurationAdmin configurationAdmin) {
+ private final Region globalRegion;
+
+ public ModelConfigurationListenerInitializer(@NonNull RuntimeArtifactRepository artifactRepository, @NonNull BundleContext bundleContext, @NonNull ConfigurationAdmin configurationAdmin, @NonNull Region globalRegion) {
this.artifactRepository = artifactRepository;
this.bundleContext = bundleContext;
this.configurationAdmin = configurationAdmin;
+ this.globalRegion = globalRegion;
}
/**
@@ -68,13 +69,13 @@ public final class ModelConfigurationListenerInitializer {
*/
@PostConstruct
public void initialize() throws IOException, InvalidSyntaxException {
- ModelConfigurationListener configurationListener = new ModelConfigurationListener(artifactRepository, bundleContext, configurationAdmin);
+ ModelConfigurationListener configurationListener = new ModelConfigurationListener(artifactRepository, bundleContext, configurationAdmin, globalRegion);
this.registrationTracker.track(this.bundleContext.registerService(ConfigurationListener.class.getCanonicalName(), configurationListener, null));
Configuration[] configurations = this.configurationAdmin.listConfigurations(null);
if (configurations != null) {
for (Configuration configuration : configurations) {
try {
- this.artifactRepository.add(new ConfigurationArtifact(bundleContext, configurationAdmin, configuration.getPid()));
+ this.artifactRepository.add(new ConfigurationArtifact(bundleContext, configurationAdmin, configuration.getPid(), globalRegion));
} catch (Exception e) {
logger.error(String.format("Exception adding configuration '%s' to the repository", configuration.getPid()), e);
}
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 ca84fa09..b2fcf8ff 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
@@ -41,11 +41,6 @@ import org.osgi.framework.BundleContext;
class DeployerArtifact extends AbstractArtifact {
private final InstallArtifact installArtifact;
-
- public DeployerArtifact(@NonNull BundleContext bundleContext, @NonNull InstallArtifact installArtifact) {
- super(bundleContext, installArtifact.getType(), installArtifact.getName(), installArtifact.getVersion(), null);
- this.installArtifact = installArtifact;
- }
public DeployerArtifact(@NonNull BundleContext bundleContext, @NonNull InstallArtifact installArtifact, Region region) {
super(bundleContext, installArtifact.getType(), installArtifact.getName(), installArtifact.getVersion(), region);
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 8bc30df7..0380241d 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
@@ -23,7 +23,7 @@ final class DeployerBundleArtifact extends DeployerArtifact implements BundleArt
private final BundleInstallArtifact installArtifact;
- public DeployerBundleArtifact(@NonNull BundleContext bundleContext, @NonNull BundleInstallArtifact installArtifact, Region region) {
+ public DeployerBundleArtifact(@NonNull BundleContext bundleContext, @NonNull BundleInstallArtifact installArtifact, @NonNull Region region) {
super(bundleContext, installArtifact, region);
this.installArtifact = installArtifact;
}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifact.java
index c424b585..02b36be9 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifact.java
@@ -16,6 +16,7 @@ import org.osgi.framework.BundleContext;
import org.eclipse.virgo.kernel.install.artifact.PlanInstallArtifact;
import org.eclipse.virgo.kernel.model.CompositeArtifact;
+import org.eclipse.equinox.region.Region;
/**
* Implementation of {@link CompositeArtifact} that delegates to a Kernel {@link PlanInstallArtifact}
@@ -30,8 +31,8 @@ final class DeployerCompositeArtifact extends DeployerArtifact implements Compos
private final PlanInstallArtifact installArtifact;
- public DeployerCompositeArtifact(@NonNull BundleContext bundleContext, @NonNull PlanInstallArtifact installArtifact) {
- super(bundleContext, installArtifact);
+ public DeployerCompositeArtifact(@NonNull BundleContext bundleContext, @NonNull PlanInstallArtifact installArtifact, @NonNull Region region) {
+ super(bundleContext, installArtifact, region);
this.installArtifact = installArtifact;
}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifactDependencyDeterminer.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifactDependencyDeterminer.java
index 40e0beed..deb8296c 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifactDependencyDeterminer.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifactDependencyDeterminer.java
@@ -20,6 +20,7 @@ import org.eclipse.virgo.kernel.install.artifact.InstallArtifact;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.serviceability.NonNull;
import org.eclipse.virgo.util.common.Tree;
@@ -38,9 +39,15 @@ import org.eclipse.virgo.util.common.Tree;
public final class DeployerCompositeArtifactDependencyDeterminer implements DependencyDeterminer {
private final RuntimeArtifactRepository artifactRepository;
+
+ private final Region globalRegion;
+
+ private final Region userRegion;
- public DeployerCompositeArtifactDependencyDeterminer(@NonNull RuntimeArtifactRepository artifactRepository) {
+ public DeployerCompositeArtifactDependencyDeterminer(@NonNull RuntimeArtifactRepository artifactRepository, @NonNull Region userRegion, @NonNull Region globalRegion) {
this.artifactRepository = artifactRepository;
+ this.userRegion = userRegion;
+ this.globalRegion = globalRegion;
}
/**
@@ -55,7 +62,11 @@ public final class DeployerCompositeArtifactDependencyDeterminer implements Depe
List<Tree<InstallArtifact>> children = ((DeployerCompositeArtifact) rootArtifact).getInstallArtifact().getTree().getChildren();
for (Tree<InstallArtifact> child : children) {
InstallArtifact artifact = child.getValue();
- dependents.add(artifactRepository.getArtifact(artifact.getType(), artifact.getName(), artifact.getVersion(), rootArtifact.getRegion()));//Plans don't have a region so this only works as null will also return artifacts in regions
+ if(artifact.getType().equalsIgnoreCase("bundle")){
+ dependents.add(this.artifactRepository.getArtifact(artifact.getType(), artifact.getName(), artifact.getVersion(), this.userRegion));
+ }else{
+ dependents.add(this.artifactRepository.getArtifact(artifact.getType(), artifact.getName(), artifact.getVersion(), this.globalRegion));
+ }
}
return dependents;
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 3fd4073b..10185966 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
@@ -12,6 +12,7 @@
package org.eclipse.virgo.kernel.model.internal.deployer;
import org.eclipse.equinox.region.RegionDigraph;
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
import org.eclipse.virgo.kernel.install.artifact.BundleInstallArtifact;
import org.eclipse.virgo.kernel.install.artifact.InstallArtifact;
@@ -55,11 +56,13 @@ class ModelInstallArtifactLifecycleListener extends InstallArtifactLifecycleList
private final RegionDigraph regionDigraph;
- public ModelInstallArtifactLifecycleListener(@NonNull BundleContext bundleContext, @NonNull RuntimeArtifactRepository artifactRepository,
- @NonNull RegionDigraph regionDigraph) {
+ private final Region globalRegion;
+
+ public ModelInstallArtifactLifecycleListener(@NonNull BundleContext bundleContext, @NonNull RuntimeArtifactRepository artifactRepository, @NonNull RegionDigraph regionDigraph, @NonNull Region globalRegion) {
this.bundleContext = bundleContext;
this.artifactRepository = artifactRepository;
this.regionDigraph = regionDigraph;
+ this.globalRegion = globalRegion;
}
/**
@@ -78,7 +81,7 @@ class ModelInstallArtifactLifecycleListener extends InstallArtifactLifecycleList
}
private void addPlan(PlanInstallArtifact planInstallArtifact) {
- this.artifactRepository.add(new DeployerCompositeArtifact(this.bundleContext, planInstallArtifact));
+ this.artifactRepository.add(new DeployerCompositeArtifact(this.bundleContext, planInstallArtifact, this.globalRegion));
}
private void addOrReplaceBundle(BundleInstallArtifact bundleInstallArtifact) {
@@ -90,7 +93,7 @@ class ModelInstallArtifactLifecycleListener extends InstallArtifactLifecycleList
}
private void addArtifact(InstallArtifact installArtifact) {
- this.artifactRepository.add(new DeployerArtifact(this.bundleContext, installArtifact));
+ this.artifactRepository.add(new DeployerArtifact(this.bundleContext, installArtifact, this.globalRegion));
}
/**
@@ -120,7 +123,7 @@ class ModelInstallArtifactLifecycleListener extends InstallArtifactLifecycleList
if(installArtifact instanceof BundleInstallArtifact){
this.artifactRepository.remove(installArtifact.getType(), installArtifact.getName(), installArtifact.getVersion(), this.regionDigraph.getRegion(USER_REGION_NAME));
} else {
- this.artifactRepository.remove(installArtifact.getType(), installArtifact.getName(), installArtifact.getVersion(), null);
+ this.artifactRepository.remove(installArtifact.getType(), installArtifact.getName(), installArtifact.getVersion(), this.globalRegion);
}
}
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 8903ae5f..644394c2 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
@@ -14,6 +14,7 @@ package org.eclipse.virgo.kernel.model.internal.deployer;
import javax.annotation.PostConstruct;
import org.eclipse.equinox.region.RegionDigraph;
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
import org.eclipse.virgo.kernel.deployer.model.RuntimeArtifactModel;
import org.eclipse.virgo.kernel.install.artifact.BundleInstallArtifact;
@@ -54,12 +55,14 @@ public final class ModelInstallArtifactLifecycleListenerInitializer {
private final RegionDigraph regionDigraph;
- public ModelInstallArtifactLifecycleListenerInitializer(@NonNull RuntimeArtifactRepository artifactRepository,
- @NonNull BundleContext bundleContext, @NonNull RuntimeArtifactModel runtimeArtifactModel, @NonNull RegionDigraph regionDigraph) {
+ private final Region globalRegion;
+
+ public ModelInstallArtifactLifecycleListenerInitializer(@NonNull RuntimeArtifactRepository artifactRepository, @NonNull BundleContext bundleContext, @NonNull RuntimeArtifactModel runtimeArtifactModel, @NonNull RegionDigraph regionDigraph, @NonNull Region globalRegion) {
this.artifactRepository = artifactRepository;
this.bundleContext = bundleContext;
this.runtimeArtifactModel = runtimeArtifactModel;
this.regionDigraph = regionDigraph;
+ this.globalRegion = globalRegion;
}
/**
@@ -68,20 +71,20 @@ public final class ModelInstallArtifactLifecycleListenerInitializer {
*/
@PostConstruct
public void initialize() {
- ModelInstallArtifactLifecycleListener listener = new ModelInstallArtifactLifecycleListener(this.bundleContext, this.artifactRepository, this.regionDigraph);
+ ModelInstallArtifactLifecycleListener listener = new ModelInstallArtifactLifecycleListener(this.bundleContext, this.artifactRepository, this.regionDigraph, this.globalRegion);
this.registrationTracker.track(this.bundleContext.registerService(InstallArtifactLifecycleListener.class.getCanonicalName(), listener, null));
for (DeploymentIdentity deploymentIdentity : this.runtimeArtifactModel.getDeploymentIdentities()) {
InstallArtifact installArtifact = this.runtimeArtifactModel.get(deploymentIdentity);
try {
if (installArtifact instanceof PlanInstallArtifact) {
- this.artifactRepository.add(new DeployerCompositeArtifact(this.bundleContext, (PlanInstallArtifact) installArtifact));
+ this.artifactRepository.add(new DeployerCompositeArtifact(this.bundleContext, (PlanInstallArtifact) installArtifact, this.globalRegion));
} else if (installArtifact instanceof BundleInstallArtifact) {
this.artifactRepository.remove(installArtifact.getType(), installArtifact.getName(), installArtifact.getVersion(), this.regionDigraph.getRegion(USER_REGION_NAME));
BundleInstallArtifact bundleInstallArtifact = (BundleInstallArtifact) installArtifact;
this.artifactRepository.add(new DeployerBundleArtifact(this.bundleContext, bundleInstallArtifact, this.regionDigraph.getRegion(USER_REGION_NAME)));
} else {
this.artifactRepository.remove(installArtifact.getType(), installArtifact.getName(), installArtifact.getVersion(), null);
- this.artifactRepository.add(new DeployerArtifact(this.bundleContext, installArtifact));
+ this.artifactRepository.add(new DeployerArtifact(this.bundleContext, installArtifact, this.globalRegion));
}
} catch (Exception e) {
logger.error(String.format("Exception adding deployer artifact '%s:%s' to the repository", installArtifact.getName(),
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 49ff319e..47e0c6ca 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
@@ -35,6 +35,8 @@ public final class DefaultRuntimeArtifactModelObjectNameCreator implements Runti
private static final String USER_REGION_NAME = "org.eclipse.virgo.region.user";
+ private static final String GLOBAL_REGION_NAME = "global";
+
private static final String ARTIFACTS_FORMAT = "%s:type=Model,*";
private static final String ALL_ARTIFACTS_FORMAT = "%s:type=*Model,*";
@@ -65,7 +67,7 @@ public final class DefaultRuntimeArtifactModelObjectNameCreator implements Runti
public ObjectName create(@NonNull Artifact artifact) {
Region region = artifact.getRegion();
// Treat user region artifacts specially to preserve JMX compatibility with Virgo 2.1.0.
- if (region == null || USER_REGION_NAME.equals(region.getName())) {
+ if (USER_REGION_NAME.equals(region.getName()) || GLOBAL_REGION_NAME.equals(region.getName()) ) {
return create(artifact.getType(), artifact.getName(), artifact.getVersion());
}
return create(artifact.getType(), artifact.getName(), artifact.getVersion(), region);
@@ -75,8 +77,7 @@ public final class DefaultRuntimeArtifactModelObjectNameCreator implements Runti
* {@inheritDoc}
*/
public ObjectName create(String type, String name, Version version, Region region) {
- String regionName = region == null ? "?" : region.getName();
- return createObjectName(String.format(EXTENDED_ARTIFACT_FORMAT, this.domain, type, name, version, regionName));
+ return createObjectName(String.format(EXTENDED_ARTIFACT_FORMAT, this.domain, type, name, version, region.getName()));
}
/**
diff --git a/org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/module-context.xml b/org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/module-context.xml
index 1573b417..fedb4a8f 100644
--- a/org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/module-context.xml
+++ b/org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/module-context.xml
@@ -16,6 +16,7 @@
<constructor-arg ref="artifactRepository"/>
<constructor-arg ref="bundleContext"/>
<constructor-arg ref="configurationAdmin"/>
+ <constructor-arg ref="globalRegion"/>
</bean>
<bean class="org.eclipse.virgo.kernel.model.internal.deployer.ModelInstallArtifactLifecycleListenerInitializer">
@@ -23,6 +24,7 @@
<constructor-arg ref="bundleContext"/>
<constructor-arg ref="runtimeArtifactModel"/>
<constructor-arg ref="regionDigraph"/>
+ <constructor-arg ref="globalRegion"/>
</bean>
<bean id="bundleDependencyDeterminer" class="org.eclipse.virgo.kernel.model.internal.bundle.BundleDependencyDeterminer">
@@ -31,9 +33,10 @@
<constructor-arg ref="regionDigraph"/>
</bean>
- <bean id="deployerCompositeArtifactDependencyDeterminer"
- class="org.eclipse.virgo.kernel.model.internal.deployer.DeployerCompositeArtifactDependencyDeterminer">
+ <bean id="deployerCompositeArtifactDependencyDeterminer" class="org.eclipse.virgo.kernel.model.internal.deployer.DeployerCompositeArtifactDependencyDeterminer">
<constructor-arg ref="artifactRepository"/>
+ <constructor-arg ref="userRegion"/>
+ <constructor-arg ref="globalRegion"/>
</bean>
<bean id="artifactRepository" class="org.eclipse.virgo.kernel.model.internal.NotifyingRuntimeArtifactRepository">
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 22c8c648..ca37d85c 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
@@ -40,7 +40,11 @@
<reference id="runtimeArtifactModel" interface="org.eclipse.virgo.kernel.deployer.model.RuntimeArtifactModel"/>
<reference id="applicationDeployer" interface="org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer"/>
-
+
<reference id="regionDigraph" interface="org.eclipse.equinox.region.RegionDigraph" />
+
+ <reference id="globalRegion" interface="org.eclipse.equinox.region.Region" filter="(org.eclipse.virgo.kernel.region.name=global)" />
+
+ <reference id="userRegion" interface="org.eclipse.equinox.region.Region" filter="(org.eclipse.virgo.kernel.region.name=org.eclipse.virgo.region.user)" />
</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 5e9a6be2..eb9d97c9 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
@@ -35,16 +35,8 @@ public class StubArtifactRepository implements RuntimeArtifactRepository {
public Artifact getArtifact(String type, String name, Version version, Region region) {
for (Artifact artifact : this.artifacts) {
- if (artifact.getType().equals(type) && artifact.getName().equals(name) && artifact.getVersion().equals(version)) {
- if(artifact.getRegion() == null){
- if(region == null){
- return artifact;
- }
- }else{
- if(artifact.getRegion().equals(region)){
- return artifact;
- }
- }
+ if (artifact.getType().equals(type) && artifact.getName().equals(name) && artifact.getVersion().equals(version) && artifact.getRegion().equals(region)) {
+ return artifact;
}
}
return null;
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 028ba34f..e8e74e4b 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
@@ -26,7 +26,7 @@ public class StubCompositeArtifact implements CompositeArtifact {
private final Region region;
public StubCompositeArtifact() {
- this("test-type", "test-name", null);
+ this("test-type", "test-name", new StubRegion("test-region"));
}
public StubCompositeArtifact(String type, String name, Region region) {
@@ -55,6 +55,10 @@ public class StubCompositeArtifact implements CompositeArtifact {
return Version.emptyVersion;
}
+ public Region getRegion() {
+ return this.region;
+ }
+
public boolean refresh() {
throw new UnsupportedOperationException();
}
@@ -83,8 +87,4 @@ public class StubCompositeArtifact implements CompositeArtifact {
throw new UnsupportedOperationException();
}
- public Region getRegion() {
- return this.region;
- }
-
}
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubRegion.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubRegion.java
new file mode 100644
index 00000000..48e5fb8e
--- /dev/null
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubRegion.java
@@ -0,0 +1,155 @@
+/*
+ * This file is part of the Eclipse Virgo project.
+ *
+ * Copyright (c) 2011 copyright_holder
+ * 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:
+ * cgfrost - initial contribution
+ */
+
+package org.eclipse.virgo.kernel.model;
+
+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.RegionDigraphVisitor;
+import org.eclipse.equinox.region.RegionFilter;
+import org.eclipse.equinox.region.RegionDigraph.FilteredRegion;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Version;
+
+/**
+ * StubRegion
+ */
+public class StubRegion implements Region {
+
+ private final String name;
+
+ public StubRegion(String name) {
+ this.name = name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addBundle(Bundle bundle) throws BundleException {
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addBundle(long bundleId) {
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Bundle installBundle(String location, InputStream input) throws BundleException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Bundle installBundle(String location) throws BundleException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Set<Long> getBundleIds() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean contains(Bundle bundle) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean contains(long bundleId) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Bundle getBundle(String symbolicName, Version version) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void connectRegion(Region headRegion, RegionFilter filter) throws BundleException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public RegionDigraph getRegionDigraph() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void removeBundle(Bundle bundle) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void removeBundle(long bundleId) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Set<FilteredRegion> getEdges() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void visitSubgraph(RegionDigraphVisitor visitor) {
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/AbztractArtifactTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/AbztractArtifactTests.java
index e9c6c9cf..a99ff9a5 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/AbztractArtifactTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/AbztractArtifactTests.java
@@ -30,8 +30,10 @@ import org.osgi.framework.Version;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.ArtifactState;
import org.eclipse.virgo.kernel.model.StubCompositeArtifact;
+import org.eclipse.virgo.kernel.model.StubRegion;
import org.eclipse.virgo.kernel.model.internal.AbstractArtifact;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.serviceability.Assert.FatalAssertionException;
import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
import org.eclipse.virgo.teststubs.osgi.support.TrueFilter;
@@ -42,36 +44,43 @@ public class AbztractArtifactTests {
private final AbstractArtifact artifact;
+ private final StubRegion region = new StubRegion("test-region");
+
{
bundleContext = new StubBundleContext();
String filterString = String.format("(&(objectClass=%s)(artifactType=test-type))", DependencyDeterminer.class.getCanonicalName());
bundleContext.addFilter(filterString, new TrueFilter(filterString));
- artifact = new StubArtifact(bundleContext, "test-type", "test-name", Version.emptyVersion);
+ artifact = new StubArtifact(bundleContext, "test-type", "test-name", Version.emptyVersion, region);
}
@Test(expected = FatalAssertionException.class)
public void nullBundleContext() {
- new StubArtifact(null, "type", "name", Version.emptyVersion);
+ new StubArtifact(null, "type", "name", Version.emptyVersion, region);
}
@Test(expected = FatalAssertionException.class)
public void nullType() {
- new StubArtifact(new StubBundleContext(), null, "name", Version.emptyVersion);
+ new StubArtifact(new StubBundleContext(), null, "name", Version.emptyVersion, region);
}
@Test(expected = FatalAssertionException.class)
public void nullName() {
- new StubArtifact(new StubBundleContext(), "type", null, Version.emptyVersion);
+ new StubArtifact(new StubBundleContext(), "type", null, Version.emptyVersion, region);
}
@Test(expected = FatalAssertionException.class)
public void nullVersion() {
- new StubArtifact(new StubBundleContext(), "type", "name", null);
+ new StubArtifact(new StubBundleContext(), "type", "name", null, region);
+ }
+
+ @Test(expected = FatalAssertionException.class)
+ public void nullRegion() {
+ new StubArtifact(new StubBundleContext(), "type", "name", Version.emptyVersion, null);
}
@Test(expected = RuntimeException.class)
public void badFilter() {
- new StubArtifact(new StubBundleContext(), "type", "name", Version.emptyVersion);
+ new StubArtifact(new StubBundleContext(), "type", "name", Version.emptyVersion, region);
}
@Test
@@ -89,6 +98,11 @@ public class AbztractArtifactTests {
assertEquals(Version.emptyVersion, artifact.getVersion());
}
+ @Test
+ public void getRegion() {
+ assertEquals("test-region", artifact.getRegion().getName());
+ }
+
@SuppressWarnings("unchecked")
@Test
public void getDependents() {
@@ -121,11 +135,11 @@ public class AbztractArtifactTests {
private static class StubArtifact extends AbstractArtifact {
public StubArtifact(BundleContext bundleContext) {
- super(bundleContext, "test-type", "test-name", Version.emptyVersion, null);
+ super(bundleContext, "test-type", "test-name", Version.emptyVersion, new StubRegion("test-region"));
}
- public StubArtifact(BundleContext bundleContext, String type, String name, Version version) {
- super(bundleContext, type, name, version, null);
+ public StubArtifact(BundleContext bundleContext, String type, String name, Version version, Region region) {
+ super(bundleContext, type, name, version, region);
}
public ArtifactState getState() {
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 079ea408..f481a97e 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
@@ -17,19 +17,13 @@ import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
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.model.StubRegion;
import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
import org.osgi.framework.Version;
@@ -77,81 +71,21 @@ public class NotifyingArtifactRepositoryTests {
@Test
public void getArtifact(){
- Region stubRegion = new StubRegion();
- Artifact stubArtifact = new StubCompositeArtifact("foo", "bar", null);
- Artifact stubArtifact2 = new StubCompositeArtifact("foo2", "bar2", stubRegion);
+ Region stubRegion1 = new StubRegion("test-region1");
+ Region stubRegion2 = new StubRegion("test-region2");
+ Artifact stubArtifact = new StubCompositeArtifact("foo", "bar", stubRegion1);
+ Artifact stubArtifact2 = new StubCompositeArtifact("foo2", "bar2", stubRegion2);
this.artifactRepository.add(stubArtifact);
this.artifactRepository.add(stubArtifact2);
Artifact retrieved = this.artifactRepository.getArtifact("foo", "bar", new Version("0.1.0"), null);
assertNull(retrieved);
- retrieved = this.artifactRepository.getArtifact("foo", "bar", Version.emptyVersion, null);
+ retrieved = this.artifactRepository.getArtifact("foo", "bar", Version.emptyVersion, stubRegion1);
assertEquals(stubArtifact, retrieved);
- retrieved = this.artifactRepository.getArtifact("foo", "bar", Version.emptyVersion, stubRegion);
+ retrieved = this.artifactRepository.getArtifact("foo", "bar", Version.emptyVersion, stubRegion2);
assertNull(retrieved);
- retrieved = this.artifactRepository.getArtifact("foo2", "bar2", Version.emptyVersion, stubRegion);
+ retrieved = this.artifactRepository.getArtifact("foo2", "bar2", Version.emptyVersion, stubRegion2);
assertEquals(stubArtifact2, retrieved);
}
-
- private static class StubRegion implements Region{
-
- public String getName() {
- return "region";
- }
-
- public void addBundle(Bundle bundle) throws BundleException {
-
- }
-
- public void addBundle(long bundleId) {
-
- }
-
- public Bundle installBundle(String location, InputStream input) throws BundleException {
- return null;
- }
-
- public Bundle installBundle(String location) throws BundleException {
- return null;
- }
-
- public Set<Long> getBundleIds() {
- return null;
- }
-
- public boolean contains(Bundle bundle) {
- return false;
- }
-
- public boolean contains(long bundleId) {
- return false;
- }
-
- public Bundle getBundle(String symbolicName, Version version) {
- return null;
- }
-
- public void connectRegion(Region headRegion, RegionFilter filter) throws BundleException {
- }
-
- public void removeBundle(Bundle bundle) {
- }
-
- public void removeBundle(long bundleId) {
- }
-
- public Set<FilteredRegion> getEdges() {
- return null;
- }
-
- public void visitSubgraph(RegionDigraphVisitor visitor) {
- }
-
- @Override
- public RegionDigraph getRegionDigraph() {
- return null;
- }
-
- }
private static class StubArtifactRepositoryListener implements ArtifactRepositoryListener {
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 bff93e76..04f65cfa 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
@@ -12,12 +12,16 @@
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.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.StubRegion;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
import org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil;
import org.eclipse.virgo.kernel.serviceability.Assert.FatalAssertionException;
@@ -31,6 +35,8 @@ import org.osgi.framework.Version;
public class ModelBundleListenerInitializerTests {
private final StubArtifactRepository artifactRepository = new StubArtifactRepository();
+
+ private final StubRegion region = new StubRegion("test-region");
private final PackageAdminUtil packageAdminUtil = createMock(PackageAdminUtil.class);
@@ -49,10 +55,10 @@ public class ModelBundleListenerInitializerTests {
this.systemBundleContext.addInstalledBundle(bundle);
String filterString = String.format("(&(objectClass=%s)(artifactType=bundle))", DependencyDeterminer.class.getCanonicalName());
this.bundleContext.addFilter(filterString, new TrueFilter(filterString));
+ expect(regionDigraph.getRegion(bundle)).andReturn(region).anyTimes();
}
- private final ModelBundleListenerInitializer initializer = new ModelBundleListenerInitializer(artifactRepository, packageAdminUtil,
- bundleContext, regionDigraph);
+ private final ModelBundleListenerInitializer initializer = new ModelBundleListenerInitializer(artifactRepository, packageAdminUtil, bundleContext, regionDigraph);
@Test(expected = FatalAssertionException.class)
public void nullArtifactRepository() {
@@ -76,17 +82,21 @@ public class ModelBundleListenerInitializerTests {
@Test
public void initialize() throws IOException, InvalidSyntaxException {
+ replay(this.regionDigraph);
assertEquals(0, this.systemBundleContext.getBundleListeners().size());
this.initializer.initialize();
assertEquals(1, this.systemBundleContext.getBundleListeners().size());
assertEquals(1, this.artifactRepository.getArtifacts().size());
+ verify(this.regionDigraph);
}
@Test
public void destroy() throws IOException, InvalidSyntaxException {
+ replay(this.regionDigraph);
this.initializer.initialize();
assertEquals(1, this.systemBundleContext.getBundleListeners().size());
this.initializer.destroy();
assertEquals(0, this.systemBundleContext.getBundleListeners().size());
+ verify(this.regionDigraph);
}
}
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 6a939d7f..b03ff247 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
@@ -19,6 +19,7 @@ import static org.junit.Assert.assertEquals;
import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.virgo.kernel.model.StubArtifactRepository;
+import org.eclipse.virgo.kernel.model.StubRegion;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
import org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil;
import org.eclipse.virgo.kernel.serviceability.Assert.FatalAssertionException;
@@ -38,12 +39,14 @@ public class ModelBundleListenerTests {
private final StubBundleContext bundleContext;
private final RegionDigraph regionDigraph = createMock(RegionDigraph.class);
+
+ private final StubRegion region = new StubRegion("test-region");
{
this.bundleContext = new StubBundleContext();
String filterString = String.format("(&(objectClass=%s)(artifactType=bundle))", DependencyDeterminer.class.getCanonicalName());
this.bundleContext.addFilter(filterString, new TrueFilter(filterString));
- expect(regionDigraph.getRegion(isA(Bundle.class))).andReturn(null).anyTimes();
+ expect(regionDigraph.getRegion(isA(Bundle.class))).andReturn(region).anyTimes();
}
private final ModelBundleListener listener = new ModelBundleListener(bundleContext, artifactRepository, packageAdminUtil, regionDigraph);
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ConfgurationArtifactTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ConfgurationArtifactTests.java
index 04de9dc0..53768df7 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ConfgurationArtifactTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ConfgurationArtifactTests.java
@@ -21,6 +21,7 @@ import org.osgi.framework.InvalidSyntaxException;
import org.eclipse.virgo.kernel.model.ArtifactState;
+import org.eclipse.virgo.kernel.model.StubRegion;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
import org.eclipse.virgo.kernel.model.internal.configurationadmin.ConfigurationArtifact;
import org.eclipse.virgo.kernel.serviceability.Assert.FatalAssertionException;
@@ -38,22 +39,29 @@ public class ConfgurationArtifactTests {
}
private final StubConfigurationAdmin configurationAdmin = new StubConfigurationAdmin();
+
+ private final StubRegion region = new StubRegion("test-region");
- private final ConfigurationArtifact artifact = new ConfigurationArtifact(bundleContext, configurationAdmin, "test-pid");
+ private final ConfigurationArtifact artifact = new ConfigurationArtifact(bundleContext, configurationAdmin, "test-pid", region);
@Test(expected = FatalAssertionException.class)
public void nullBundleContext() {
- new ConfigurationArtifact(null, configurationAdmin, "test-pid");
+ new ConfigurationArtifact(null, configurationAdmin, "test-pid", region);
}
@Test(expected = FatalAssertionException.class)
public void nullConfigurationAdmin() {
- new ConfigurationArtifact(bundleContext, null, "test-pid");
+ new ConfigurationArtifact(bundleContext, null, "test-pid", region);
}
@Test(expected = FatalAssertionException.class)
public void nullArtifactRepository() {
- new ConfigurationArtifact(bundleContext, configurationAdmin, null);
+ new ConfigurationArtifact(bundleContext, configurationAdmin, null, region);
+ }
+
+ @Test(expected = FatalAssertionException.class)
+ public void nullRegion() {
+ new ConfigurationArtifact(bundleContext, configurationAdmin, "test-pid", null);
}
@Test
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListenerInitializerTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListenerInitializerTests.java
index 13244e5e..3d3d87a0 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListenerInitializerTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListenerInitializerTests.java
@@ -20,6 +20,7 @@ import org.osgi.framework.InvalidSyntaxException;
import org.eclipse.virgo.kernel.model.StubArtifactRepository;
+import org.eclipse.virgo.kernel.model.StubRegion;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
import org.eclipse.virgo.kernel.model.internal.configurationadmin.ModelConfigurationListenerInitializer;
import org.eclipse.virgo.kernel.serviceability.Assert.FatalAssertionException;
@@ -37,23 +38,30 @@ public class ModelConfigurationListenerInitializerTests {
this.bundleContext.addFilter(filterString, new TrueFilter(filterString));
}
+ private final StubRegion region = new StubRegion("test-region");
+
private final StubConfigurationAdmin configurationAdmin = new StubConfigurationAdmin();
- private final ModelConfigurationListenerInitializer initializer = new ModelConfigurationListenerInitializer(artifactRepository, bundleContext, configurationAdmin);
+ private final ModelConfigurationListenerInitializer initializer = new ModelConfigurationListenerInitializer(artifactRepository, bundleContext, configurationAdmin, region);
@Test(expected = FatalAssertionException.class)
public void nullArtifactRepository() {
- new ModelConfigurationListenerInitializer(null, bundleContext, configurationAdmin);
+ new ModelConfigurationListenerInitializer(null, bundleContext, configurationAdmin, region);
}
@Test(expected = FatalAssertionException.class)
public void nullBundleContext() {
- new ModelConfigurationListenerInitializer(artifactRepository, null, configurationAdmin);
+ new ModelConfigurationListenerInitializer(artifactRepository, null, configurationAdmin, region);
}
@Test(expected = FatalAssertionException.class)
public void nullConfigurationAdmin() {
- new ModelConfigurationListenerInitializer(artifactRepository, bundleContext, null);
+ new ModelConfigurationListenerInitializer(artifactRepository, bundleContext, null, region);
+ }
+
+ @Test(expected = FatalAssertionException.class)
+ public void nullRegion() {
+ new ModelConfigurationListenerInitializer(artifactRepository, bundleContext, configurationAdmin, null);
}
@Test
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListenerTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListenerTests.java
index 2a3e292e..263c7259 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListenerTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListenerTests.java
@@ -20,6 +20,7 @@ import org.osgi.service.cm.ConfigurationEvent;
import org.eclipse.virgo.kernel.model.StubArtifactRepository;
+import org.eclipse.virgo.kernel.model.StubRegion;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
import org.eclipse.virgo.kernel.model.internal.configurationadmin.ModelConfigurationListener;
import org.eclipse.virgo.kernel.serviceability.Assert.FatalAssertionException;
@@ -43,21 +44,28 @@ public class ModelConfigurationListenerTests {
private final StubConfigurationAdmin configurationAdmin = new StubConfigurationAdmin();
- private final ModelConfigurationListener listener = new ModelConfigurationListener(artifactRepository, bundleContext, configurationAdmin);
+ private final StubRegion region = new StubRegion("test-region");
+
+ private final ModelConfigurationListener listener = new ModelConfigurationListener(artifactRepository, bundleContext, configurationAdmin, region);
@Test(expected = FatalAssertionException.class)
public void nullArtifactRepository() {
- new ModelConfigurationListener(null, bundleContext, configurationAdmin);
+ new ModelConfigurationListener(null, bundleContext, configurationAdmin, region);
}
@Test(expected = FatalAssertionException.class)
public void nullBundleContext() {
- new ModelConfigurationListener(artifactRepository, null, configurationAdmin);
+ new ModelConfigurationListener(artifactRepository, null, configurationAdmin, region);
}
@Test(expected = FatalAssertionException.class)
public void nullConfigurationAdmin() {
- new ModelConfigurationListener(artifactRepository, bundleContext, null);
+ new ModelConfigurationListener(artifactRepository, bundleContext, null, region);
+ }
+
+ @Test(expected = FatalAssertionException.class)
+ public void nullRegion() {
+ new ModelConfigurationListener(artifactRepository, bundleContext, configurationAdmin, null);
}
@Test
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerArtifactTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerArtifactTests.java
index d5778e77..c66cf520 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerArtifactTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerArtifactTests.java
@@ -23,6 +23,7 @@ import org.osgi.framework.Version;
import org.eclipse.virgo.kernel.install.artifact.InstallArtifact;
import org.eclipse.virgo.kernel.install.artifact.InstallArtifact.State;
import org.eclipse.virgo.kernel.model.ArtifactState;
+import org.eclipse.virgo.kernel.model.StubRegion;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
import org.eclipse.virgo.kernel.model.internal.deployer.DeployerArtifact;
@@ -42,16 +43,23 @@ public class DeployerArtifactTests {
bundleContext.addFilter(filterString, new TrueFilter(filterString));
}
- private final DeployerArtifact artifact = new DeployerArtifact(bundleContext, new StubInstallArtifact("bundle"));
+ private final StubRegion region = new StubRegion("test-region");
+
+ private final DeployerArtifact artifact = new DeployerArtifact(bundleContext, new StubInstallArtifact("bundle"), region);
@Test(expected = FatalAssertionException.class)
public void testNullBundleContext() {
- new DeployerArtifact(null, new StubInstallArtifact("bundle"));
+ new DeployerArtifact(null, new StubInstallArtifact("bundle"), region);
}
@Test(expected = FatalAssertionException.class)
public void testNullInstallArtifact() {
- new DeployerArtifact(this.bundleContext, null);
+ new DeployerArtifact(this.bundleContext, null, region);
+ }
+
+ @Test(expected = FatalAssertionException.class)
+ public void testNullRegion() {
+ new DeployerArtifact(this.bundleContext, new StubInstallArtifact("bundle"), null);
}
@Test
@@ -74,7 +82,7 @@ public class DeployerArtifactTests {
expect(installArtifact.getState()).andReturn(State.UNINSTALLED);
replay(installArtifact);
- DeployerArtifact artifact1 = new DeployerArtifact(bundleContext, installArtifact);
+ DeployerArtifact artifact1 = new DeployerArtifact(bundleContext, installArtifact, region);
assertEquals(ArtifactState.INITIAL, artifact1.getState());
assertEquals(ArtifactState.INSTALLING, artifact1.getState());
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifactDependencyDeterminerTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifactDependencyDeterminerTests.java
index a68bb6da..d22e321a 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifactDependencyDeterminerTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifactDependencyDeterminerTests.java
@@ -19,6 +19,7 @@ import org.eclipse.virgo.kernel.install.artifact.InstallArtifact;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
import org.eclipse.virgo.kernel.model.StubArtifactRepository;
import org.eclipse.virgo.kernel.model.StubCompositeArtifact;
+import org.eclipse.virgo.kernel.model.StubRegion;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
import org.eclipse.virgo.kernel.model.internal.deployer.DeployerCompositeArtifact;
import org.eclipse.virgo.kernel.model.internal.deployer.DeployerCompositeArtifactDependencyDeterminer;
@@ -42,11 +43,25 @@ public class DeployerCompositeArtifactDependencyDeterminerTests {
this.bundleContext.addFilter(filterString, new TrueFilter(filterString));
}
- private final DeployerCompositeArtifactDependencyDeterminer determiner = new DeployerCompositeArtifactDependencyDeterminer(artifactRepository);
+ private final StubRegion region1 = new StubRegion("test-region1");
+
+ private final StubRegion region2 = new StubRegion("test-region2");
+
+ private final DeployerCompositeArtifactDependencyDeterminer determiner = new DeployerCompositeArtifactDependencyDeterminer(artifactRepository, region1, region2);
@Test(expected = FatalAssertionException.class)
public void nullRepository() {
- new DeployerCompositeArtifactDependencyDeterminer(null);
+ new DeployerCompositeArtifactDependencyDeterminer(null, region1, region2);
+ }
+
+ @Test(expected = FatalAssertionException.class)
+ public void nullUserRegion() {
+ new DeployerCompositeArtifactDependencyDeterminer(artifactRepository, null, region2);
+ }
+
+ @Test(expected = FatalAssertionException.class)
+ public void nullGlobalRegion() {
+ new DeployerCompositeArtifactDependencyDeterminer(artifactRepository, region1, null);
}
@Test
@@ -58,7 +73,7 @@ public class DeployerCompositeArtifactDependencyDeterminerTests {
public void success() {
StubPlanInstallArtifact installArtifact = new StubPlanInstallArtifact();
installArtifact.getTree().addChild(new ThreadSafeArrayListTree<InstallArtifact>(new StubInstallArtifact()));
- DeployerCompositeArtifact artifact = new DeployerCompositeArtifact(bundleContext, installArtifact);
+ DeployerCompositeArtifact artifact = new DeployerCompositeArtifact(bundleContext, installArtifact, region1);
assertEquals(1, this.determiner.getDependents(artifact).size());
}
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifactTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifactTests.java
index 8ddade64..93e9d0ce 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifactTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifactTests.java
@@ -17,6 +17,7 @@ import static org.junit.Assert.assertNotNull;
import org.junit.Test;
+import org.eclipse.virgo.kernel.model.StubRegion;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
import org.eclipse.virgo.kernel.model.internal.deployer.DeployerArtifact;
import org.eclipse.virgo.kernel.model.internal.deployer.DeployerCompositeArtifact;
@@ -33,16 +34,23 @@ public class DeployerCompositeArtifactTests {
bundleContext.addFilter(filterString, new TrueFilter(filterString));
}
- private final DeployerCompositeArtifact artifact = new DeployerCompositeArtifact(bundleContext, new StubPlanInstallArtifact());
+ private final StubRegion region = new StubRegion("test-region");
+
+ private final DeployerCompositeArtifact artifact = new DeployerCompositeArtifact(bundleContext, new StubPlanInstallArtifact(), region);
@Test(expected = FatalAssertionException.class)
public void testNullBundleContext() {
- new DeployerArtifact(null, new StubPlanInstallArtifact());
+ new DeployerArtifact(null, new StubPlanInstallArtifact(), region);
}
@Test(expected = FatalAssertionException.class)
public void testNullInstallArtifact() {
- new DeployerArtifact(this.bundleContext, null);
+ new DeployerArtifact(this.bundleContext, null, region);
+ }
+
+ @Test(expected = FatalAssertionException.class)
+ public void testRegion() {
+ new DeployerArtifact(this.bundleContext, new StubPlanInstallArtifact(), null);
}
@Test
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 56db866c..6d11a830 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
@@ -24,6 +24,7 @@ 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.StubRegion;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
import org.eclipse.virgo.kernel.serviceability.Assert.FatalAssertionException;
import org.eclipse.virgo.kernel.stubs.StubInstallArtifact;
@@ -50,23 +51,29 @@ public class ModelInstallArtifactLifecycleListenerInitializerTests {
String filterString2 = String.format("(&(objectClass=%s)(artifactType=plan))", DependencyDeterminer.class.getCanonicalName());
this.bundleContext.addFilter(filterString2, new TrueFilter(filterString2));
}
+
+ private final StubRegion region = new StubRegion("test-region");
- private final ModelInstallArtifactLifecycleListenerInitializer initializer = new ModelInstallArtifactLifecycleListenerInitializer(
- artifactRepository, bundleContext, runtimeArtifactModel, regionDigraph);
+ private final ModelInstallArtifactLifecycleListenerInitializer initializer = new ModelInstallArtifactLifecycleListenerInitializer(artifactRepository, bundleContext, runtimeArtifactModel, regionDigraph, region);
@Test(expected = FatalAssertionException.class)
public void nullArtifactRepository() {
- new ModelInstallArtifactLifecycleListenerInitializer(null, bundleContext, runtimeArtifactModel, regionDigraph);
+ new ModelInstallArtifactLifecycleListenerInitializer(null, bundleContext, runtimeArtifactModel, regionDigraph, region);
}
@Test(expected = FatalAssertionException.class)
public void nullBundleContext() {
- new ModelInstallArtifactLifecycleListenerInitializer(artifactRepository, null, runtimeArtifactModel, regionDigraph);
+ new ModelInstallArtifactLifecycleListenerInitializer(artifactRepository, null, runtimeArtifactModel, regionDigraph, region);
}
@Test(expected = FatalAssertionException.class)
public void nullRegionDigraph() {
- new ModelInstallArtifactLifecycleListenerInitializer(artifactRepository, bundleContext, runtimeArtifactModel, null);
+ new ModelInstallArtifactLifecycleListenerInitializer(artifactRepository, bundleContext, runtimeArtifactModel, null, region);
+ }
+
+ @Test(expected = FatalAssertionException.class)
+ public void nullRegion() {
+ new ModelInstallArtifactLifecycleListenerInitializer(artifactRepository, bundleContext, runtimeArtifactModel, regionDigraph, null);
}
@Test
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 b7dda74c..8f016b8d 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
@@ -18,6 +18,7 @@ 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.StubRegion;
import org.eclipse.virgo.kernel.model.internal.DependencyDeterminer;
import org.eclipse.virgo.kernel.serviceability.Assert.FatalAssertionException;
import org.eclipse.virgo.kernel.stubs.StubInstallArtifact;
@@ -40,22 +41,29 @@ public class ModelInstallArtifactLifecycleListenerTests {
String filterString2 = String.format("(&(objectClass=%s)(artifactType=plan))", DependencyDeterminer.class.getCanonicalName());
this.bundleContext.addFilter(filterString2, new TrueFilter(filterString2));
}
+
+ private final StubRegion region = new StubRegion("test-region");
- private final ModelInstallArtifactLifecycleListener listener = new ModelInstallArtifactLifecycleListener(bundleContext, artifactRepository, regionDigraph);
+ private final ModelInstallArtifactLifecycleListener listener = new ModelInstallArtifactLifecycleListener(bundleContext, artifactRepository, regionDigraph, region);
@Test(expected = FatalAssertionException.class)
public void nullBundleContext() {
- new ModelInstallArtifactLifecycleListener(null, artifactRepository, regionDigraph);
+ new ModelInstallArtifactLifecycleListener(null, artifactRepository, regionDigraph, region);
}
@Test(expected = FatalAssertionException.class)
public void nullArtifactRepository() {
- new ModelInstallArtifactLifecycleListener(bundleContext, null, regionDigraph);
+ new ModelInstallArtifactLifecycleListener(bundleContext, null, regionDigraph, region);
}
@Test(expected = FatalAssertionException.class)
public void nullRegionDigraph() {
- new ModelInstallArtifactLifecycleListener(bundleContext, artifactRepository, null);
+ new ModelInstallArtifactLifecycleListener(bundleContext, artifactRepository, null, region);
+ }
+
+ @Test(expected = FatalAssertionException.class)
+ public void nullRegion() {
+ new ModelInstallArtifactLifecycleListener(bundleContext, artifactRepository, regionDigraph, null);
}
@Test
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DefaultArtifactObjectNameCreatorTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DefaultArtifactObjectNameCreatorTests.java
index f3aac773..479b30c7 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DefaultArtifactObjectNameCreatorTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DefaultArtifactObjectNameCreatorTests.java
@@ -35,6 +35,6 @@ public class DefaultArtifactObjectNameCreatorTests {
public void success() {
ObjectName objectName = creator.create(new StubCompositeArtifact());
assertNotNull(objectName);
- assertEquals("test-domain:artifact-type=test-type,name=test-name,type=Model,version=0.0.0", objectName.getCanonicalName());
+ assertEquals("test-domain:artifact-type=test-type,name=test-name,region=test-region,type=KernelModel,version=0.0.0", objectName.getCanonicalName());
}
}
diff --git a/org.eclipse.virgo.kernel.osgi/.classpath b/org.eclipse.virgo.kernel.osgi/.classpath
index 45763da3..0c0a67c1 100644
--- a/org.eclipse.virgo.kernel.osgi/.classpath
+++ b/org.eclipse.virgo.kernel.osgi/.classpath
@@ -45,5 +45,6 @@
<classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.virgo.osgi/org.eclipse.virgo.osgi.launcher/3.0.0.M04/org.eclipse.virgo.osgi.launcher-3.0.0.M04.jar" sourcepath="/KERNEL_IVY_CACHE/org.eclipse.virgo.osgi/org.eclipse.virgo.osgi.launcher/3.0.0.M04/org.eclipse.virgo.osgi.launcher-sources-3.0.0.M04.jar"/>
<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.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/GlobalRegion.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/GlobalRegion.java
new file mode 100644
index 00000000..3cd46e2d
--- /dev/null
+++ b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/GlobalRegion.java
@@ -0,0 +1,203 @@
+/*******************************************************************************
+ * 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;
+
+import java.io.InputStream;
+import java.util.HashSet;
+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.serviceability.NonNull;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Version;
+
+/**
+ * {@link GlobalRegion} is an implementation of {@link Region} which acts as a place holder for all artifacts that are not bundles
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * Thread safe.
+ */
+final class GlobalRegion implements Region {
+
+ private final String regionName;
+
+ private static final String UNSUPPORTED_OPERATION_MESSAGE = "Bundle operations are not support on the Independent Region";
+
+
+ public GlobalRegion(String regionName) {
+ this.regionName = regionName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getName() {
+ return regionName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addBundle(Bundle bundle) throws BundleException {
+ throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_MESSAGE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addBundle(long bundleId) {
+ throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_MESSAGE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Bundle installBundle(String location, InputStream input) throws BundleException {
+ throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_MESSAGE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Bundle installBundle(String location) throws BundleException {
+ throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_MESSAGE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Bundle getBundle(@NonNull String symbolicName, @NonNull Version version) {
+ throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_MESSAGE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void connectRegion(Region headRegion, RegionFilter filter) throws BundleException {
+ throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_MESSAGE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public RegionDigraph getRegionDigraph(){
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean contains(Bundle bundle) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean contains(long bundleId) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void removeBundle(Bundle bundle) {
+ //no-op
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void removeBundle(long bundleId) {
+ //no-op
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Set<Long> getBundleIds() {
+ return new HashSet<Long>();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Set<FilteredRegion> getEdges() {
+ return new HashSet<RegionDigraph.FilteredRegion>();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void visitSubgraph(RegionDigraphVisitor visitor) {
+ //no-op
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return getName();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + regionName.hashCode();
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (!(obj instanceof GlobalRegion)) {
+ return false;
+ }
+ GlobalRegion other = (GlobalRegion) obj;
+ return this.regionName.equals(other.regionName);
+ }
+
+}
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
new file mode 100644
index 00000000..226c564b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.osgi/src/main/resources/META-INF/spring/osgi-framework-context.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:osgi="http://www.springframework.org/schema/osgi"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd">
+
+ <osgi:service ref="globalRegion" interface="org.eclipse.equinox.region.Region" >
+ <osgi:service-properties>
+ <entry key="org.eclipse.virgo.kernel.region.name" value="global"/>
+ </osgi:service-properties>
+ </osgi:service>
+
+ <bean id="globalRegion" class="org.eclipse.virgo.kernel.osgi.region.GlobalRegion">
+ <constructor-arg name="regionName" value="global" />
+ </bean>
+
+</beans>
diff --git a/org.eclipse.virgo.kernel.osgi/template.mf b/org.eclipse.virgo.kernel.osgi/template.mf
index e08ad360..bd108454 100644
--- a/org.eclipse.virgo.kernel.osgi/template.mf
+++ b/org.eclipse.virgo.kernel.osgi/template.mf
@@ -17,6 +17,7 @@ Import-Template:
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.shutdown/src/test/java/.gitignore b/org.eclipse.virgo.kernel.shutdown/src/main/resources/.gitignore
index e69de29b..e69de29b 100644
--- a/org.eclipse.virgo.kernel.shutdown/src/test/java/.gitignore
+++ b/org.eclipse.virgo.kernel.shutdown/src/main/resources/.gitignore
diff --git a/org.eclipse.virgo.kernel.shutdown/src/test/resources/.gitignore b/org.eclipse.virgo.kernel.shutdown/src/test/resources/.gitignore
deleted file mode 100644
index e69de29b..00000000
--- a/org.eclipse.virgo.kernel.shutdown/src/test/resources/.gitignore
+++ /dev/null
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 70a569f8..12e388be 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
@@ -82,7 +82,7 @@ serviceExports =\
org.eclipse.virgo.kernel.osgi.framework.OsgiFramework,\
org.eclipse.virgo.kernel.osgi.framework.ImportExpander,\
org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil,\
- org.eclipse.virgo.kernel.osgi.region.Region,\
+ org.eclipse.equinox.region.Region,\
org.osgi.service.event.EventHandler,\
org.osgi.service.cm.ConfigurationListener,\
org.osgi.service.cm.ManagedService,\
diff --git a/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoaderTests.java b/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoaderTests.java
index e871c0b4..c6fcffb3 100644
--- a/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoaderTests.java
+++ b/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoaderTests.java
@@ -43,7 +43,6 @@ public class KernelBundleClassLoaderTests extends AbstractOsgiFrameworkLaunching
* @throws UnableToSatisfyDependenciesException
* @throws Exception
*/
- @SuppressWarnings("unchecked")
@Test
public void testGetResourcesStringFromBundle() throws Exception {
Enumeration<URL> resources = this.dependant.getResources("/META-INF/GET_ME");
diff --git a/org.eclipse.virgo.kernel.userregionfactory/src/main/java/.gitignore b/org.eclipse.virgo.kernel.userregionfactory/src/main/java/.gitignore
deleted file mode 100644
index e69de29b..00000000
--- a/org.eclipse.virgo.kernel.userregionfactory/src/main/java/.gitignore
+++ /dev/null
diff --git a/org.eclipse.virgo.kernel.userregionfactory/src/main/resources/.gitignore b/org.eclipse.virgo.kernel.userregionfactory/src/main/resources/.gitignore
deleted file mode 100644
index e69de29b..00000000
--- a/org.eclipse.virgo.kernel.userregionfactory/src/main/resources/.gitignore
+++ /dev/null
diff --git a/org.eclipse.virgo.kernel.userregionfactory/src/test/java/.gitignore b/org.eclipse.virgo.kernel.userregionfactory/src/test/java/.gitignore
deleted file mode 100644
index e69de29b..00000000
--- a/org.eclipse.virgo.kernel.userregionfactory/src/test/java/.gitignore
+++ /dev/null

Back to the top