KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > threads > SamplePackage


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/threads/SamplePackage.java,v 1.8 2004/02/14 03:34:29 sebb Exp $
2
/*
3  * Copyright 2001-2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17 */

18
19 package org.apache.jmeter.threads;
20
21 import java.util.Iterator JavaDoc;
22 import java.util.LinkedList JavaDoc;
23 import java.util.List JavaDoc;
24
25 import org.apache.jmeter.assertions.Assertion;
26 import org.apache.jmeter.processor.PostProcessor;
27 import org.apache.jmeter.processor.PreProcessor;
28 import org.apache.jmeter.samplers.SampleListener;
29 import org.apache.jmeter.samplers.Sampler;
30 import org.apache.jmeter.testelement.TestElement;
31 import org.apache.jmeter.timers.Timer;
32 import org.apache.jorphan.logging.LoggingManager;
33 import org.apache.log.Logger;
34
35 /**
36  * @author Michael Stover
37  * @version $Revision: 1.8 $
38  */

39 public class SamplePackage
40 {
41     private static Logger log = LoggingManager.getLoggerForClass();
42     List JavaDoc sampleListeners = new LinkedList JavaDoc();
43     List JavaDoc timers = new LinkedList JavaDoc();
44     List JavaDoc assertions = new LinkedList JavaDoc();
45     List JavaDoc postProcessors = new LinkedList JavaDoc();
46     List JavaDoc preProcessors = new LinkedList JavaDoc();
47     List JavaDoc responseModifiers;
48     List JavaDoc configs;
49     List JavaDoc modifiers;
50     Sampler sampler;
51
52     public SamplePackage()
53     {
54     }
55     
56     public SamplePackage(
57         List JavaDoc configs,
58         List JavaDoc modifiers,
59         List JavaDoc responseModifiers,
60         List JavaDoc listeners,
61         List JavaDoc timers,
62         List JavaDoc assertions,
63         List JavaDoc extractors,
64         List JavaDoc pres)
65     {
66         log.debug("configs is null: " + (configs == null));
67         this.configs = configs;
68         this.modifiers = modifiers;
69         this.responseModifiers = responseModifiers;
70         this.sampleListeners = listeners;
71         this.timers = timers;
72         this.assertions = assertions;
73         this.postProcessors = extractors;
74         this.preProcessors = pres;
75     }
76     
77     public void setRunningVersion(boolean running)
78     {
79         setRunningVersion(configs, running);
80         setRunningVersion(modifiers, running);
81         setRunningVersion(sampleListeners, running);
82         setRunningVersion(assertions, running);
83         setRunningVersion(timers, running);
84         setRunningVersion(responseModifiers, running);
85         setRunningVersion(postProcessors, running);
86         setRunningVersion(preProcessors, running);
87         sampler.setRunningVersion(running);
88     }
89         
90     private void setRunningVersion(List JavaDoc list,boolean running)
91     {
92         Iterator JavaDoc iter = list.iterator();
93         while (iter.hasNext())
94         {
95             ((TestElement) iter.next()).setRunningVersion(running);
96         }
97     }
98     
99     private void recoverRunningVersion(List JavaDoc list)
100     {
101         Iterator JavaDoc iter = list.iterator();
102         while (iter.hasNext())
103         {
104             ((TestElement) iter.next()).recoverRunningVersion();
105         }
106     }
107     
108     public void recoverRunningVersion()
109     {
110         recoverRunningVersion(configs);
111         recoverRunningVersion(modifiers);
112         recoverRunningVersion(sampleListeners);
113         recoverRunningVersion(assertions);
114         recoverRunningVersion(timers);
115         recoverRunningVersion(responseModifiers);
116         recoverRunningVersion(postProcessors);
117         recoverRunningVersion(preProcessors);
118         sampler.recoverRunningVersion();
119     }
120
121     public List JavaDoc getSampleListeners()
122     {
123         return sampleListeners;
124     }
125
126     public void addSampleListener(SampleListener listener)
127     {
128         sampleListeners.add(listener);
129     }
130
131     public List JavaDoc getTimers()
132     {
133         return timers;
134     }
135     
136     public void addPostProcessor(PostProcessor ex)
137     {
138         postProcessors.add(ex);
139     }
140     
141     public void addPreProcessor(PreProcessor pre)
142     {
143         preProcessors.add(pre);
144     }
145
146     public void addTimer(Timer timer)
147     {
148         timers.add(timer);
149     }
150
151     public void addAssertion(Assertion asser)
152     {
153         assertions.add(asser);
154     }
155
156     public List JavaDoc getAssertions()
157     {
158         return assertions;
159     }
160     
161     public List JavaDoc getPostProcessors()
162     {
163         return postProcessors;
164     }
165
166     public Sampler getSampler()
167     {
168         return sampler;
169     }
170
171     public void setSampler(Sampler s)
172     {
173         sampler = s;
174     }
175
176     /**
177      * Returns the preProcessors.
178      */

179     public List JavaDoc getPreProcessors()
180     {
181         return preProcessors;
182     }
183
184     /**
185      * Sets the preProcessors.
186      * @param preProcessors the preProcessors to set
187      */

188     public void setPreProcessors(List JavaDoc preProcessors)
189     {
190         this.preProcessors = preProcessors;
191     }
192
193     /**
194      * Returns the configs.
195      * @return List
196      */

197     public List JavaDoc getConfigs()
198     {
199         return configs;
200     }
201
202     /**
203      * Returns the modifiers.
204      */

205     public List JavaDoc getModifiers()
206     {
207         return modifiers;
208     }
209
210     /**
211      * Returns the responseModifiers.
212      */

213     public List JavaDoc getResponseModifiers()
214     {
215         return responseModifiers;
216     }
217
218     /**
219      * Sets the assertions.
220      * @param assertions the assertions to set
221      */

222     public void setAssertions(List JavaDoc assertions)
223     {
224         this.assertions = assertions;
225     }
226
227     /**
228      * Sets the configs.
229      * @param configs the configs to set
230      */

231     public void setConfigs(List JavaDoc configs)
232     {
233         this.configs = configs;
234     }
235
236     /**
237      * Sets the modifiers.
238      * @param modifiers the modifiers to set
239      */

240     public void setModifiers(List JavaDoc modifiers)
241     {
242         this.modifiers = modifiers;
243     }
244
245     /**
246      * Sets the postProcessors.
247      * @param postProcessors the postProcessors to set
248      */

249     public void setPostProcessors(List JavaDoc postProcessors)
250     {
251         this.postProcessors = postProcessors;
252     }
253
254     /**
255      * Sets the responseModifiers.
256      * @param responseModifiers the responseModifiers to set
257      */

258     public void setResponseModifiers(List JavaDoc responseModifiers)
259     {
260         this.responseModifiers = responseModifiers;
261     }
262
263     /**
264      * Sets the sampleListeners.
265      * @param sampleListeners the sampleListeners to set
266      */

267     public void setSampleListeners(List JavaDoc sampleListeners)
268     {
269         this.sampleListeners = sampleListeners;
270     }
271
272     /**
273      * Sets the timers.
274      * @param timers the timers to set
275      */

276     public void setTimers(List JavaDoc timers)
277     {
278         this.timers = timers;
279     }
280 }
Popular Tags