/**
*
*/
package net.fp.rp.workflow.flow.action;
import net.fp.rp.drools.SpringDecisionTableLoader;
import net.fp.rp.workflow.flow.state.FlowStateBean;
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
*
* This project uses Apache, Spring, JBoss and other GPL Licenced Code
*
* delegates to the Decision Table contained in DecisionTable.xls
*
* @author paul browne
*/
public class DecisionHander 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";
/**
* 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 MessageTypeDecisionHander");
try {
// Carry out the processing
FlowStateBean flowBean = super
.getFlowBeanFromContext(executionContext);
//MessageLogs tmpMl = flowBean.getMLog();
// Get the Spring bean responsible for loading the decision table
BeanFactory appContext = super.getSpringContext();
dtLoader = (SpringDecisionTableLoader) appContext
.getBean(SPRING_DECISION_TABLE_LOADER_BEAN_NAME);
//Set the state that we are in on the bean
// Carry out the processing using the Delegate
// Create the Xml Object and place it in the flow bean
// Update the context
super.setFlowBeanInContext(executionContext, flowBean);
//Message type
log.debug("Message Type has decided transition:");
// transition to the next node based on the decision
executionContext.leaveNode();
} 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 MessageTypeDecisionHander");
}
}