//
// FlowStepCall.java - Call a nested Flow
//

package nyangau.jmsadapter;

//...simports:0:
import javax.jms.JMSException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
//...e

public class FlowStepCall extends FlowStep
  {
  protected String flow;
  protected Flow f;
//...sFlowStepCall:2:
public FlowStepCall(Node eStep)
  throws FlowProcessorException
  {
  super(eStep);
  NamedNodeMap nnmStep = eStep.getAttributes();
  Node aFlow = nnmStep.getNamedItem("flow");
  if ( aFlow == null )
    throw new FlowProcessorException("unexpected missing flow in step"+name+", bad jmsadapter.xsd?");
  flow = aFlow.getNodeValue();

  // Note that you might think we can lookup the callee Flow right now,
  // but note that not all of them may have been read from the configuration
  // XML at the time we are called here, so we do this lookup lazily.
  f = null;
  }
//...e
//...sprocess:2:
public void process(FlowContext c)
  throws FlowProcessorException, JMSException
  {
  if ( f == null )
    {
    f = c.getFlowProcessor().getFlow(flow);
    if ( f == null )
      throw new FlowProcessorException("unexpected reference to non-existent flow "+flow+" in step "+name+", bad jmsadapter.xsd?");
    }
  f.process(c);
  }
//...e
  }
