Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMengxin Zhu2012-01-12 02:27:54 -0500
committerMengxin Zhu2012-01-12 02:51:38 -0500
commit04549b1dd45c808514d61d55185d55a7a8b7fb63 (patch)
treee5cd3123c13bc9d2582cdcc15cd812e7f7bdaf67 /bundles/org.eclipse.equinox.p2.engine/src
parentc56d3086f43989513d7e3d2a149a0b6b1f82e9a7 (diff)
downloadrt.equinox.p2-04549b1dd45c808514d61d55185d55a7a8b7fb63.tar.gz
rt.equinox.p2-04549b1dd45c808514d61d55185d55a7a8b7fb63.tar.xz
rt.equinox.p2-04549b1dd45c808514d61d55185d55a7a8b7fb63.zip
316328 engine should be more verbose while performing an installationv20120112-1825
1. the event of phase starts and finishes 2. download events, including how many artifacts to be downloaded, how many artifacts to be downloaded from a specific repository, the mirror request(download) result, download progress event(a wrapper of ProgressStatistics) 3. the events before/after configuring/unconfiguring an IU Signed-off-by: Mengxin Zhu <kane.zhu@windriver.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.engine/src')
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/CollectEvent.java74
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/InstallableUnitEvent.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Messages.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Phase.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/PhaseEvent.java46
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/messages.properties4
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Collect.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Configure.java73
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Unconfigure.java72
10 files changed, 312 insertions, 28 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/CollectEvent.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/CollectEvent.java
new file mode 100644
index 000000000..fdd62f2a2
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/CollectEvent.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River 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:
+ * Wind River - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.engine;
+
+import java.util.EventObject;
+import org.eclipse.equinox.p2.engine.ProvisioningContext;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRequest;
+
+public class CollectEvent extends EventObject {
+
+ private static final long serialVersionUID = 5782796765127875200L;
+ /**
+ * It means the overall collecting requests are started.
+ */
+ public static final int TYPE_OVERALL_START = 1;
+ /**
+ * It means the overall collecting requests are finished.
+ */
+ public static final int TYPE_OVERALL_END = 2;
+ /**
+ * It means the collecting requests related to a special repository are started.
+ * See {@link CollectEvent#getRepository()}
+ */
+ public static final int TYPE_REPOSITORY_START = 3;
+ /**
+ * It means the collecting requests related to a special repository are end.
+ * See {@link CollectEvent#getRepository()}
+ */
+ public static final int TYPE_REPOSITORY_END = 4;
+
+ private IArtifactRepository artifactRepo;
+ private IArtifactRequest[] requests;
+
+ private ProvisioningContext context;
+
+ private int type;
+
+ public CollectEvent(int type, IArtifactRepository artifactRepo, ProvisioningContext context, IArtifactRequest[] requests) {
+ super(requests);
+ this.type = type;
+ this.artifactRepo = artifactRepo;
+ this.context = context;
+ this.requests = requests;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ /**
+ * Return the associated repository if the downloading requests are related to a special repository
+ * @return the associated repository or <code>null</code> if the repository is unknown
+ */
+ public IArtifactRepository getRepository() {
+ return artifactRepo;
+ }
+
+ public IArtifactRequest[] getDownloadRequests() {
+ return requests;
+ }
+
+ public ProvisioningContext getContext() {
+ return context;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java
index 8daa26bae..d1df5cf0c 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * Copyright (c) 2007, 2012 IBM Corporation 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
@@ -14,6 +14,7 @@ package org.eclipse.equinox.internal.p2.engine;
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.engine.phases.Collect;
+import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
@@ -107,7 +108,9 @@ public class DownloadManager {
SubMonitor monitor = SubMonitor.convert(mon, requestsToProcess.size());
for (int i = 0; i < repositories.length && !requestsToProcess.isEmpty() && !monitor.isCanceled(); i++) {
IArtifactRequest[] requests = getRequestsForRepository(repositories[i]);
+ publishDownloadEvent(new CollectEvent(CollectEvent.TYPE_REPOSITORY_START, repositories[i], provContext, requests));
IStatus dlStatus = repositories[i].getArtifacts(requests, monitor.newChild(requests.length));
+ publishDownloadEvent(new CollectEvent(CollectEvent.TYPE_REPOSITORY_END, repositories[i], provContext, requests));
if (dlStatus.getSeverity() == IStatus.CANCEL)
return;
filterUnfetched();
@@ -115,6 +118,12 @@ public class DownloadManager {
}
}
+ private void publishDownloadEvent(CollectEvent event) {
+ IProvisioningEventBus bus = (IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME);
+ if (bus != null)
+ bus.publishEvent(event);
+ }
+
private IArtifactRequest[] getRequestsForRepository(IArtifactRepository repository) {
ArrayList<IArtifactRequest> applicable = new ArrayList<IArtifactRequest>();
for (IArtifactRequest request : requestsToProcess) {
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/InstallableUnitEvent.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/InstallableUnitEvent.java
index 8eb5c0cfd..6d4424892 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/InstallableUnitEvent.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/InstallableUnitEvent.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2012 IBM Corporation 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
@@ -7,14 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Wind River - ongoing development
*******************************************************************************/
package org.eclipse.equinox.internal.p2.engine;
-import org.eclipse.equinox.p2.engine.IProfile;
-
import java.util.EventObject;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.spi.Touchpoint;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
@@ -24,6 +24,8 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnit;
public class InstallableUnitEvent extends EventObject {
public static final int UNINSTALL = 0;
public static final int INSTALL = 1;
+ public static final int UNCONFIGURE = 2;
+ public static final int CONFIGURE = 3;
private static final long serialVersionUID = 3318712818811459886L;
private String phaseId;
@@ -45,8 +47,8 @@ public class InstallableUnitEvent extends EventObject {
this.prePhase = prePhase;
this.profile = profile;
this.iu = iu;
- if (type != UNINSTALL && type != INSTALL)
- throw new IllegalArgumentException(Messages.InstallableUnitEvent_type_not_install_or_uninstall);
+ if (type != UNINSTALL && type != INSTALL && type != UNCONFIGURE && type != CONFIGURE)
+ throw new IllegalArgumentException(Messages.InstallableUnitEvent_type_not_install_or_uninstall_or_configure);
this.type = type;
this.result = result;
this.touchpoint = touchpoint;
@@ -88,4 +90,12 @@ public class InstallableUnitEvent extends EventObject {
public boolean isUninstall() {
return type == UNINSTALL;
}
+
+ public boolean isConfigure() {
+ return type == CONFIGURE;
+ }
+
+ public boolean isUnConfigure() {
+ return type == UNCONFIGURE;
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Messages.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Messages.java
index 453670e7f..9c9710c4a 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Messages.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * Copyright (c) 2007, 2012 IBM Corporation 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
@@ -39,7 +39,7 @@ public class Messages extends NLS {
public static String error_parsing_profile;
public static String error_persisting_profile;
public static String forced_action_execute_error;
- public static String InstallableUnitEvent_type_not_install_or_uninstall;
+ public static String InstallableUnitEvent_type_not_install_or_uninstall_or_configure;
public static String io_FailedRead;
public static String io_NotFound;
public static String not_current_operand;
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Phase.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Phase.java
index 14782d57b..f57a4829a 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Phase.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Phase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2012 IBM Corporation 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
@@ -13,6 +13,7 @@ package org.eclipse.equinox.internal.p2.engine;
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
+import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
@@ -66,9 +67,21 @@ public abstract class Phase {
return getClass().getName() + " - " + this.weight; //$NON-NLS-1$
}
+ private void broadcastPhaseEvent(EngineSession session, Operand[] operands, int type) {
+ IProvisioningEventBus bus = (IProvisioningEventBus) session.getAgent().getService(IProvisioningEventBus.SERVICE_NAME);
+ if (bus != null) {
+ bus.publishEvent(getPhaseEvent(operands, type));
+ }
+ }
+
+ protected PhaseEvent getPhaseEvent(final Operand[] operands, int type) {
+ return new PhaseEvent(phaseId, operands, type);
+ }
+
void perform(MultiStatus status, EngineSession session, Operand[] operands, IProgressMonitor monitor) {
SubMonitor subMonitor = SubMonitor.convert(monitor, prePerformWork + mainPerformWork + postPerformWork);
session.recordPhaseEnter(this);
+ broadcastPhaseEvent(session, operands, PhaseEvent.TYPE_START);
prePerform(status, session, subMonitor.newChild(prePerformWork));
if (status.matches(IStatus.ERROR | IStatus.CANCEL))
return;
@@ -85,6 +98,7 @@ public abstract class Phase {
phaseParameters.clear();
if (status.matches(IStatus.ERROR | IStatus.CANCEL))
return;
+ broadcastPhaseEvent(session, operands, PhaseEvent.TYPE_END);
session.recordPhaseExit(this);
subMonitor.done();
}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/PhaseEvent.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/PhaseEvent.java
new file mode 100644
index 000000000..2461242a2
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/PhaseEvent.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River 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:
+ * Wind River - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.engine;
+
+import java.util.EventObject;
+
+public class PhaseEvent extends EventObject {
+
+ private static final long serialVersionUID = 8971345257149340658L;
+
+ public static final int TYPE_START = 1;
+ public static final int TYPE_END = 2;
+
+ private int type;
+
+ private String phaseId;
+
+ private Operand[] operands;
+
+ public PhaseEvent(String phaseId, Operand[] operands, int type) {
+ super(operands);
+ this.phaseId = phaseId;
+ this.type = type;
+ this.operands = operands;
+ }
+
+ public String getPhaseId() {
+ return phaseId;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public Operand[] getOperands() {
+ return operands;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/messages.properties b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/messages.properties
index b8e98c09d..597ef540d 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2007, 2011 IBM Corporation and others.
+# Copyright (c) 2007, 2012 IBM Corporation 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
@@ -90,7 +90,7 @@ rollingback_error=An error was detected while performing the engine operation an
rollingback_cancel=The engine operation was cancelled and the changes are being rolled back.
Engine_Operation_Canceled_By_User=Operation canceled by the user.
-InstallableUnitEvent_type_not_install_or_uninstall=type must be either UNINSTALL(0) or INSTALL(1)
+InstallableUnitEvent_type_not_install_or_uninstall_or_configure=type must be either UNINSTALL(0) or INSTALL(1) or UNCONFIGURE(2) or CONFIGURE(3)
CertificateChecker_CertificateError=An invalid certificate was found.
CertificateChecker_CertificateRejected=One or more certificates rejected. Cannot proceed with installation.
CertificateChecker_KeystoreConnectionError=Cannot connect to keystore.
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Collect.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Collect.java
index 92ad013d4..df2435eda 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Collect.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Collect.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2012 IBM Corporation 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
@@ -15,6 +15,7 @@ import java.util.*;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.internal.p2.engine.*;
+import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
@@ -69,11 +70,24 @@ public class Collect extends InstallableUnitPhase {
ProvisioningContext context = (ProvisioningContext) parameters.get(PARM_CONTEXT);
IProvisioningAgent agent = (IProvisioningAgent) parameters.get(PARM_AGENT);
+ List<IArtifactRequest> totalArtifactRequests = new ArrayList<IArtifactRequest>(artifactRequests.size());
DownloadManager dm = new DownloadManager(context, agent);
for (IArtifactRequest[] requests : artifactRequests) {
- dm.add(requests);
+ for (int i = 0; i < requests.length; i++) {
+ dm.add(requests[i]);
+ totalArtifactRequests.add(requests[i]);
+ }
+ }
+ IProvisioningEventBus bus = (IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME);
+ if (bus != null)
+ bus.publishEvent(new CollectEvent(CollectEvent.TYPE_OVERALL_START, null, context, totalArtifactRequests.toArray(new IArtifactRequest[totalArtifactRequests.size()])));
+ IStatus downloadStatus = dm.start(monitor);
+ try {
+ return downloadStatus;
+ } finally {
+ if (downloadStatus.isOK() && bus != null)
+ bus.publishEvent(new CollectEvent(CollectEvent.TYPE_OVERALL_END, null, context, totalArtifactRequests.toArray(new IArtifactRequest[totalArtifactRequests.size()])));
}
- return dm.start(monitor);
}
protected IStatus initializePhase(IProgressMonitor monitor, IProfile profile, Map<String, Object> parameters) {
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Configure.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Configure.java
index 7d4a834ef..f7fc7c871 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Configure.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Configure.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2012 IBM Corporation 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
@@ -7,23 +7,68 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Wind River - ongoing development
*******************************************************************************/
package org.eclipse.equinox.internal.p2.engine.phases;
-import org.eclipse.equinox.p2.query.QueryUtil;
-
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.engine.*;
-import org.eclipse.equinox.p2.engine.PhaseSetFactory;
+import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.PhaseSetFactory;
import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.engine.spi.Touchpoint;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.osgi.util.NLS;
public class Configure extends InstallableUnitPhase {
+ final static class BeforeConfigureEventAction extends ProvisioningAction {
+
+ public IStatus execute(Map<String, Object> parameters) {
+ IProfile profile = (IProfile) parameters.get(PARM_PROFILE);
+ String phaseId = (String) parameters.get(PARM_PHASE_ID);
+ IInstallableUnit iu = (IInstallableUnit) parameters.get(PARM_IU);
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(PARM_AGENT);
+ ((IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME)).publishEvent(new InstallableUnitEvent(phaseId, true, profile, iu, InstallableUnitEvent.CONFIGURE, getTouchpoint()));
+ return null;
+ }
+
+ public IStatus undo(Map<String, Object> parameters) {
+ Profile profile = (Profile) parameters.get(PARM_PROFILE);
+ String phaseId = (String) parameters.get(PARM_PHASE_ID);
+ IInstallableUnit iu = (IInstallableUnit) parameters.get(PARM_IU);
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(PARM_AGENT);
+ ((IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME)).publishEvent(new InstallableUnitEvent(phaseId, false, profile, iu, InstallableUnitEvent.UNCONFIGURE, getTouchpoint()));
+ return null;
+ }
+ }
+
+ final static class AfterConfigureEventAction extends ProvisioningAction {
+
+ public IStatus execute(Map<String, Object> parameters) {
+ Profile profile = (Profile) parameters.get(PARM_PROFILE);
+ String phaseId = (String) parameters.get(PARM_PHASE_ID);
+ IInstallableUnit iu = (IInstallableUnit) parameters.get(PARM_IU);
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(PARM_AGENT);
+ ((IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME)).publishEvent(new InstallableUnitEvent(phaseId, false, profile, iu, InstallableUnitEvent.CONFIGURE, getTouchpoint()));
+ return null;
+ }
+
+ public IStatus undo(Map<String, Object> parameters) {
+ IProfile profile = (IProfile) parameters.get(PARM_PROFILE);
+ String phaseId = (String) parameters.get(PARM_PHASE_ID);
+ IInstallableUnit iu = (IInstallableUnit) parameters.get(PARM_IU);
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(PARM_AGENT);
+ ((IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME)).publishEvent(new InstallableUnitEvent(phaseId, true, profile, iu, InstallableUnitEvent.UNCONFIGURE, getTouchpoint()));
+ return null;
+ }
+ }
+
public Configure(int weight) {
super(PhaseSetFactory.PHASE_CONFIGURE, weight);
}
@@ -34,9 +79,23 @@ public class Configure extends InstallableUnitPhase {
protected List<ProvisioningAction> getActions(InstallableUnitOperand currentOperand) {
IInstallableUnit unit = currentOperand.second();
- if (QueryUtil.isFragment(unit))
- return null;
- return getActions(unit, phaseId);
+
+ ProvisioningAction beforeAction = new BeforeConfigureEventAction();
+ ProvisioningAction afterAction = new AfterConfigureEventAction();
+ Touchpoint touchpoint = getActionManager().getTouchpointPoint(unit.getTouchpointType());
+ if (touchpoint != null) {
+ beforeAction.setTouchpoint(touchpoint);
+ afterAction.setTouchpoint(touchpoint);
+ }
+ ArrayList<ProvisioningAction> actions = new ArrayList<ProvisioningAction>();
+ actions.add(beforeAction);
+ if (!QueryUtil.isFragment(unit)) {
+ List<ProvisioningAction> parsedActions = getActions(unit, phaseId);
+ if (parsedActions != null)
+ actions.addAll(parsedActions);
+ }
+ actions.add(afterAction);
+ return actions;
}
protected String getProblemMessage() {
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Unconfigure.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Unconfigure.java
index 8edd542f5..76a8d6341 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Unconfigure.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Unconfigure.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2012 IBM Corporation 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
@@ -7,22 +7,67 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Wind River - ongoing development
*******************************************************************************/
package org.eclipse.equinox.internal.p2.engine.phases;
-import org.eclipse.equinox.p2.query.QueryUtil;
-
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.engine.*;
-import org.eclipse.equinox.p2.engine.PhaseSetFactory;
+import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.PhaseSetFactory;
import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.engine.spi.Touchpoint;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.query.QueryUtil;
public class Unconfigure extends InstallableUnitPhase {
+ final static class BeforeUnConfigureEventAction extends ProvisioningAction {
+
+ public IStatus execute(Map<String, Object> parameters) {
+ IProfile profile = (IProfile) parameters.get(PARM_PROFILE);
+ String phaseId = (String) parameters.get(PARM_PHASE_ID);
+ IInstallableUnit iu = (IInstallableUnit) parameters.get(PARM_IU);
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(PARM_AGENT);
+ ((IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME)).publishEvent(new InstallableUnitEvent(phaseId, true, profile, iu, InstallableUnitEvent.UNCONFIGURE, getTouchpoint()));
+ return null;
+ }
+
+ public IStatus undo(Map<String, Object> parameters) {
+ Profile profile = (Profile) parameters.get(PARM_PROFILE);
+ String phaseId = (String) parameters.get(PARM_PHASE_ID);
+ IInstallableUnit iu = (IInstallableUnit) parameters.get(PARM_IU);
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(PARM_AGENT);
+ ((IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME)).publishEvent(new InstallableUnitEvent(phaseId, false, profile, iu, InstallableUnitEvent.CONFIGURE, getTouchpoint()));
+ return null;
+ }
+ }
+
+ final static class AfterUnConfigureEventAction extends ProvisioningAction {
+
+ public IStatus execute(Map<String, Object> parameters) {
+ Profile profile = (Profile) parameters.get(PARM_PROFILE);
+ String phaseId = (String) parameters.get(PARM_PHASE_ID);
+ IInstallableUnit iu = (IInstallableUnit) parameters.get(PARM_IU);
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(PARM_AGENT);
+ ((IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME)).publishEvent(new InstallableUnitEvent(phaseId, false, profile, iu, InstallableUnitEvent.UNCONFIGURE, getTouchpoint()));
+ return null;
+ }
+
+ public IStatus undo(Map<String, Object> parameters) {
+ IProfile profile = (IProfile) parameters.get(PARM_PROFILE);
+ String phaseId = (String) parameters.get(PARM_PHASE_ID);
+ IInstallableUnit iu = (IInstallableUnit) parameters.get(PARM_IU);
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(PARM_AGENT);
+ ((IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME)).publishEvent(new InstallableUnitEvent(phaseId, true, profile, iu, InstallableUnitEvent.CONFIGURE, getTouchpoint()));
+ return null;
+ }
+ }
+
public Unconfigure(int weight, boolean forced) {
super(PhaseSetFactory.PHASE_UNCONFIGURE, weight, forced);
}
@@ -39,10 +84,23 @@ public class Unconfigure extends InstallableUnitPhase {
//TODO: monitor.subTask(NLS.bind(Messages.Engine_Unconfiguring_IU, unit.getId()));
IInstallableUnit unit = currentOperand.first();
- if (QueryUtil.isFragment(unit))
- return null;
- return getActions(unit, phaseId);
+ ProvisioningAction beforeAction = new BeforeUnConfigureEventAction();
+ ProvisioningAction afterAction = new AfterUnConfigureEventAction();
+ Touchpoint touchpoint = getActionManager().getTouchpointPoint(unit.getTouchpointType());
+ if (touchpoint != null) {
+ beforeAction.setTouchpoint(touchpoint);
+ afterAction.setTouchpoint(touchpoint);
+ }
+ ArrayList<ProvisioningAction> actions = new ArrayList<ProvisioningAction>();
+ actions.add(beforeAction);
+ if (!QueryUtil.isFragment(unit)) {
+ List<ProvisioningAction> parsedActions = getActions(unit, phaseId);
+ if (parsedActions != null)
+ actions.addAll(parsedActions);
+ }
+ actions.add(afterAction);
+ return actions;
}
protected String getProblemMessage() {

Back to the top