KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mr > core > util > patterns > flow > DefaultFlowFramework


1 package org.mr.core.util.patterns.flow;
2
3 import java.util.Map JavaDoc;
4
5 /*
6  * Copyright 2002 by
7  * <a HREF="http://www.coridan.com">Coridan</a>
8  * <a HREF="mailto: support@coridan.com ">support@coridan.com</a>
9  *
10  * The contents of this file are subject to the Mozilla Public License Version
11  * 1.1 (the "License"); you may not use this file except in compliance with the
12  * License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS" basis,
16  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17  * for the specific language governing rights and limitations under the
18  * License.
19  *
20  * The Original Code is "MantaRay" (TM).
21  *
22  * The Initial Developer of the Original Code is Coridan.
23  * Portions created by the Initial Developer are Copyright (C) 2006
24  * Coridan Inc. All Rights Reserved.
25  *
26  * Contributor(s): all the names of the contributors are added in the source
27  * code where applicable.
28  *
29  * Alternatively, the contents of this file may be used under the terms of the
30  * LGPL license (the "GNU LESSER GENERAL PUBLIC LICENSE"), in which case the
31  * provisions of LGPL are applicable instead of those above. If you wish to
32  * allow use of your version of this file only under the terms of the LGPL
33  * License and not to allow others to use your version of this file under
34  * the MPL, indicate your decision by deleting the provisions above and
35  * replace them with the notice and other provisions required by the LGPL.
36  * If you do not delete the provisions above, a recipient may use your version
37  * of this file under either the MPL or the GNU LESSER GENERAL PUBLIC LICENSE.
38  
39  *
40  * This library is free software; you can redistribute it and/or modify it
41  * under the terms of the MPL as stated above or under the terms of the GNU
42  * Lesser General Public License as published by the Free Software Foundation;
43  * either version 2.1 of the License, or any later version.
44  *
45  * This library is distributed in the hope that it will be useful, but WITHOUT
46  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
47  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
48  * License for more details.
49  */

50
51  /**
52  * User: Moti Tal
53  * Date: Mar 13, 2005
54  * Time: 11:25:42 AM
55  *
56  * A default FlowFramework implementation.
57  */

58 public class DefaultFlowFramework implements FlowFramework{
59
60     protected Flow m_flow = null;
61
62     public void setFlow(Flow i_flow){
63         m_flow = i_flow;
64     }
65
66     public Map JavaDoc execute(Map JavaDoc i_map) {
67         Declaration next = null;
68
69         //execute the flow logic
70
for (int i=1; true ; i++) {
71             next = m_flow.getNextStep(next,i_map);
72             if(next == null){
73                 postExecution(i_map, i);
74                 break;
75             }
76             preSingleExecute(next, i_map, i);
77             i_map = next.execute(i_map);
78             postSingleExecute(next, i_map, i);
79         }
80         return i_map;
81     }
82
83      /**
84       * A hook, called before each step
85       * @param i_current the current Declaration
86       * @param i_map the upto date parameters
87       * @param i_orderMunber the step number at the flow
88       */

89     protected void preSingleExecute(Declaration i_current, Map JavaDoc i_map, int i_orderMunber){
90     }
91
92     /**
93      * A hook, called after each step
94      * @param i_current the current Declaration
95      * @param i_map the upto date parameters
96      * @param i_orderMunber the step number at the flow
97      */

98     protected void postSingleExecute(Declaration i_current, Map JavaDoc i_map, int i_orderMunber){
99     }
100
101     /**
102      * A hook, called after the flow finished.
103      * @param i_map the upto date parameters
104      * @param i_totalExecutions the total number of tasks in this flow.
105      */

106     protected void postExecution(Map JavaDoc i_map, int i_totalExecutions){
107     }
108 }
109
Popular Tags