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.base;
018    
019    
020    import org.apache.commons.workflow.Activity;
021    import org.apache.commons.workflow.Context;
022    import org.apache.commons.workflow.Owner;
023    import org.apache.commons.workflow.Step;
024    import org.apache.commons.workflow.StepException;
025    
026    
027    /**
028     * <p><strong>BaseStep</strong> is a convenient base class for more sophisticated
029     * <code>Step</code> implementations.  It includes management of the static
030     * relationships of Steps to each other, and to their owning Activity, but
031     * requires the implementation to provide an <code>execute()</code> method.
032     *
033     * @version $Revision: 155475 $ $Date: 2005-02-26 13:31:11 +0000 (Sat, 26 Feb 2005) $
034     * @author Craig R. McClanahan
035     */
036    
037    public abstract class BaseStep implements Step {
038    
039    
040        // ----------------------------------------------------- Instance Variables
041    
042    
043        /**
044         * The unique identifier (within this Activity) of this Step.
045         */
046        protected String id = null;
047    
048    
049        /**
050         * The next Step in our associated Activity.
051         */
052        protected Step nextStep = null;
053    
054    
055        /**
056         * The Activity or Block that owns this Step.
057         */
058        protected Owner owner = null;
059    
060    
061    
062        /**
063         * The previous Step in our associated Activity.
064         */
065        protected Step previousStep = null;
066    
067    
068    
069        // ------------------------------------------------------------- Properties
070    
071    
072        /**
073         * Return the unique identifier (within this Activity or Block)
074         * of this Step.
075         */
076        public String getId() {
077    
078            return (this.id);
079    
080        }
081    
082    
083        /**
084         * Set the unique identifier (within this Activity or Block)
085         * of this Step.
086         *
087         * @param id The new unique identifier
088         */
089        public void setId(String id) {
090    
091            this.id = id;
092    
093        }
094    
095    
096        /**
097         * Return the next Step in our associated Activity or Block.
098         */
099        public Step getNextStep() {
100    
101            return (this.nextStep);
102    
103        }
104    
105    
106        /**
107         * Set the next Step in our associated Activity or Block.
108         *
109         * @param nextStep The new next Step
110         */
111        public void setNextStep(Step nextStep) {
112    
113            this.nextStep = nextStep;
114    
115        }
116    
117    
118        /**
119         * Return the Activity or Block that owns this Step.
120         */
121        public Owner getOwner() {
122    
123            return (this.owner);
124    
125        }
126    
127    
128        /**
129         * Set the Activity or Block that owns this Step.
130         *
131         * @param owner The new owning Activity or Block
132         */
133        public void setOwner(Owner owner) {
134    
135            this.owner = owner;
136    
137        }
138    
139    
140        /**
141         * Return the previous Step in our associated Activity or Block.
142         */
143        public Step getPreviousStep() {
144    
145            return (this.previousStep);
146    
147        }
148    
149    
150        /**
151         * Set the previous Step in our associated Activity or Block.
152         *
153         * @param previousStep The new previous Step
154         */
155        public void setPreviousStep(Step previousStep) {
156    
157            this.previousStep = previousStep;
158    
159        }
160    
161    
162        // --------------------------------------------------------- Public Methods
163    
164    
165        /**
166         * Perform the executable actions related to this Step, in the context of
167         * the specified Context.
168         *
169         * @param context The Context that is tracking our execution state
170         *
171         * @exception StepException if a processing error has occurred
172         */
173        public abstract void execute(Context context) throws StepException;
174    
175    
176    }