View Javadoc

1   package br.com.ibnetwork.guara.pipeline.valve;
2   
3   import org.apache.commons.logging.Log;
4   import org.apache.commons.logging.LogFactory;
5   
6   import br.com.ibnetwork.guara.pipeline.Pipeline;
7   import br.com.ibnetwork.guara.pipeline.PipelineException;
8   import br.com.ibnetwork.guara.pipeline.Valve;
9   import br.com.ibnetwork.guara.rundata.RunData;
10  
11  /***
12   * @author <a href="mailto:leandro@ibnetwork.com.br">leandro</a>
13   */
14  public abstract class ValveSupport
15  	implements Valve
16  {
17      protected String name;
18  
19      protected Pipeline pipeline;
20      
21      protected Log log = LogFactory.getLog(this.getClass());
22  
23      public String getName()
24      {
25          return name;
26      }
27      
28      public void setName(String name)
29      {
30          this.name = name;
31      }
32  
33      public Pipeline getPipeline()
34      {
35          return pipeline;
36      }
37      
38      public void setPipeline(Pipeline pipeline)
39      {
40          this.pipeline = pipeline;
41      }
42  
43      /***
44       * Execute next valve in pipeline
45       */
46      private void keepGoing(RunData data)
47      {
48          Valve next = pipeline.getNextValve(this);
49          if(next != null)
50          {
51          	next.forward(data);    
52          }
53      }
54  
55      public final void forward(RunData data)
56  		throws PipelineException
57  	{
58     		boolean result = execute(data);
59     		if(result == true)
60          {
61     		    keepGoing(data);    
62          }
63  	}
64  
65  	protected abstract boolean execute(RunData data)
66  		throws PipelineException;
67  
68  }