Package net.fp.rp.workflow.flow.action

Source Code of net.fp.rp.workflow.flow.action.AbstractActionHandler

/**
*
*/
package net.fp.rp.workflow.flow.action;

import net.fp.rp.workflow.flow.state.FlowStateBean;
import net.fp.rp.common.exception.*;
import net.fp.rp.spring.ContextLoader;

import org.apache.log4j.Logger;
import org.jbpm.graph.exe.ExecutionContext;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;


/**
* Class that provides utility functions for the action / decision handler
*
* This project uses Apache, Spring, JBoss and other GPL Licenced Code
*
* @author paul.browne
*/
public abstract class AbstractActionHandler {

  /** Logger for this class and subclasses */
  protected final Logger log = Logger.getLogger(getClass());
 
   //Transition to end
    protected static final String ERROR_TRANSITION_NAME = "error";
 
    //The Spring application context (if any) that has been made available to this workflow item;
    private static ApplicationContext context = null;
   
    /**
     * Extract the current state of the workflow (as a bean)
     * @param executionContext
     * @return
     * @throws RpException
     */
  protected FlowStateBean getFlowBeanFromContext(ExecutionContext executionContext) throws RpException{
 
//    Get the Message Log Object from the context
    Object tmpObject = executionContext.getVariable(FlowStateBean.FLOW_STATE_BEAN_IN_CONTEXT_NAME);
    if(tmpObject ==null){
     
      throw new RpException("No FlowStateBean found in executionContext for:"+FlowStateBean.FLOW_STATE_BEAN_IN_CONTEXT_NAME);
     
    }
    if (!(tmpObject instanceof FlowStateBean)){
     
      throw new RpException("Expected Class of FlowStateBean under key :"+FlowStateBean.FLOW_STATE_BEAN_IN_CONTEXT_NAME+" but found"+tmpObject.getClass());
     
    }
   
    return (FlowStateBean)tmpObject;
   
  }
 
  /**
   * Update the Flow State into the Context for later use
   * @param executionContext
   * @param inFlowBean
   */
  protected void setFlowBeanInContext(ExecutionContext executionContext ,FlowStateBean inFlowBean){
 
    executionContext.setVariable(FlowStateBean.FLOW_STATE_BEAN_IN_CONTEXT_NAME,inFlowBean);
   
  }
 
  /**
   * Loads (and returns) the Spring Application Context
   * @return
   * @throws RpException
   */
  protected BeanFactory getSpringContext() throws RpException {
     
    log.debug("getting Spring context ");
   
    BeanFactory myFactory = ContextLoader.getHandleToBeanFactory();
   
    log.debug("BeanFactory is Null:"+myFactory);
    return myFactory;
   
   
   
  }
 
 
 
 
}
TOP

Related Classes of net.fp.rp.workflow.flow.action.AbstractActionHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.