/**
*
*/
package net.fp.rp.workflow.flow.action;
import net.fp.rp.workflow.flow.state.FlowStateBean;
import net.fp.rp.drools.SpringDecisionTableLoader;
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 decide the message type that needs to be sent This
* delegates to the Decision Table contained in DecisionTable.xls
*
* This project uses Apache, Spring, JBoss and other GPL Licenced Code
*
* @author paul browne
*/
public class MappingActionHander 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 addMessageTransitionName = null;
public String deleteMessageTransitionName = null;
// Handle to the Drools workflow bean
SpringDecisionTableLoader dtLoader = null;
// Name of the SpringDecisionTableLoaderBean bean
private static String SPRING_DECISION_TABLE_LOADER_BEAN_NAME = "SpringDecisionTableLoaderBean";
// These values will be set by JBPM
public String successTransitionName = null;
/**
* Pass in the Execution Context, decide on which transition to leave the
* node by. jBPM expects the transition provided (
*
* @return String - name of the Transition to follow
*/
public void execute(ExecutionContext executionContext) {
log.debug("Enter MappingActionHander");
//Short circuit until implemented
if(true) return;
try {
// Carry out the processing
FlowStateBean flowBean = super
.getFlowBeanFromContext(executionContext);
// Get the Spring bean responsible for loading the decision table
BeanFactory appContext = super.getSpringContext();
dtLoader = (SpringDecisionTableLoader) appContext
.getBean(SPRING_DECISION_TABLE_LOADER_BEAN_NAME);
// 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 , ending workflow", t);
executionContext
.leaveNode(AbstractActionHandler.ERROR_TRANSITION_NAME);
}
log.debug("Exit MappingActionHander");
}
}