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.core;
18  
19  
20  import org.apache.commons.workflow.Context;
21  import org.apache.commons.workflow.Descriptor;
22  import org.apache.commons.workflow.StepException;
23  import org.apache.commons.workflow.base.DescriptorStep;
24  
25  
26  /**
27   * <p>For each associated <code>Descriptor</code>, remove the corresponding
28   * Java object from our Context, in the order that descriptors are
29   * listed.</p>
30   *
31   * @version $Revision: 155475 $ $Date: 2005-02-26 13:31:11 +0000 (Sat, 26 Feb 2005) $
32   * @author Craig R. McClanahan
33   */
34  
35  public class RemoveStep extends DescriptorStep {
36  
37  
38      // ----------------------------------------------------------= Constructors
39  
40  
41      /**
42       * Construct a default instance of this Step.
43       */
44      public RemoveStep() {
45  
46          super();
47  
48      }
49  
50  
51      /**
52       * Construct an instance of this Step with the specified identifier.
53       *
54       * @param id Step identifier
55       */
56      public RemoveStep(String id) {
57  
58          super();
59          setId(id);
60  
61      }
62  
63  
64      /**
65       * Construct an instance of this Step with the specified identifier
66       * and associated Descriptor.
67       *
68       * @param id Step identifier
69       * @param descriptor Initial descriptor
70       */
71      public RemoveStep(String id, Descriptor descriptor) {
72  
73          super();
74          setId(id);
75          addDescriptor(descriptor);
76  
77      }
78  
79  
80      // --------------------------------------------------------- Public Methods
81  
82  
83      /**
84       * Perform the executable actions related to this Step, in the context of
85       * the specified Context.
86       *
87       * @param context The Context that is tracking our execution state
88       *
89       * @exception StepException if a processing error has occurred
90       */
91      public void execute(Context context) throws StepException {
92  
93          // Process all associated descriptors
94          Descriptor descriptors[] = findDescriptors();
95          for (int i = 0; i < descriptors.length; i++) {
96              descriptors[i].remove(context);
97          }
98  
99      }
100 
101 
102 }