Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2011-11-25 11:03:24 -0500
committerGlyn Normington2011-11-25 11:22:02 -0500
commit92eb5770679a79438ec6f04088718ba0eed8b16a (patch)
tree91a1f5a854136fdfda27f74de57fb7901d37712e
parent4a7ba17a6bcee02230e326dd8a0e1a6efe698426 (diff)
downloadorg.eclipse.virgo.kernel-bug358442-change-install-artifact-graph-to-dag.tar.gz
org.eclipse.virgo.kernel-bug358442-change-install-artifact-graph-to-dag.tar.xz
org.eclipse.virgo.kernel-bug358442-change-install-artifact-graph-to-dag.zip
bug 358442: remove GraphUtils since a deep copy is no longer performed and refactor to address TODOs and common up long-standing duplicated codebug358442-change-install-artifact-graph-to-dag
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/GraphUtils.java64
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PlanResolver.java20
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ParPlanInstallArtifact.java11
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleDriver.java31
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleInstallArtifact.java65
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/pipeline/stage/transform/internal/SyntheticContextBundleCreatingTransformer.java3
6 files changed, 55 insertions, 139 deletions
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/GraphUtils.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/GraphUtils.java
deleted file mode 100644
index 66d447bb..00000000
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/GraphUtils.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2011 VMware Inc. and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution (TreeUtils)
- * EclipseSource - Bug 358442 Change InstallArtifact graph from a tree to a DAG
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.deployer.core.internal;
-
-
-import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
-import org.eclipse.virgo.kernel.install.artifact.InstallArtifact;
-import org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact;
-import org.eclipse.virgo.util.common.GraphNode;
-import org.eclipse.virgo.util.common.GraphNode.ExceptionThrowingDirectedAcyclicGraphVisitor;
-
-/**
- * Helper methods for manipulating {@link GraphNode GraphNode<InstallArtifact>} instances.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- *
- * This class is thread safe.
- *
- */
-// TODO DAG - maybe we do not need this helper class anymore.
-public class GraphUtils {
-
- /**
- * Adds the given child graph as a subgraph of the given parent graph and fixes up the subgraph artifacts to refer to
- * the copies.
- *
- * @param parent to get new child
- * @param child to add to parent
- * @throws DeploymentException not really
- */
- public static void addChild(GraphNode<InstallArtifact> parent, GraphNode<InstallArtifact> child) throws DeploymentException {
- parent.addChild(child);
- setGraphReferences(child);
- }
-
- // TODO DAG - Is this necessary?! We do not copy any more!
- /**
- * The given graph was deeply copied. This method sets the references in each install artifact to its
- * corresponding copied tree.
- */
- private static void setGraphReferences(GraphNode<InstallArtifact> graph) throws DeploymentException {
- graph.visit(new ExceptionThrowingDirectedAcyclicGraphVisitor<InstallArtifact, DeploymentException>() {
- public boolean visit(GraphNode<InstallArtifact> node) throws DeploymentException {
- InstallArtifact value = node.getValue();
- if (value instanceof AbstractInstallArtifact) {
- ((AbstractInstallArtifact)value).setGraph(node);
- }
- return true;
- }
- });
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PlanResolver.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PlanResolver.java
index 0e97195b..e9d8455f 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PlanResolver.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PlanResolver.java
@@ -14,9 +14,6 @@ package org.eclipse.virgo.kernel.deployer.core.internal;
import java.util.List;
-import org.osgi.framework.Version;
-
-
import org.eclipse.virgo.kernel.artifact.ArtifactSpecification;
import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
import org.eclipse.virgo.kernel.install.artifact.InstallArtifact;
@@ -27,6 +24,7 @@ import org.eclipse.virgo.kernel.install.environment.InstallEnvironment;
import org.eclipse.virgo.kernel.install.pipeline.stage.transform.Transformer;
import org.eclipse.virgo.util.common.GraphNode;
import org.eclipse.virgo.util.common.GraphNode.ExceptionThrowingDirectedAcyclicGraphVisitor;
+import org.osgi.framework.Version;
/**
* {@link PlanResolver} adds the immediate child nodes to a plan node.
@@ -68,16 +66,17 @@ public class PlanResolver implements Transformer {
GraphNode<InstallArtifact> graph = planInstallArtifact.getGraph();
List<ArtifactSpecification> artifactSpecifications = planInstallArtifact.getArtifactSpecifications();
for (ArtifactSpecification artifactSpecification : artifactSpecifications) {
- GraphNode<InstallArtifact> childInstallArtifactGraph = createInstallArtifactGraph(artifactSpecification, scopeName);
- GraphUtils.addChild(graph, childInstallArtifactGraph);
-
- // Put child into the INSTALLING state as Transformers (like this) are after the "begin install" pipeline stage.
+ GraphNode<InstallArtifact> childInstallArtifactGraph = createInstallArtifactGraph(artifactSpecification, scopeName);
+ graph.addChild(childInstallArtifactGraph);
+
+ // Put child into the INSTALLING state as Transformers (like this) are after the "begin install"
+ // pipeline stage.
InstallArtifact childInstallArtifact = childInstallArtifactGraph.getValue();
((AbstractInstallArtifact) childInstallArtifact).beginInstall();
}
}
}
- }
+ }
/**
* Returns the scope name of the given {@link InstallArtifact} or <code>null</code> if the given InstallArtifact
@@ -105,7 +104,8 @@ public class PlanResolver implements Transformer {
return result;
}
- private GraphNode<InstallArtifact> createInstallArtifactGraph(ArtifactSpecification artifactSpecification, String scopeName) throws DeploymentException {
+ private GraphNode<InstallArtifact> createInstallArtifactGraph(ArtifactSpecification artifactSpecification, String scopeName)
+ throws DeploymentException {
return this.installArtifactGraphInclosure.createInstallGraph(artifactSpecification, scopeName);
- }
+ }
}
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 3838d065..2306abe3 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
@@ -21,7 +21,6 @@ import org.eclipse.virgo.kernel.artifact.fs.ArtifactFS;
import org.eclipse.virgo.kernel.artifact.fs.ArtifactFSEntry;
import org.eclipse.virgo.kernel.deployer.core.DeployerLogEvents;
import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
-import org.eclipse.virgo.kernel.deployer.core.internal.GraphUtils;
import org.eclipse.virgo.kernel.install.artifact.ArtifactIdentity;
import org.eclipse.virgo.kernel.install.artifact.ArtifactIdentityDeterminer;
import org.eclipse.virgo.kernel.install.artifact.ArtifactStorage;
@@ -131,11 +130,11 @@ final class ParPlanInstallArtifact extends StandardPlanInstallArtifact {
ArtifactFSEntry artifactFs = childArtifact.getSecond();
if (ArtifactIdentityDeterminer.BUNDLE_TYPE.equals(identity.getType())) {
- subGraph = this.bundleInstallArtifactGraphFactory.constructInstallArtifactGraph(identity, createArtifactStorage(artifactFs, identity),
- null, null);
+ subGraph = this.bundleInstallArtifactGraphFactory.constructInstallArtifactGraph(identity,
+ createArtifactStorage(artifactFs, identity), null, null);
} else if (ArtifactIdentityDeterminer.CONFIGURATION_TYPE.equals(identity.getType())) {
- subGraph = this.configInstallArtifactGraphFactory.constructInstallArtifactGraph(identity, createArtifactStorage(artifactFs, identity),
- null, null);
+ subGraph = this.configInstallArtifactGraphFactory.constructInstallArtifactGraph(identity,
+ createArtifactStorage(artifactFs, identity), null, null);
} else if (ArtifactIdentityDeterminer.PLAN_TYPE.equals(identity.getType())) {
subGraph = this.planInstallArtifactGraphFactory.constructInstallArtifactGraph(identity, createArtifactStorage(artifactFs, identity),
null, null);
@@ -179,7 +178,7 @@ final class ParPlanInstallArtifact extends StandardPlanInstallArtifact {
for (GraphNode<InstallArtifact> child : this.childInstallArtifacts) {
// Add any children that are not already present.
if (!isChildPresent(children, child)) {
- GraphUtils.addChild(graph, child);
+ graph.addChild(child);
}
}
}
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleDriver.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleDriver.java
index f417b6a9..92756913 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleDriver.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleDriver.java
@@ -12,8 +12,6 @@
package org.eclipse.virgo.kernel.install.artifact.internal.bundle;
-import java.util.List;
-
import org.eclipse.virgo.kernel.core.AbortableSignal;
import org.eclipse.virgo.kernel.core.BundleStarter;
import org.eclipse.virgo.kernel.core.BundleUtils;
@@ -150,28 +148,17 @@ final class StandardBundleDriver implements BundleDriver {
private Bundle getThreadContextBundle() {
if (this.installArtifact != null) {
- GraphNode<InstallArtifact> tree = this.installArtifact.getGraph();
- // TODO DAG - check usage of getParent
- List<GraphNode<InstallArtifact>> parentList = tree.getParents();
- while (!parentList.isEmpty()) {
- GraphNode<InstallArtifact> parent = parentList.get(0);
- InstallArtifact parentArtifact = parent.getValue();
- if (parentArtifact instanceof PlanInstallArtifact) {
- PlanInstallArtifact parentPlan = (PlanInstallArtifact) (parentArtifact);
- if (parentPlan.isScoped()) {
- String syntheticContextBundleSymbolicName = this.installArtifact.getScopeName() + SYNTHETIC_CONTEXT_SUFFIX;
- for (GraphNode<InstallArtifact> scopedPlanChild : parent.getChildren()) {
- InstallArtifact scopedPlanChildArtifact = scopedPlanChild.getValue();
- if (scopedPlanChildArtifact instanceof BundleInstallArtifact
- && syntheticContextBundleSymbolicName.equals(scopedPlanChildArtifact.getName())) {
- BundleInstallArtifact syntheticContextBundleArtifact = (BundleInstallArtifact) scopedPlanChildArtifact;
- return syntheticContextBundleArtifact.getBundle();
- }
- }
- break;
+ PlanInstallArtifact scopedAncestor = this.installArtifact.getScopedAncestor();
+ if (scopedAncestor != null) {
+ String syntheticContextBundleSymbolicName = this.installArtifact.getScopeName() + SYNTHETIC_CONTEXT_SUFFIX;
+ for (GraphNode<InstallArtifact> scopedPlanChild : scopedAncestor.getGraph().getChildren()) {
+ InstallArtifact scopedPlanChildArtifact = scopedPlanChild.getValue();
+ if (scopedPlanChildArtifact instanceof BundleInstallArtifact
+ && syntheticContextBundleSymbolicName.equals(scopedPlanChildArtifact.getName())) {
+ BundleInstallArtifact syntheticContextBundleArtifact = (BundleInstallArtifact) scopedPlanChildArtifact;
+ return syntheticContextBundleArtifact.getBundle();
}
}
- parentList = parent.getParents();
}
}
return this.bundle;
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleInstallArtifact.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleInstallArtifact.java
index 8aba23f9..e8fb9a45 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleInstallArtifact.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleInstallArtifact.java
@@ -67,12 +67,12 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private static final String MANIFEST_ENTRY_NAME = "/META-INF/MANIFEST.MF";
-
- private static final String EQUINOX_SYSTEM_BUNDLE_NAME = "org.eclipse.osgi";
- private static final String RESERVED_SYSTEM_BUNDLE_NAME = "system.bundle";
+ private static final String EQUINOX_SYSTEM_BUNDLE_NAME = "org.eclipse.osgi";
- private static final long REFRESH_RESTART_WAIT_PERIOD = 60;
+ private static final String RESERVED_SYSTEM_BUNDLE_NAME = "system.bundle";
+
+ private static final long REFRESH_RESTART_WAIT_PERIOD = 60;
private final Object monitor = new Object();
@@ -81,7 +81,7 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
private final BundleDriver bundleDriver;
private final InstallArtifactRefreshHandler refreshHandler;
-
+
private final ArtifactIdentityDeterminer identityDeterminer;
private BundleManifest bundleManifest;
@@ -100,11 +100,12 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
* @param refreshHandler
* @param repositoryName
* @param eventLogger
- * @param identityDeterminer
+ * @param identityDeterminer
*/
public StandardBundleInstallArtifact(@NonNull ArtifactIdentity artifactIdentifier, @NonNull BundleManifest bundleManifest,
@NonNull ArtifactStorage artifactStorage, @NonNull BundleDriver bundleDriver, @NonNull ArtifactStateMonitor artifactStateMonitor,
- @NonNull InstallArtifactRefreshHandler refreshHandler, String repositoryName, EventLogger eventLogger, ArtifactIdentityDeterminer identityDeterminer) {
+ @NonNull InstallArtifactRefreshHandler refreshHandler, String repositoryName, EventLogger eventLogger,
+ ArtifactIdentityDeterminer identityDeterminer) {
super(artifactIdentifier, artifactStorage, artifactStateMonitor, repositoryName, eventLogger);
this.artifactStorage = artifactStorage;
@@ -112,7 +113,7 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
this.bundleDriver = bundleDriver;
this.refreshHandler = refreshHandler;
-
+
this.identityDeterminer = identityDeterminer;
synchronizeBundleSymbolicNameWithIdentity();
@@ -222,7 +223,7 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
public void popThreadContext() {
this.bundleDriver.popThreadContext();
}
-
+
/**
* Track the start of the bundle.
*/
@@ -231,7 +232,7 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
this.bundleDriver.trackStart(signal);
}
- @Override
+ @Override
public void beginInstall() throws DeploymentException {
if (isFragmentOnSystemBundle()) {
throw new DeploymentException("Deploying fragments of the system bundle is not supported");
@@ -370,11 +371,11 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
}
ArtifactIdentity newIdentity = this.identityDeterminer.determineIdentity(this.artifactStorage.getArtifactFS().getFile(), getScopeName());
-
+
if (newIdentity == null) {
throw new DeploymentException("Failed to determine new identity during refresh");
}
-
+
newIdentity = ArtifactIdentityScoper.scopeArtifactIdentity(newIdentity);
if (!isNameAndVersionUnchanged(newIdentity)) {
return false;
@@ -394,7 +395,7 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
if (!refreshScope()) {
synchronized (this.monitor) {
- this.bundleManifest = currentBundleManifest;
+ this.bundleManifest = currentBundleManifest;
}
startIfNecessary(bundleStopped);
return false;
@@ -413,16 +414,16 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
if (!refreshSuccessful) {
synchronized (this.monitor) {
- this.bundleManifest = currentBundleManifest;
+ this.bundleManifest = currentBundleManifest;
}
startIfNecessary(bundleStopped);
}
return refreshSuccessful;
}
-
+
private void startIfNecessary(boolean bundleStopped) throws DeploymentException {
- if (bundleStopped) {
- BlockingAbortableSignal signal = new BlockingAbortableSignal(true);
+ if (bundleStopped) {
+ BlockingAbortableSignal signal = new BlockingAbortableSignal(true);
start(signal);
signal.awaitCompletion(REFRESH_RESTART_WAIT_PERIOD);
}
@@ -434,9 +435,8 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
return newExportedPackageSet.equals(previousExportedPackageSet);
}
- private boolean isNameAndVersionUnchanged(ArtifactIdentity newIdentity) {
- if (newIdentity.getName().equals(getName())
- && newIdentity.getVersion().equals(getVersion())) {
+ private boolean isNameAndVersionUnchanged(ArtifactIdentity newIdentity) {
+ if (newIdentity.getName().equals(getName()) && newIdentity.getVersion().equals(getVersion())) {
return true;
}
@@ -450,38 +450,33 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
// subpipeline.
private boolean refreshScope() {
boolean refreshed;
-
+
PlanInstallArtifact scopedAncestor = getScopedAncestor();
-
+
if (scopedAncestor != null) {
- refreshed = scopedAncestor.refreshScope();
+ refreshed = scopedAncestor.refreshScope();
} else {
refreshed = this.refreshHandler.refresh(this);
}
return refreshed;
}
- private PlanInstallArtifact getScopedAncestor() {
- // TODO DAG: when the Tree is generalised to a DAG, a bundle can belong to at most one scoped ancestor in which case any unscoped
- // ancestors it belongs to must be descendents of the scoped ancestor. So it is sufficient to search one line of ancestors
- // looking for a scope ancestor.
- // TODO DAG - get first parent. See comment above
- // TODO DAG - added isEmpty check due to JUnit error in StandardBundleInstallArtifactTests
- List<GraphNode<InstallArtifact>> ancestors = getGraph().getParents();
-
+ PlanInstallArtifact getScopedAncestor() {
+ // If the bundle belongs to a scoped plan, that plan may be found by searching up any line of ancestors.
+ List<GraphNode<InstallArtifact>> ancestors = getGraph().getParents();
+
while (!ancestors.isEmpty()) {
- GraphNode<InstallArtifact> ancestor = ancestors.get(0);
+ GraphNode<InstallArtifact> ancestor = ancestors.get(0);
InstallArtifact ancestorArtifact = ancestor.getValue();
- PlanInstallArtifact planAncestor = (PlanInstallArtifact)ancestorArtifact;
+ PlanInstallArtifact planAncestor = (PlanInstallArtifact) ancestorArtifact;
if (planAncestor.isScoped()) {
return planAncestor;
} else {
- // TODO DAG - get first parent. See comment above
ancestor = ancestors.get(0);
ancestors = ancestor.getParents();
}
}
-
+
return null;
}
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/pipeline/stage/transform/internal/SyntheticContextBundleCreatingTransformer.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/pipeline/stage/transform/internal/SyntheticContextBundleCreatingTransformer.java
index 3cb4c946..cd5c7389 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/pipeline/stage/transform/internal/SyntheticContextBundleCreatingTransformer.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/pipeline/stage/transform/internal/SyntheticContextBundleCreatingTransformer.java
@@ -23,7 +23,6 @@ import org.eclipse.virgo.kernel.artifact.fs.ArtifactFS;
import org.eclipse.virgo.kernel.artifact.fs.ArtifactFSEntry;
import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
import org.eclipse.virgo.kernel.deployer.core.FatalDeploymentException;
-import org.eclipse.virgo.kernel.deployer.core.internal.GraphUtils;
import org.eclipse.virgo.kernel.install.artifact.ArtifactIdentity;
import org.eclipse.virgo.kernel.install.artifact.ArtifactIdentityDeterminer;
import org.eclipse.virgo.kernel.install.artifact.ArtifactStorage;
@@ -99,7 +98,7 @@ final class SyntheticContextBundleCreatingTransformer implements Transformer, Sc
GraphNode<InstallArtifact> syntheticContextBundle = this.installArtifactGraphFactory.constructInstallArtifactGraph(
identity, artifactStorage, null, null);
- GraphUtils.addChild(graph, syntheticContextBundle);
+ graph.addChild(syntheticContextBundle);
}
}

Back to the top