001    /*
002     * Copyright 1999-2001,2004 The Apache Software Foundation.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */ 
016    
017    package org.apache.commons.workflow;
018    
019    
020    /**
021     * <p>A <strong>Block</strong> is a Step that can include nested Steps.
022     * It is used to create Step implementations supporting conditional
023     * execution and iteration.</p>
024     *
025     * <p><strong>DESIGN NOTES</strong> - The <code>execute()</code> method will
026     * be called when the Block is first encountered in the normal flow of
027     * execution (as with any other Step), and each time the execution of the
028     * nested Steps associated with this Block.  The Block implementation is
029     * responsible for satisfying the following contract requirements:</p>
030     * <ul>
031     * <li>Determine whether this is a first-time entry, or a repeated entry
032     *     after execution of the nested Steps for this Block:
033     *     <ul>
034     *     <li>Peek at the top item on the <code>BlockState</code> stack maintained
035     *         for us by the current <code>Context</code>.</li>
036     *     <li>If the top item exists, and has a <code>block</code> property
037     *         equal to the current Block, this is a repeated entry after execution
038     *         of the nested Steps for this Block.</li>
039     *     <li>If there is no top element, or the top element is for a different
040     *         <code>Block</code>, this is the initial entry from the preceeding
041     *         Step in the current Activity (or Block).</li>
042     *     </ul>
043     * <li>When this is the initial entry into the Block, make a decision about
044     *     whether the nested Steps should be executed:
045     *     <ul>
046     *     <li>If the nested Steps <strong>SHOULD</strong> be executed, create a
047     *         new <code>BlockState</code> object (associated with this
048     *         <code>Block</code>) and push it onto the <code>BlockState</code>
049     *         stack.  Then, set the next Step to be the first nested Step
050     *         for this Block.</li>
051     *     <li>If the nested Steps <strong>SHOULD NOT</strong> be executed,
052     *         simply return.  The next Step will have already been set to the
053     *         next Step of the current Activity (or Block) at the same nesting
054     *         level.</li>
055     *     </ul></li>
056     *  <li>When this is a repeated entry into the Block, make a decision about
057     *      whether the nested Steps should be executed again:
058     *      <ul>
059     *      <li>If the nested Steps <strong>SHOULD</strong> be executed again,
060     *          set the next Step to be the first nested Step for this Block.</li>
061     *      <li>If the nested Steps <strong>SHOULD NOT</strong> be executed again,
062     *          pop our <code>BlockState</code> object off of the stack
063     *          maintained by our <code>Context</code>.  Then, set the next Step
064     *          to the <code>nextStep</code> property of this Block, which will
065     *          cause execution to flow past the Block.</li>
066     *      </ul>
067     * </ul>
068     *
069     * @version $Revision: 155475 $ $Date: 2005-02-26 13:31:11 +0000 (Sat, 26 Feb 2005) $
070     * @author Craig R. McClanahan
071     */
072    
073    public interface Block extends Owner, Step {
074    
075    
076        // --------------------------------------------------------- Public Methods
077    
078    
079    }