Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Frost2011-04-28 09:06:12 +0000
committerChristopher Frost2011-04-28 09:06:12 +0000
commit032e769d3da3061535ba1061b2ffcd09444a69c7 (patch)
treea001696e8d1601bc4cc681897247ee2e3a564cf4
parentff472db97420fac46dd3e03c039df28d531a1f23 (diff)
downloadorg.eclipse.virgo.kernel-032e769d3da3061535ba1061b2ffcd09444a69c7.tar.gz
org.eclipse.virgo.kernel-032e769d3da3061535ba1061b2ffcd09444a69c7.tar.xz
org.eclipse.virgo.kernel-032e769d3da3061535ba1061b2ffcd09444a69c7.zip
Initial changes complete but some tests are still failing at this stage
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/NestedPlanIntegrationTests.java19
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMDeploymentIntegrationTests.java18
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/test.config.properties2
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PipelinedApplicationDeployer.java3
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/AbstractInstallArtifact.java3
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/RuntimeArtifactRepository.java11
-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.java37
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminer.java26
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListener.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ModelConfigurationListener.java4
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerCompositeArtifactDependencyDeterminer.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListener.java12
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListenerInitializer.java4
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/module-context.xml1
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubArtifactRepository.java17
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/NotifyingArtifactRepositoryTests.java6
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java14
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraph.java3
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/StateService.java8
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateService.java7
-rw-r--r--org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/stubs/StubStateService.java11
22 files changed, 150 insertions, 62 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 6e64d014..adc47350 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/NestedPlanIntegrationTests.java
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/NestedPlanIntegrationTests.java
@@ -29,6 +29,8 @@ import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.ArtifactState;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
+import org.eclipse.virgo.kernel.osgi.region.Region;
+import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -59,6 +61,8 @@ import org.osgi.service.packageadmin.ExportedPackage;
@SuppressWarnings("deprecation")
public class NestedPlanIntegrationTests extends AbstractDeployerIntegrationTest {
+ private static final String REGION_USER = "org.eclipse.virgo.region.user";
+
private static final String GLOBAL_PACKAGE = "global";
private static final String PARENT_PACKAGE_NAME = "parent";
@@ -110,6 +114,10 @@ public class NestedPlanIntegrationTests extends AbstractDeployerIntegrationTest
private DeploymentIdentity globalBundleDeploymentIdentity;
+ private ServiceReference<RegionDigraph> regionDigraphReference;
+
+ private RegionDigraph regionDigraph;
+
@BeforeClass
public static void setUpClass() throws Exception {
File generatedPlanDirectory = new File(GENERATED_PLAN_DIRECTORY);
@@ -125,6 +133,9 @@ public class NestedPlanIntegrationTests extends AbstractDeployerIntegrationTest
this.ram = context.getService(serviceReference);
}
+ this.regionDigraphReference = this.kernelContext.getServiceReference(RegionDigraph.class);
+ this.regionDigraph = this.kernelContext.getService(regionDigraphReference);
+
globalBundleDeploymentIdentity = deploy(GLOBAL_BUNDLE_INFO);
}
@@ -363,7 +374,7 @@ public class NestedPlanIntegrationTests extends AbstractDeployerIntegrationTest
Artifact childArtifact;
if (parent.isScoped()) {
- childArtifact = getPlan(childPlan.getType(), model.getScopeName() + SCOPE_SEPARATOR + childPlan.getName(), childPlan.getVersion());
+ childArtifact = getPlan(childPlan.getType(), model.getScopeName() + SCOPE_SEPARATOR + childPlan.getName(), childPlan.getVersion(), this.regionDigraph.getRegion(REGION_USER));
} else {
childArtifact = getPlan(childPlan);
}
@@ -382,11 +393,11 @@ public class NestedPlanIntegrationTests extends AbstractDeployerIntegrationTest
}
private Artifact getPlan(TestPlanArtifactInfo plan) {
- return getPlan(plan.getType(), plan.getName(), plan.getVersion());
+ return getPlan(plan.getType(), plan.getName(), plan.getVersion(), this.regionDigraph.getRegion(REGION_USER));
}
- private Artifact getPlan(String type, String name, Version version) {
- Artifact planArtifact = this.ram.getArtifact(type, name, version);
+ private Artifact getPlan(String type, String name, Version version, Region region) {
+ Artifact planArtifact = this.ram.getArtifact(type, name, version, region);
assertNotNull(planArtifact);
return planArtifact;
}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMDeploymentIntegrationTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMDeploymentIntegrationTests.java
index 27f14e06..6cda3a87 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMDeploymentIntegrationTests.java
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMDeploymentIntegrationTests.java
@@ -27,6 +27,7 @@ import org.osgi.framework.Version;
import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListener;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
+import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
/**
* Test the interactions between the Runtime Artifact Model (RAM) and the deployer.
@@ -34,6 +35,8 @@ import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
*/
public class RAMDeploymentIntegrationTests extends AbstractDeployerIntegrationTest {
+ private static final String REGION_USER = "org.eclipse.virgo.region.user";
+
private StubInstallArtifactLifecycleListener lifecycleListener;
private ServiceRegistration<InstallArtifactLifecycleListener> lifecycleListenerRegistration;
@@ -41,9 +44,13 @@ public class RAMDeploymentIntegrationTests extends AbstractDeployerIntegrationTe
private DeploymentIdentity deploymentIdentity;
private ServiceReference<RuntimeArtifactRepository> ramReference;
-
+
private RuntimeArtifactRepository ram;
+ private ServiceReference<RegionDigraph> regionDigraphReference;
+
+ private RegionDigraph regionDigraph;
+
@Before
public void setUp() throws Exception {
this.lifecycleListener = new StubInstallArtifactLifecycleListener();
@@ -51,6 +58,9 @@ public class RAMDeploymentIntegrationTests extends AbstractDeployerIntegrationTe
this.ramReference = this.kernelContext.getServiceReference(RuntimeArtifactRepository.class);
this.ram = this.kernelContext.getService(ramReference);
+
+ this.regionDigraphReference = this.kernelContext.getServiceReference(RegionDigraph.class);
+ this.regionDigraph = this.kernelContext.getService(regionDigraphReference);
}
@After
@@ -71,8 +81,7 @@ public class RAMDeploymentIntegrationTests extends AbstractDeployerIntegrationTe
this.lifecycleListener.assertLifecycleCounts(0, 0, 0, 0);
this.deploymentIdentity = this.deployer.deploy(file.toURI());
this.lifecycleListener.assertLifecycleCounts(1, 1, 0, 0);
- Artifact artifact = this.ram.getArtifact(this.deploymentIdentity.getType(), this.deploymentIdentity.getSymbolicName(), new Version(
- this.deploymentIdentity.getVersion()));
+ Artifact artifact = this.ram.getArtifact(this.deploymentIdentity.getType(), this.deploymentIdentity.getSymbolicName(), new Version(this.deploymentIdentity.getVersion()), this.regionDigraph.getRegion(REGION_USER));
assertNotNull(artifact);
artifact.uninstall();
this.lifecycleListener.assertLifecycleCounts(1, 1, 1, 1);
@@ -82,8 +91,7 @@ public class RAMDeploymentIntegrationTests extends AbstractDeployerIntegrationTe
public void testRAMUndeploymentFollowedByDeployerUndeployment() throws Exception {
File file = new File("src/test/resources/dummy.jar");
this.deploymentIdentity = this.deployer.deploy(file.toURI());
- Artifact artifact = this.ram.getArtifact(this.deploymentIdentity.getType(), this.deploymentIdentity.getSymbolicName(), new Version(
- this.deploymentIdentity.getVersion()));
+ Artifact artifact = this.ram.getArtifact(this.deploymentIdentity.getType(), this.deploymentIdentity.getSymbolicName(), new Version(this.deploymentIdentity.getVersion()), this.regionDigraph.getRegion(REGION_USER));
artifact.uninstall();
// The following deployer operation should throw DeploymentException.
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/test.config.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/test.config.properties
index b2182b1d..ce6a4d07 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/test.config.properties
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/test.config.properties
@@ -49,7 +49,7 @@ osgi.clean=true
osgi.configuration.area=target
org.osgi.framework.bsnversion=multiple
-#osgi.console=2401
+# osgi.console=2401
org.apache.felix.eventadmin.Timeout=0
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PipelinedApplicationDeployer.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PipelinedApplicationDeployer.java
index d9edd42c..1c05579e 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PipelinedApplicationDeployer.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PipelinedApplicationDeployer.java
@@ -543,8 +543,7 @@ final class PipelinedApplicationDeployer implements ApplicationDeployer, Applica
String symbolicName = deploymentIdentity.getSymbolicName();
String version = deploymentIdentity.getVersion();
this.eventLogger.log(DeployerLogEvents.UNDEPLOY_ARTEFACT_NOT_FOUND, type, symbolicName, version);
- throw new DeploymentException("Undeploy not possible as no " + type + " with name " + symbolicName + " and version " + version
- + " is deployed");
+ throw new DeploymentException("Undeploy not possible as no " + type + " with name " + symbolicName + " and version " + version + " is deployed");
} else {
URI location = this.ram.getLocation(deploymentIdentity);
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/AbstractInstallArtifact.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/AbstractInstallArtifact.java
index ffd7c9c1..0754d710 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/AbstractInstallArtifact.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/AbstractInstallArtifact.java
@@ -350,8 +350,7 @@ public abstract class AbstractInstallArtifact implements InstallArtifact {
* {@inheritDoc}
*/
public void uninstall() throws DeploymentException {
- if (getState().equals(State.STARTING) || getState().equals(State.ACTIVE) || getState().equals(State.RESOLVED)
- || getState().equals(State.INSTALLED)) {
+ if (getState().equals(State.STARTING) || getState().equals(State.ACTIVE) || getState().equals(State.RESOLVED) || getState().equals(State.INSTALLED)) {
pushThreadContext();
try {
if (getState().equals(State.ACTIVE) || getState().equals(State.STARTING)) {
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/RuntimeArtifactRepository.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/RuntimeArtifactRepository.java
index 0f68bd44..fc74ea46 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/RuntimeArtifactRepository.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/RuntimeArtifactRepository.java
@@ -13,15 +13,12 @@ package org.eclipse.virgo.kernel.model;
import java.util.Set;
+import org.eclipse.virgo.kernel.osgi.region.Region;
import org.osgi.framework.Version;
/**
* A single in-memory repository with representations of all artifacts in the running system. Operations are generally
* executed against the artifacts themselves rather than the repository.
- * <p />
- * Bundle artifacts may reside in a number of {@link Region Regions}, but certain repository operations such as remove
- * and get operate only on bundle artifacts in the user region. This is to preserve backward compatibility with Virgo
- * 2.1.0 for the RuntimeArtifactRepository interface (and for JMX).
*
* <strong>Concurrent Semantics</strong><br />
*
@@ -46,9 +43,10 @@ public interface RuntimeArtifactRepository {
* @param type The type of the {@link Artifact} to remove
* @param name The name of the {@link Artifact} to remove
* @param version The {@link Version} of the {@link Artifact} to remove
+ * @param region The {@link Region} to remove the {@link Artifact} from
* @return <code>true</code> if this repository contained the specified {@link Artifact}
*/
- boolean remove(String type, String name, Version version);
+ boolean remove(String type, String name, Version version, Region region);
/**
* Returns the entire collection of {@link Artifact}s contained within this repository. The returned collection
@@ -66,8 +64,9 @@ public interface RuntimeArtifactRepository {
* @param type The type of the {@link Artifact} to get
* @param name The name of the {@link Artifact} to get
* @param version The {@link Version} of the {@link Artifact} to get
+ * @param region The {@link Region} to get the {@link Artifact} from
* @return The {@link Artifact} represented by this type, name, and version if it is in the repository, otherwise
* <code>null</code>
*/
- Artifact getArtifact(String type, String name, Version version);
+ Artifact getArtifact(String type, String name, Version version, Region region);
}
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 1e0f12f8..aa0b76da 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
@@ -52,7 +52,7 @@ public abstract class AbstractArtifact implements Artifact {
private final Version version;
- private final ServiceTracker dependencyDeterminerTracker;
+ private final ServiceTracker<DependencyDeterminer, DependencyDeterminer> dependencyDeterminerTracker;
private final Region region;
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 63665a2c..fdc43f6d 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,6 +35,8 @@ 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());
@@ -70,9 +72,9 @@ public final class NotifyingRuntimeArtifactRepository implements RuntimeArtifact
/**
* {@inheritDoc}
*/
- public boolean remove(String type, String name, Version version) {
+ public boolean remove(String type, String name, Version version, Region region) {
synchronized (this.monitor) {
- Artifact artifact = getArtifact(type, name, version);
+ Artifact artifact = getArtifact(type, name, version, region);
boolean result = this.artifacts.remove(artifact);
if (result) {
for (ArtifactRepositoryListener listener : listeners) {
@@ -99,18 +101,35 @@ public final class NotifyingRuntimeArtifactRepository implements RuntimeArtifact
/**
* {@inheritDoc}
*/
- public Artifact getArtifact(String type, String name, Version version) {
+ public Artifact getArtifact(String type, String name, Version version, Region region) {
synchronized (this.monitor) {
+ Artifact fallBack = null;
for (Artifact artifact : this.artifacts) {
- // Skip kernel artifacts.
- Region region = artifact.getRegion();
- if (region == null || !region.contains(0L)) {
- if (artifact.getType().equals(type) && artifact.getName().equals(name) && artifact.getVersion().equals(version)) {
- return artifact;
+ 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;
+ }
}
}
}
- return null;
+ return fallBack;
}
}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminer.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminer.java
index be497ca1..8a3c7a89 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminer.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminer.java
@@ -23,6 +23,7 @@ import org.eclipse.virgo.kernel.osgi.quasi.QuasiExportPackage;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiFramework;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiFrameworkFactory;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiImportPackage;
+import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
import org.eclipse.virgo.kernel.serviceability.NonNull;
/**
@@ -41,9 +42,12 @@ public final class BundleDependencyDeterminer implements DependencyDeterminer {
private final RuntimeArtifactRepository artifactRepository;
- public BundleDependencyDeterminer(@NonNull QuasiFrameworkFactory quasiFrameworkFactory, @NonNull RuntimeArtifactRepository artifactRepository) {
+ private final RegionDigraph regionDigraph;
+
+ public BundleDependencyDeterminer(@NonNull QuasiFrameworkFactory quasiFrameworkFactory, @NonNull RuntimeArtifactRepository artifactRepository, @NonNull RegionDigraph regionDigraph) {
this.quasiFrameworkFactory = quasiFrameworkFactory;
this.artifactRepository = artifactRepository;
+ this.regionDigraph = regionDigraph;
}
/**
@@ -61,16 +65,16 @@ public final class BundleDependencyDeterminer implements DependencyDeterminer {
QuasiExportPackage provider = importPackage.getProvider();
if (provider != null) {
QuasiBundle bundle = provider.getExportingBundle();
- Artifact artifact = artifactRepository.getArtifact(BundleArtifact.TYPE, bundle.getSymbolicName(), bundle.getVersion());
- if (artifact == null) {
- // If there is no matching artifact in the user region, try the kernel region.
- for (Artifact a : this.artifactRepository.getArtifacts()) {
- if (BundleArtifact.TYPE.equals(a.getType()) && bundle.getSymbolicName().equals(a.getName()) && bundle.getVersion().equals(a.getVersion())) {
- artifact = a;
- break;
- }
- }
- }
+ Artifact artifact = artifactRepository.getArtifact(BundleArtifact.TYPE, bundle.getSymbolicName(), bundle.getVersion(), this.regionDigraph.getRegion(bundle.getBundleId()));
+// if (artifact == null) {
+// // If there is no matching artifact in the user region, try the kernel region.
+// for (Artifact a : this.artifactRepository.getArtifacts()) {
+// if (BundleArtifact.TYPE.equals(a.getType()) && bundle.getSymbolicName().equals(a.getName()) && bundle.getVersion().equals(a.getVersion())) {
+// artifact = a;
+// break;
+// }
+// }
+// }
artifacts.add(artifact);
}
}
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 38acc1f4..8c3cd8c3 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
@@ -78,7 +78,7 @@ final class ModelBundleListener implements SynchronousBundleListener {
private void processUninstalled(BundleEvent event) {
Bundle bundle = event.getBundle();
logger.info("Processing uninstalled event for '{}:{}'", bundle.getSymbolicName(), bundle.getVersion().toString());
- this.artifactRepository.remove(BundleArtifact.TYPE, bundle.getSymbolicName(), bundle.getVersion());
+ this.artifactRepository.remove(BundleArtifact.TYPE, bundle.getSymbolicName(), bundle.getVersion(), this.regionDigraph.getRegion(bundle));
}
}
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 58ceb547..34612f34 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
@@ -70,9 +70,9 @@ 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);
+ Artifact artifact = this.artifactRepository.getArtifact(ConfigurationArtifact.TYPE, event.getPid(), Version.emptyVersion, null);
if (artifact instanceof ConfigurationArtifact) {
- this.artifactRepository.remove(ConfigurationArtifact.TYPE, event.getPid(), Version.emptyVersion);
+ this.artifactRepository.remove(ConfigurationArtifact.TYPE, event.getPid(), Version.emptyVersion, null);
}
}
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 fab5009c..c4bd7ece 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
@@ -54,7 +54,7 @@ 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()));
+ dependents.add(artifactRepository.getArtifact(artifact.getType(), artifact.getName(), artifact.getVersion(), rootArtifact.getRegion()));
}
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 193faf2d..7d1e43e1 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
@@ -82,12 +82,10 @@ class ModelInstallArtifactLifecycleListener extends InstallArtifactLifecycleList
}
private void addOrReplaceBundle(BundleInstallArtifact bundleInstallArtifact) {
- Artifact existingBundleArtifact = this.artifactRepository.getArtifact(bundleInstallArtifact.getType(), bundleInstallArtifact.getName(),
- bundleInstallArtifact.getVersion());
+ Artifact existingBundleArtifact = this.artifactRepository.getArtifact(bundleInstallArtifact.getType(), bundleInstallArtifact.getName(), bundleInstallArtifact.getVersion(), this.regionDigraph.getRegion(USER_REGION_NAME));
if (!(existingBundleArtifact instanceof DeployerBundleArtifact)) {
remove(bundleInstallArtifact);
- this.artifactRepository.add(new DeployerBundleArtifact(this.bundleContext, bundleInstallArtifact,
- this.regionDigraph.getRegion(USER_REGION_NAME)));
+ this.artifactRepository.add(new DeployerBundleArtifact(this.bundleContext, bundleInstallArtifact, this.regionDigraph.getRegion(USER_REGION_NAME)));
}
}
@@ -119,7 +117,11 @@ class ModelInstallArtifactLifecycleListener extends InstallArtifactLifecycleList
}
private void remove(InstallArtifact installArtifact) {
- this.artifactRepository.remove(installArtifact.getType(), installArtifact.getName(), installArtifact.getVersion());
+ if(installArtifact instanceof BundleInstallArtifact){
+ this.artifactRepository.remove(installArtifact.getType(), installArtifact.getName(), installArtifact.getVersion(), this.regionDigraph.getRegion(((BundleInstallArtifact) installArtifact).getBundle()));
+ } else {
+ this.artifactRepository.remove(installArtifact.getType(), installArtifact.getName(), installArtifact.getVersion(), null);
+ }
}
}
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 7c69d455..aa830b59 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
@@ -77,12 +77,12 @@ public final class ModelInstallArtifactLifecycleListenerInitializer {
if (installArtifact instanceof PlanInstallArtifact) {
this.artifactRepository.add(new DeployerCompositeArtifact(this.bundleContext, (PlanInstallArtifact) installArtifact));
} else if (installArtifact instanceof BundleInstallArtifact) {
- this.artifactRepository.remove(installArtifact.getType(), installArtifact.getName(), installArtifact.getVersion());
+ this.artifactRepository.remove(installArtifact.getType(), installArtifact.getName(), installArtifact.getVersion(), null);
BundleInstallArtifact bundleInstallArtifact = (BundleInstallArtifact) installArtifact;
this.artifactRepository.add(new DeployerBundleArtifact(this.bundleContext, bundleInstallArtifact,
this.regionDigraph.getRegion(bundleInstallArtifact.getBundle())));
} else {
- this.artifactRepository.remove(installArtifact.getType(), installArtifact.getName(), installArtifact.getVersion());
+ this.artifactRepository.remove(installArtifact.getType(), installArtifact.getName(), installArtifact.getVersion(), null);
this.artifactRepository.add(new DeployerArtifact(this.bundleContext, installArtifact));
}
} catch (Exception e) {
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 99442c5e..1573b417 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
@@ -28,6 +28,7 @@
<bean id="bundleDependencyDeterminer" class="org.eclipse.virgo.kernel.model.internal.bundle.BundleDependencyDeterminer">
<constructor-arg ref="quasiFrameworkFactory"/>
<constructor-arg ref="artifactRepository"/>
+ <constructor-arg ref="regionDigraph"/>
</bean>
<bean id="deployerCompositeArtifactDependencyDeterminer"
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 6ffa70ae..87e0e896 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
@@ -16,6 +16,7 @@ import java.util.Set;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
+import org.eclipse.virgo.kernel.osgi.region.Region;
import org.osgi.framework.Version;
public class StubArtifactRepository implements RuntimeArtifactRepository {
@@ -26,18 +27,26 @@ public class StubArtifactRepository implements RuntimeArtifactRepository {
return this.artifacts.add(artifact);
}
- public boolean remove(String type, String name, Version version) {
- return this.artifacts.remove(getArtifact(type, name, version));
+ public boolean remove(String type, String name, Version version, Region region) {
+ return this.artifacts.remove(getArtifact(type, name, version, region));
}
public Set<Artifact> getArtifacts() {
return this.artifacts;
}
- public Artifact getArtifact(String type, String name, Version version) {
+ 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)) {
- return artifact;
+ if(artifact.getRegion() == null){
+ if(region == null){
+ return artifact;
+ }
+ }else{
+ if(artifact.getRegion().equals(region)){
+ return artifact;
+ }
+ }
}
}
return null;
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 fd2e0208..21e1658b 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
@@ -38,8 +38,8 @@ public class NotifyingArtifactRepositoryTests {
public void remove() {
StubCompositeArtifact artifact = new StubCompositeArtifact();
assertTrue(this.artifactRepository.add(artifact));
- assertTrue(this.artifactRepository.remove(artifact.getType(), artifact.getName(), artifact.getVersion()));
- assertFalse(this.artifactRepository.remove(artifact.getType(), artifact.getName(), artifact.getVersion()));
+ assertTrue(this.artifactRepository.remove(artifact.getType(), artifact.getName(), artifact.getVersion(), artifact.getRegion()));
+ assertFalse(this.artifactRepository.remove(artifact.getType(), artifact.getName(), artifact.getVersion(), artifact.getRegion()));
}
@Test
@@ -49,7 +49,7 @@ public class NotifyingArtifactRepositoryTests {
NotifyingRuntimeArtifactRepository artifactRepository = new NotifyingRuntimeArtifactRepository(listener1, listener2);
StubCompositeArtifact artifact = new StubCompositeArtifact();
artifactRepository.add(artifact);
- artifactRepository.remove(artifact.getType(), artifact.getName(), artifact.getVersion());
+ artifactRepository.remove(artifact.getType(), artifact.getName(), artifact.getVersion(), artifact.getRegion());
assertTrue(listener1.getAdded());
assertTrue(listener2.getAdded());
assertTrue(listener1.getRemoved());
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java
index 164097b9..6f94a9f2 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java
@@ -27,6 +27,7 @@ import org.eclipse.virgo.kernel.model.StubCompositeArtifact;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiBundle;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiFramework;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiFrameworkFactory;
+import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
import org.eclipse.virgo.kernel.serviceability.Assert.FatalAssertionException;
import org.junit.Test;
@@ -36,16 +37,23 @@ public class BundleDependencyDeterminerTests {
private final RuntimeArtifactRepository artifactRepository = new StubArtifactRepository();
- private final BundleDependencyDeterminer determiner = new BundleDependencyDeterminer(quasiFrameworkFactory, artifactRepository);
+ private final RegionDigraph regionDigraph = createMock(RegionDigraph.class);
+
+ private final BundleDependencyDeterminer determiner = new BundleDependencyDeterminer(quasiFrameworkFactory, artifactRepository, regionDigraph);
@Test(expected = FatalAssertionException.class)
public void nullFactory() {
- new BundleDependencyDeterminer(null, artifactRepository);
+ new BundleDependencyDeterminer(null, artifactRepository, regionDigraph);
}
@Test(expected = FatalAssertionException.class)
public void nullRepository() {
- new BundleDependencyDeterminer(quasiFrameworkFactory, null);
+ new BundleDependencyDeterminer(quasiFrameworkFactory, null, regionDigraph);
+ }
+
+ @Test(expected = FatalAssertionException.class)
+ public void nullRegionDigraph() {
+ new BundleDependencyDeterminer(quasiFrameworkFactory, artifactRepository, null);
}
@Test
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraph.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraph.java
index 7049eab5..69f9ef5a 100644
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraph.java
+++ b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraph.java
@@ -189,6 +189,9 @@ public final class StandardRegionDigraph implements RegionDigraph {
*/
@Override
public Region getRegion(Bundle bundle) {
+ if(bundle == null){
+ return null;
+ }
synchronized (this.monitor) {
for (Region region : this) {
if (region.contains(bundle)) {
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/StateService.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/StateService.java
index 87bf8e60..6d18293f 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/StateService.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/StateService.java
@@ -58,6 +58,14 @@ public interface StateService {
public QuasiBundle getBundle(File source, long bundleId);
/**
+ * Lookup the name of a bundles region from the live state.
+ *
+ * @param bundleId
+ * @return the name of the region that this bundle belongs to in the running (live) state.
+ */
+ public String getBundleRegionName(long bundleId);
+
+ /**
* Returns the {@link QuasiLiveService} that represents the service with the requested service Id in the live state
* or the given dump directory. If no such service exists then <code>null</code> is returned.
*
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateService.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateService.java
index 1d4d5cef..92e202dd 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateService.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateService.java
@@ -91,6 +91,13 @@ final public class StandardStateService implements StateService {
/**
* {@inheritDoc}
*/
+ public String getBundleRegionName(long bundleId) {
+ return this.regionDigraph.getRegion(bundleId).getName();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
@Override
public QuasiBundle getBundle(File source, long bundleId) {
return this.getQuasiFramework(source).getBundle(bundleId);
diff --git a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/stubs/StubStateService.java b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/stubs/StubStateService.java
index 5c32c4cc..293ddeda 100644
--- a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/stubs/StubStateService.java
+++ b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/stubs/StubStateService.java
@@ -61,6 +61,17 @@ public class StubStateService implements StateService {
/**
* {@inheritDoc}
*/
+ public String getBundleRegionName(long bundleId) {
+ if (bundleId == stubQuasiBundle.getBundleId()) {
+ return "org.eclipse.virgo.region.user";
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
@Override
public List<QuasiResolutionFailure> getResolverReport(File source, long bundleId) {
return new ArrayList<QuasiResolutionFailure>();

Back to the top