Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Kaegi2009-03-13 01:50:49 +0000
committerSimon Kaegi2009-03-13 01:50:49 +0000
commitc6756a6147dfd2936b26facbd9ad1ffd8e5aca78 (patch)
tree8b744f95a8af3d00fdb858a510f0a40a4ccbe85b
parentc12958ef0cdc22abf72a7e805c374e4e48b20134 (diff)
downloadrt.equinox.p2-c6756a6147dfd2936b26facbd9ad1ffd8e5aca78.tar.gz
rt.equinox.p2-c6756a6147dfd2936b26facbd9ad1ffd8e5aca78.tar.xz
rt.equinox.p2-c6756a6147dfd2936b26facbd9ad1ffd8e5aca78.zip
Bug 268433 EngineSession context string could be better
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/EngineSession.java37
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/Phase.java2
2 files changed, 35 insertions, 4 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/EngineSession.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/EngineSession.java
index e9bbc7202..22fedad11 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/EngineSession.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/EngineSession.java
@@ -14,6 +14,7 @@ import java.io.File;
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.engine.EngineActivator;
+import org.eclipse.equinox.internal.p2.engine.ParameterizedProvisioningAction;
import org.eclipse.osgi.util.NLS;
public class EngineSession {
@@ -32,6 +33,8 @@ public class EngineSession {
private List phaseActionRecordsPairs = new ArrayList();
private Phase currentPhase;
+ boolean currentPhaseActive;
+
private List currentActionRecords;
private ActionsRecord currentRecord;
@@ -113,7 +116,7 @@ public class EngineSession {
MultiStatus status = new MultiStatus(EngineActivator.ID, IStatus.OK, null, null);
- if (currentPhase != null) {
+ if (currentPhaseActive && currentPhase != null) {
try {
status.add(rollBackPhase(currentPhase, currentActionRecords));
} catch (RuntimeException e) {
@@ -124,6 +127,7 @@ public class EngineSession {
// Catch linkage errors as these are generally recoverable but let other Errors propagate (see bug 222001)
status.add(new Status(IStatus.ERROR, EngineActivator.ID, NLS.bind(Messages.phase_undo_error, currentPhase.getClass().getName()), e));
}
+ currentPhaseActive = false;
currentPhase = null;
currentActionRecords = null;
currentRecord = null;
@@ -183,7 +187,7 @@ public class EngineSession {
return result;
}
- void recordPhaseStart(Phase phase) {
+ void recordPhaseEnter(Phase phase) {
if (phase == null)
throw new IllegalArgumentException(Messages.null_phase);
@@ -191,6 +195,16 @@ public class EngineSession {
throw new IllegalStateException(Messages.phase_started);
currentPhase = phase;
+ }
+
+ void recordPhaseStart(Phase phase) {
+ if (phase == null)
+ throw new IllegalArgumentException(Messages.null_phase);
+
+ if (currentPhase != phase)
+ throw new IllegalArgumentException(Messages.not_current_phase);
+
+ currentPhaseActive = true;
currentActionRecords = new ArrayList();
}
@@ -202,8 +216,18 @@ public class EngineSession {
throw new IllegalArgumentException(Messages.not_current_phase);
phaseActionRecordsPairs.add(new Object[] {currentPhase, currentActionRecords});
- currentPhase = null;
currentActionRecords = null;
+ currentPhaseActive = false;
+ }
+
+ void recordPhaseExit(Phase phase) {
+ if (currentPhase == null)
+ throw new IllegalStateException(Messages.phase_not_started);
+
+ if (currentPhase != phase)
+ throw new IllegalArgumentException(Messages.not_current_phase);
+
+ currentPhase = null;
}
void recordOperandStart(Operand operand) {
@@ -239,7 +263,8 @@ public class EngineSession {
}
public String getContextString() {
- return NLS.bind(Messages.session_context, new Object[] {profile.getProfileId(), getCurrentPhaseId(), getCurrentOperandId(), getCurrentActionId()});
+ String message = NLS.bind(Messages.session_context, new Object[] {profile.getProfileId(), getCurrentPhaseId(), getCurrentOperandId(), getCurrentActionId()});
+ return message;
}
private Object getCurrentActionId() {
@@ -247,6 +272,10 @@ public class EngineSession {
return EMPTY_STRING;
Object currentAction = currentRecord.actions.get(currentRecord.actions.size() - 1);
+ if (currentAction instanceof ParameterizedProvisioningAction) {
+ ParameterizedProvisioningAction parameterizedAction = (ParameterizedProvisioningAction) currentAction;
+ currentAction = parameterizedAction.getAction();
+ }
return currentAction.getClass().getName();
}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/Phase.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/Phase.java
index 802d99cb3..e88378b36 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/Phase.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/Phase.java
@@ -53,6 +53,7 @@ public abstract class Phase {
public final void perform(MultiStatus status, EngineSession session, IProfile profile, Operand[] operands, ProvisioningContext context, IProgressMonitor monitor) {
SubMonitor subMonitor = SubMonitor.convert(monitor, prePerformWork + mainPerformWork + postPerformWork);
+ session.recordPhaseEnter(this);
prePerform(status, session, profile, context, subMonitor.newChild(prePerformWork));
if (status.matches(IStatus.ERROR | IStatus.CANCEL))
return;
@@ -67,6 +68,7 @@ public abstract class Phase {
subMonitor.setWorkRemaining(postPerformWork);
postPerform(status, profile, context, subMonitor.newChild(postPerformWork));
phaseParameters.clear();
+ session.recordPhaseExit(this);
if (status.matches(IStatus.ERROR | IStatus.CANCEL))
return;

Back to the top