/**
 * Abort.java
 * Created May 15, 2007
 * Copyright (c) Tandberg Television 2007
 */
package com.tandbergtv.workflow.exe;

import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

/**
 * Causes execution to abort by throwing an exception containing a pre-defined error string
 * 
 * @author Sahil Verma
 */
public class Abort implements ActionHandler {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2691598208478936881L;
	
	private String failureReason;

	/**
	 * 
	 */
	public Abort() {
	}

	/* (non-Javadoc)
	 * @see org.jbpm.graph.def.ActionHandler#execute(org.jbpm.graph.exe.ExecutionContext)
	 */
	public void execute(ExecutionContext context) throws Exception {
		throw new ActionException(context.getProcessInstance() + ", forcing execution to fail: " + failureReason);
	}

	/**
	 * @return the failureReason
	 */
	public String getFailureReason() {
		return failureReason;
	}

	/**
	 * @param failureReason the failureReason to set
	 */
	public void setFailureReason(String failureReason) {
		this.failureReason = failureReason;
	}
}
