Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Frost2011-05-12 05:45:17 -0400
committerChristopher Frost2011-05-12 05:45:17 -0400
commit9d41ff7df0fb48d5d48a2060621bb5293623480c (patch)
tree2907703cc1ef256582c7360893c4501e2ae9c8f1
parent145ff0c85ffd02a3976d442fe6a48c8ea7b616bd (diff)
downloadorg.eclipse.virgo.kernel-9d41ff7df0fb48d5d48a2060621bb5293623480c.tar.gz
org.eclipse.virgo.kernel-9d41ff7df0fb48d5d48a2060621bb5293623480c.tar.xz
org.eclipse.virgo.kernel-9d41ff7df0fb48d5d48a2060621bb5293623480c.zip
Adding Global region implementation and enforcing nonNull region in all places
-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.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.java11
-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.xml4
-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.java146
-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.java78
-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/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/GlobalRegion.java195
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/resources/META-INF/spring/configuration-context.xml6
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/resources/META-INF/spring/osgi-framework-context.xml4
-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
40 files changed, 599 insertions, 209 deletions
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/NestedPlanIntegrationTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/NestedPlanIntegrationTests.java
index 3a10030a..dc7d78c8 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.model/src/main/java/org/eclipse/virgo/kernel/model/internal/AbstractArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/AbstractArtifact.java
index aa0b76da..39872ef4 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 fdc43f6d..e20817ec 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 0bbecaac..05206407 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
@@ -43,7 +43,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 8c3cd8c3..9db00e93 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 8a526236..33176600 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..84abeb92 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.virgo.kernel.osgi.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..b6278027 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.virgo.kernel.osgi.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..40e3da1b 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
@@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
+import org.eclipse.virgo.kernel.osgi.region.Region;
import org.eclipse.virgo.kernel.serviceability.NonNull;
import org.eclipse.virgo.util.osgi.ServiceRegistrationTracker;
@@ -52,11 +53,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 +71,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 ccc4bc87..4cd0ac8b 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 4bf25494..624aa6ae 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
@@ -24,7 +24,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..fae6e9b9 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.virgo.kernel.osgi.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..7738af38 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.virgo.kernel.osgi.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 57cccc7e..c5b917cf 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
@@ -24,6 +24,7 @@ import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListene
import org.eclipse.virgo.kernel.install.artifact.PlanInstallArtifact;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
+import org.eclipse.virgo.kernel.osgi.region.Region;
import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
/**
@@ -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 41b25277..a29f729e 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
@@ -22,6 +22,7 @@ import org.eclipse.virgo.kernel.install.artifact.InstallArtifact;
import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListener;
import org.eclipse.virgo.kernel.install.artifact.PlanInstallArtifact;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
+import org.eclipse.virgo.kernel.osgi.region.Region;
import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
@@ -56,12 +57,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;
}
/**
@@ -70,20 +73,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 d30d1774..cc02e596 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 ARTIFACTS_OF_TYPE_FORMAT = "%s:type=Model,artifact-type=%s,*";
@@ -63,7 +65,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);
@@ -73,8 +75,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 df23f813..8cc25587 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
@@ -42,5 +42,9 @@
<reference id="applicationDeployer" interface="org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer"/>
<reference id="regionDigraph" interface="org.eclipse.virgo.kernel.osgi.region.RegionDigraph" />
+
+ <reference id="globalRegion" interface="org.eclipse.virgo.kernel.osgi.region.Region" filter="(org.eclipse.virgo.kernel.region.name=global)" />
+
+ <reference id="userRegion" interface="org.eclipse.virgo.kernel.osgi.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 87e0e896..cd149fae 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
@@ -37,16 +37,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 b29054a1..ac7c4d5a 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..f3a1fba4
--- /dev/null
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubRegion.java
@@ -0,0 +1,146 @@
+/*
+ * 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.virgo.kernel.osgi.region.Region;
+import org.eclipse.virgo.kernel.osgi.region.RegionDigraphVisitor;
+import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
+import org.eclipse.virgo.kernel.osgi.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 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..b61fb165 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.virgo.kernel.osgi.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 ad82a671..30e09af7 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,14 @@ 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.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.StubCompositeArtifact;
+import org.eclipse.virgo.kernel.model.StubRegion;
import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph.FilteredRegion;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraphVisitor;
-import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Version;
import org.junit.Test;
+import org.osgi.framework.Version;
public class NotifyingArtifactRepositoryTests {
@@ -76,76 +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) {
- }
-
- }
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 59bb20db..8fc304c1 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,11 +12,15 @@
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.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.osgi.region.RegionDigraph;
@@ -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 b77d1b7f..ea69a61c 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
@@ -25,6 +25,7 @@ import org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil;
import org.eclipse.virgo.kernel.osgi.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.model.internal.bundle.ModelBundleListener;
import org.eclipse.virgo.kernel.serviceability.Assert.FatalAssertionException;
@@ -41,12 +42,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 eb380dab..401d8a51 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
@@ -28,6 +28,7 @@ import org.osgi.framework.Version;
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.model.internal.deployer.ModelInstallArtifactLifecycleListenerInitializer;
import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
@@ -53,23 +54,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 af9edca4..f5ec5cdf 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.junit.Test;
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.model.internal.deployer.ModelInstallArtifactLifecycleListener;
import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
@@ -44,22 +45,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/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/GlobalRegion.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/GlobalRegion.java
new file mode 100644
index 00000000..fc5fcf9f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/GlobalRegion.java
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2011 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.osgi.region.internal;
+
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.virgo.kernel.osgi.region.Region;
+import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
+import org.eclipse.virgo.kernel.osgi.region.RegionDigraph.FilteredRegion;
+import org.eclipse.virgo.kernel.osgi.region.RegionDigraphVisitor;
+import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
+import org.eclipse.virgo.kernel.serviceability.NonNull;
+import org.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 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/configuration-context.xml b/org.eclipse.virgo.kernel.osgi/src/main/resources/META-INF/spring/configuration-context.xml
index 17e5153a..1d1512b8 100644
--- a/org.eclipse.virgo.kernel.osgi/src/main/resources/META-INF/spring/configuration-context.xml
+++ b/org.eclipse.virgo.kernel.osgi/src/main/resources/META-INF/spring/configuration-context.xml
@@ -13,4 +13,10 @@
<context:property-placeholder properties-ref="kernelConfig"/>
+ <osgi:service ref="globalRegion" interface="org.eclipse.virgo.kernel.osgi.region.Region" >
+ <osgi:service-properties>
+ <entry key="org.eclipse.virgo.kernel.region.name" value="global"/>
+ </osgi:service-properties>
+ </osgi:service>
+
</beans>
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
index c68c957c..7fcdca76 100644
--- 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
@@ -8,4 +8,8 @@
<constructor-arg type="java.lang.String" value="${domain}"/>
</bean>
+ <bean id="globalRegion" class="org.eclipse.virgo.kernel.osgi.region.internal.GlobalRegion">
+ <constructor-arg name="regionName" value="global" />
+ </bean>
+
</beans>
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