/**
*
*/
package net.fp.rp.workflow.flow.action;
import net.fp.rp.workflow.db.MessageDao;
import net.fp.rp.workflow.flow.state.FlowStateBean;
import net.fp.rp.common.exception.RpException;
import org.apache.log4j.Logger;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
import org.springframework.beans.factory.BeanFactory;
/**
* A decision Handler to check if this client is registered and act accordingly
*
* This project uses Apache, Spring, JBoss and other GPL Licenced Code
*
* @author paul browne
*/
public class FlowExceptionHandler extends AbstractActionHandler
implements ActionHandler {
// Serial ID
static final long serialVersionUID = 1;
/** Logger for this class and subclasses */
protected final Logger log = Logger.getLogger(getClass());
// These values will be set by JBPM
public String successTransitionName = null;
// Name of the SpringDecisionTableLoaderBean bean
public static String DAO_NAME = "MessageDao";
//The code we use for BR Messages
public static final String BR_MESSAGE_TYPE="BR";
/**
* Pass in the Execution Context, decide on which transition to leave the
* node by. jBPM expects the transition provided
*
* Note that even if an exception occurs , the transition will always be to the success node:
* This is to ensure that we send the message , even if the system is down
*
* @return String - name of the Transition to follow
*/
public void execute(ExecutionContext executionContext) {
log.debug("Enter FlowExceptionHandler");
try {
// Carry out the processing
FlowStateBean flowBean = super
.getFlowBeanFromContext(executionContext);
// Update the context
super.setFlowBeanInContext(executionContext, flowBean);
// transition to the next node based on the decision
executionContext.leaveNode(successTransitionName);
} catch (Throwable t) {
// Log the exception , end the workflow
log .warn("Exception occured , but carrying on with remainder of workflow", t);
executionContext.leaveNode(successTransitionName);
}
log.debug("Exit FlowExceptionHandler");
}
}