Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2011-03-19 19:15:11 +0000
committerGlyn Normington2011-03-19 19:15:11 +0000
commitbfce058527331aff06b05a6ea26b44ec6ba276cb (patch)
treea970b0c6596055651071960b859ee0ac89d4beb8
parent3694eff6052d8d0f9c63eeb7e081671ba7c65d5e (diff)
downloadorg.eclipse.virgo.kernel-bfce058527331aff06b05a6ea26b44ec6ba276cb.tar.gz
org.eclipse.virgo.kernel-bfce058527331aff06b05a6ea26b44ec6ba276cb.tar.xz
org.eclipse.virgo.kernel-bfce058527331aff06b05a6ea26b44ec6ba276cb.zip
bug 335689: support plans inside PARs
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ParDeploymentTests.java53
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-in-par/ParContainingPlan.parbin0 -> 1634 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ParPlanInstallArtifact.java10
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ParPlanInstallArtifactFactory.java7
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/PlanInstallArtifactTreeFactory.java9
5 files changed, 48 insertions, 31 deletions
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ParDeploymentTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ParDeploymentTests.java
index 078324d5..dd2fce8e 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ParDeploymentTests.java
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ParDeploymentTests.java
@@ -27,38 +27,40 @@ import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.Version;
import org.osgi.service.cm.Configuration;
-
-/**
- */
public class ParDeploymentTests extends AbstractDeployerIntegrationTest {
-
+
private static final File PAR_FILE = new File("src/test/resources/BundlesAndConfig.par");
+
private static final File PAR_FOR_BUG331767 = new File("src/test/resources/bug331767.par");
- private static final File PAR_FOR_BUG330506 = new File("src/test/resources/bug330506.par");
-
+
+ private static final File PAR_FOR_BUG330506 = new File("src/test/resources/bug330506.par");
+
+ private static final File PAR_CONTAINING_PLAN = new File("src/test/resources/plan-in-par/ParContainingPlan.par");
+
private static final String BUNDLE_SYMBOLIC_NAME = "appA-1-bundleA";
+
private static final String BUNDLE_SYMBOLIC_NAME_BUG331767 = "PARbug331767-1-BUNDLEbug331767";
- private static final Version BUNDLE_VERSION = new Version(1,0,0);
+ private static final Version BUNDLE_VERSION = new Version(1, 0, 0);
@Test
public void deployParContainingBundlesAndProperties() throws DeploymentException, IOException, InvalidSyntaxException {
DeploymentIdentity deploymentIdentity = this.deployer.deploy(PAR_FILE.toURI());
-
+
Configuration configuration = getConfiguration("foo");
- assertNotNull(configuration);
+ assertNotNull(configuration);
assertEquals("bar", configuration.getProperties().get("foo"));
-
+
assertBundlePresent(BUNDLE_SYMBOLIC_NAME, BUNDLE_VERSION);
-
+
this.deployer.undeploy(deploymentIdentity);
-
+
configuration = getConfiguration("foo");
assertNull(configuration);
-
+
assertBundleNotPresent(BUNDLE_SYMBOLIC_NAME, BUNDLE_VERSION);
}
-
+
@Test
public void deployParContainingDynamicImportStar() throws DeploymentException {
DeploymentIdentity deploymentIdentity = this.deployer.deploy(PAR_FOR_BUG331767.toURI());
@@ -66,31 +68,38 @@ public class ParDeploymentTests extends AbstractDeployerIntegrationTest {
this.deployer.undeploy(deploymentIdentity);
assertBundleNotPresent(BUNDLE_SYMBOLIC_NAME_BUG331767, BUNDLE_VERSION);
}
-
- @Test(expected=DeploymentException.class)
+
+ @Test(expected = DeploymentException.class)
public void deployParContainingFragmentOfSystemBundle() throws DeploymentException {
this.deployer.deploy(PAR_FOR_BUG330506.toURI());
}
-
+
+ @Test
+ public void deployParContainingPlan() throws DeploymentException {
+ DeploymentIdentity deploymentIdentity = this.deployer.deploy(PAR_CONTAINING_PLAN.toURI());
+ assertBundlePresent("par.with.plan-1-simple.bundle.one", new Version(1, 0, 0, "BUILD-20090326114035"));
+ this.deployer.undeploy(deploymentIdentity);
+ }
+
private void assertBundlePresent(String symbolicName, Version version) {
Bundle[] bundles = this.context.getBundles();
-
+
for (Bundle bundle : bundles) {
if (symbolicName.equals(bundle.getSymbolicName()) && version.equals(bundle.getVersion())) {
return;
}
}
-
+
fail("The bundle " + symbolicName + " " + version + " was not found.");
}
-
+
private void assertBundleNotPresent(String symbolicName, Version version) {
Bundle[] bundles = this.context.getBundles();
-
+
for (Bundle bundle : bundles) {
if (symbolicName.equals(bundle.getSymbolicName()) && version.equals(bundle.getVersion())) {
fail("Bundle " + bundle + " should not be present");
}
}
- }
+ }
}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-in-par/ParContainingPlan.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-in-par/ParContainingPlan.par
new file mode 100644
index 00000000..8241347e
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-in-par/ParContainingPlan.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ParPlanInstallArtifact.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ParPlanInstallArtifact.java
index 0827eccc..db1845a0 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ParPlanInstallArtifact.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ParPlanInstallArtifact.java
@@ -18,7 +18,6 @@ import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import org.eclipse.virgo.kernel.artifact.ArtifactSpecification;
import org.eclipse.virgo.kernel.artifact.fs.ArtifactFS;
import org.eclipse.virgo.kernel.artifact.fs.ArtifactFSEntry;
@@ -66,6 +65,8 @@ final class ParPlanInstallArtifact extends StandardPlanInstallArtifact {
private final List<Tree<InstallArtifact>> childInstallArtifacts;
+ private final InstallArtifactTreeFactory planInstallArtifactTreeFactory;
+
private static final Logger LOGGER = LoggerFactory.getLogger(ParPlanInstallArtifact.class);
public ParPlanInstallArtifact(@NonNull ArtifactIdentity identity, @NonNull ArtifactStorage artifactStorage,
@@ -73,7 +74,8 @@ final class ParPlanInstallArtifact extends StandardPlanInstallArtifact {
@NonNull ScopeFactory scopeFactory, @NonNull EventLogger eventLogger, @NonNull InstallArtifactTreeFactory bundleInstallArtifactTreeFactory,
@NonNull InstallArtifactRefreshHandler refreshHandler, String repositoryName,
@NonNull InstallArtifactTreeFactory configInstallArtifactTreeFactory, @NonNull ArtifactStorageFactory artifactStorageFactory,
- @NonNull ArtifactIdentityDeterminer artifactIdentityDeterminer) throws DeploymentException {
+ @NonNull ArtifactIdentityDeterminer artifactIdentityDeterminer, @NonNull InstallArtifactTreeFactory planInstallArtifactTreeFactory)
+ throws DeploymentException {
super(identity, true, true, artifactStorage, artifactStateMonitor, scopeServiceRepository, scopeFactory, eventLogger, refreshHandler,
repositoryName, EMPTY_ARTIFACT_SPECIFICATION_LIST);
@@ -81,6 +83,7 @@ final class ParPlanInstallArtifact extends StandardPlanInstallArtifact {
this.configInstallArtifactTreeFactory = configInstallArtifactTreeFactory;
this.bundleInstallArtifactTreeFactory = bundleInstallArtifactTreeFactory;
+ this.planInstallArtifactTreeFactory = planInstallArtifactTreeFactory;
this.artifactIdentityDeterminer = artifactIdentityDeterminer;
List<OrderedPair<ArtifactIdentity, ArtifactFSEntry>> childArtifacts = findChildArtifacts(artifactStorage.getArtifactFS());
@@ -133,6 +136,9 @@ final class ParPlanInstallArtifact extends StandardPlanInstallArtifact {
} else if (ArtifactIdentityDeterminer.CONFIGURATION_TYPE.equals(identity.getType())) {
subTree = this.configInstallArtifactTreeFactory.constructInstallArtifactTree(identity, createArtifactStorage(artifactFs, identity),
null, null);
+ } else if (ArtifactIdentityDeterminer.PLAN_TYPE.equals(identity.getType())) {
+ subTree = this.planInstallArtifactTreeFactory.constructInstallArtifactTree(identity, createArtifactStorage(artifactFs, identity),
+ null, null);
}
if (subTree == null) {
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ParPlanInstallArtifactFactory.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ParPlanInstallArtifactFactory.java
index 88ff847e..9e1e465d 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ParPlanInstallArtifactFactory.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ParPlanInstallArtifactFactory.java
@@ -55,10 +55,12 @@ final class ParPlanInstallArtifactFactory {
private final ArtifactIdentityDeterminer artifactIdentityDeterminer;
+ private final InstallArtifactTreeFactory planInstallArtifactTreeFactory;
+
ParPlanInstallArtifactFactory(EventLogger eventLogger, BundleContext bundleContext,
BundleInstallArtifactTreeFactory bundleInstallArtifactTreeFactory, ScopeServiceRepository scopeServiceRepository, ScopeFactory scopeFactory,
InstallArtifactRefreshHandler refreshHandler, ConfigInstallArtifactTreeFactory configInstallArtifactTreeFactory,
- ArtifactStorageFactory artifactStorageFactory, ArtifactIdentityDeterminer artifactIdentityDeterminer) {
+ ArtifactStorageFactory artifactStorageFactory, ArtifactIdentityDeterminer artifactIdentityDeterminer, PlanInstallArtifactTreeFactory planInstallArtifactTreeFactory) {
this.eventLogger = eventLogger;
this.bundleContext = bundleContext;
this.bundleInstallArtifactTreeFactory = bundleInstallArtifactTreeFactory;
@@ -68,12 +70,13 @@ final class ParPlanInstallArtifactFactory {
this.configInstallArtifactTreeFactory = configInstallArtifactTreeFactory;
this.artifactStorageFactory = artifactStorageFactory;
this.artifactIdentityDeterminer = artifactIdentityDeterminer;
+ this.planInstallArtifactTreeFactory = planInstallArtifactTreeFactory;
}
ParPlanInstallArtifact createParPlanInstallArtifact(@NonNull ArtifactIdentity artifactIdentity, @NonNull ArtifactStorage artifactStorage, String repositoryName) throws DeploymentException {
ArtifactStateMonitor artifactStateMonitor = new StandardArtifactStateMonitor(this.bundleContext);
return new ParPlanInstallArtifact(artifactIdentity, artifactStorage, artifactStateMonitor, scopeServiceRepository, scopeFactory, eventLogger,
bundleInstallArtifactTreeFactory, refreshHandler, repositoryName, this.configInstallArtifactTreeFactory,
- this.artifactStorageFactory, this.artifactIdentityDeterminer);
+ this.artifactStorageFactory, this.artifactIdentityDeterminer, this.planInstallArtifactTreeFactory);
}
}
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/PlanInstallArtifactTreeFactory.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/PlanInstallArtifactTreeFactory.java
index d120b1f0..4fd4c968 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/PlanInstallArtifactTreeFactory.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/PlanInstallArtifactTreeFactory.java
@@ -19,7 +19,6 @@ import java.util.Map;
import org.osgi.framework.BundleContext;
-
import org.eclipse.virgo.kernel.artifact.plan.PlanDescriptor;
import org.eclipse.virgo.kernel.artifact.plan.PlanReader;
import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
@@ -73,7 +72,7 @@ final class PlanInstallArtifactTreeFactory implements InstallArtifactTreeFactory
this.refreshHandler = refreshHandler;
this.parFactory = new ParPlanInstallArtifactFactory(eventLogger, bundleContext, bundleInstallArtifactTreeFactory, scopeServiceRepository,
- scopeFactory, refreshHandler, configInstallArtifactTreeFactory, artifactStorageFactory, artifactIdentityDeterminer);
+ scopeFactory, refreshHandler, configInstallArtifactTreeFactory, artifactStorageFactory, artifactIdentityDeterminer, this);
}
/**
@@ -101,7 +100,7 @@ final class PlanInstallArtifactTreeFactory implements InstallArtifactTreeFactory
}
/**
- * @throws DeploymentException
+ * @throws DeploymentException
*/
private PlanDescriptor getPlanDescriptor(ArtifactStorage artifactStorage) throws DeploymentException {
InputStream in = null;
@@ -120,8 +119,8 @@ final class PlanInstallArtifactTreeFactory implements InstallArtifactTreeFactory
StandardPlanInstallArtifact planInstallArtifact;
planInstallArtifact = new StandardPlanInstallArtifact(artifactIdentity, planDescriptor.getAtomic(), planDescriptor.getScoped(),
- artifactStorage, new StandardArtifactStateMonitor(this.bundleContext), this.scopeServiceRepository, this.scopeFactory,
- this.eventLogger, this.refreshHandler, repositoryName, planDescriptor.getArtifactSpecifications());
+ artifactStorage, new StandardArtifactStateMonitor(this.bundleContext), this.scopeServiceRepository, this.scopeFactory, this.eventLogger,
+ this.refreshHandler, repositoryName, planDescriptor.getArtifactSpecifications());
Tree<InstallArtifact> tree = constructInstallTree(planInstallArtifact);
planInstallArtifact.setTree(tree);

Back to the top