| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2007, 2013 IBM Corporation and others. |
| 3 |
* |
| 4 |
* This program and the accompanying materials |
| 5 |
* are made available under the terms of the Eclipse Public License 2.0 |
| 6 |
* which accompanies this distribution, and is available at |
| 7 |
* https://www.eclipse.org/legal/epl-2.0/ |
| 8 |
* |
| 9 |
* SPDX-License-Identifier: EPL-2.0 |
| 10 |
* |
| 11 |
* Contributors: |
| 12 |
* IBM Corporation - initial API and implementation |
| 13 |
* Landmark Graphics Corporation - bug 397183 |
| 14 |
*******************************************************************************/ |
| 15 |
package org.eclipse.equinox.p2.engine.spi; |
| 16 |
|
| 17 |
import java.util.Map; |
| 18 |
import org.eclipse.core.runtime.IStatus; |
| 19 |
|
| 20 |
/** |
| 21 |
* An action that performs one step of a provisioning operation for a particular |
| 22 |
* {@link Touchpoint}. |
| 23 |
* @since 2.0 |
| 24 |
*/ |
| 25 |
public abstract class ProvisioningAction { |
| 26 |
|
| 27 |
private Memento memento; |
| 28 |
private Touchpoint touchpoint; |
| 29 |
|
| 30 |
protected Memento getMemento() { |
| 31 |
if (memento == null) |
| 32 |
memento = new Memento(); |
| 33 |
return memento; |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Performs the provisioning action. |
| 38 |
* @param parameters The action parameters |
| 39 |
* @return A status indicating whether the action was successful |
| 40 |
*/ |
| 41 |
public abstract IStatus execute(Map<String, Object> parameters); |
| 42 |
|
| 43 |
/** |
| 44 |
* Performs the inverse of this provisioning action. This should reverse |
| 45 |
* any effects from a previous invocation of the {@link #execute(Map)} method. |
| 46 |
* @param parameters The action parameters |
| 47 |
* @return A status indicating whether the action was successful |
| 48 |
*/ |
| 49 |
public abstract IStatus undo(Map<String, Object> parameters); |
| 50 |
|
| 51 |
/** |
| 52 |
* This method is meant for provisioning actions that need to communicate the result of their execution |
| 53 |
* to subsequent actions. |
| 54 |
* This method is only invoked by p2 once execute() has been executed. |
| 55 |
* @return the result of the action execution. |
| 56 |
* @since 2.3 |
| 57 |
*/ |
| 58 |
public Value<?> getResult() { |
| 59 |
return Value.NO_VALUE; |
| 60 |
} |
| 61 |
|
| 62 |
// TODO: these probably should not be visible |
| 63 |
public void setTouchpoint(Touchpoint touchpoint) { |
| 64 |
this.touchpoint = touchpoint; |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* Returns the touchpoint that this action is operating under. |
| 69 |
* @return the touchpoint |
| 70 |
*/ |
| 71 |
public Touchpoint getTouchpoint() { |
| 72 |
return touchpoint; |
| 73 |
} |
| 74 |
} |