View Javadoc

1   /*
2    * Copyright 1999-2001,2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */ 
16  
17  package org.apache.commons.workflow;
18  
19  
20  /**
21   * <p>A <strong>Block</strong> is a Step that can include nested Steps.
22   * It is used to create Step implementations supporting conditional
23   * execution and iteration.</p>
24   *
25   * <p><strong>DESIGN NOTES</strong> - The <code>execute()</code> method will
26   * be called when the Block is first encountered in the normal flow of
27   * execution (as with any other Step), and each time the execution of the
28   * nested Steps associated with this Block.  The Block implementation is
29   * responsible for satisfying the following contract requirements:</p>
30   * <ul>
31   * <li>Determine whether this is a first-time entry, or a repeated entry
32   *     after execution of the nested Steps for this Block:
33   *     <ul>
34   *     <li>Peek at the top item on the <code>BlockState</code> stack maintained
35   *         for us by the current <code>Context</code>.</li>
36   *     <li>If the top item exists, and has a <code>block</code> property
37   *         equal to the current Block, this is a repeated entry after execution
38   *         of the nested Steps for this Block.</li>
39   *     <li>If there is no top element, or the top element is for a different
40   *         <code>Block</code>, this is the initial entry from the preceeding
41   *         Step in the current Activity (or Block).</li>
42   *     </ul>
43   * <li>When this is the initial entry into the Block, make a decision about
44   *     whether the nested Steps should be executed:
45   *     <ul>
46   *     <li>If the nested Steps <strong>SHOULD</strong> be executed, create a
47   *         new <code>BlockState</code> object (associated with this
48   *         <code>Block</code>) and push it onto the <code>BlockState</code>
49   *         stack.  Then, set the next Step to be the first nested Step
50   *         for this Block.</li>
51   *     <li>If the nested Steps <strong>SHOULD NOT</strong> be executed,
52   *         simply return.  The next Step will have already been set to the
53   *         next Step of the current Activity (or Block) at the same nesting
54   *         level.</li>
55   *     </ul></li>
56   *  <li>When this is a repeated entry into the Block, make a decision about
57   *      whether the nested Steps should be executed again:
58   *      <ul>
59   *      <li>If the nested Steps <strong>SHOULD</strong> be executed again,
60   *          set the next Step to be the first nested Step for this Block.</li>
61   *      <li>If the nested Steps <strong>SHOULD NOT</strong> be executed again,
62   *          pop our <code>BlockState</code> object off of the stack
63   *          maintained by our <code>Context</code>.  Then, set the next Step
64   *          to the <code>nextStep</code> property of this Block, which will
65   *          cause execution to flow past the Block.</li>
66   *      </ul>
67   * </ul>
68   *
69   * @version $Revision: 155475 $ $Date: 2005-02-26 13:31:11 +0000 (Sat, 26 Feb 2005) $
70   * @author Craig R. McClanahan
71   */
72  
73  public interface Block extends Owner, Step {
74  
75  
76      // --------------------------------------------------------- Public Methods
77  
78  
79  }