01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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.samplers;
20:
21: import org.apache.jmeter.util.JMeterUtils;
22: import org.apache.jmeter.samplers.StatisticalSampleSender;
23:
24: /**
25: * @author Michael Freeman
26: * 10/24/2005 - added statistical mode for distributed testing
27: */
28: public class SampleSenderFactory {
29: /**
30: * Checks for the Jmeter property mode and returns the required class.
31: *
32: * @param listener
33: * @return the appropriate class. Standard Jmeter functionality,
34: * hold_samples until end of test or batch samples.
35: */
36: static SampleSender getInstance(RemoteSampleListener listener) {
37: // Support original property name
38: boolean holdSamples = JMeterUtils.getPropDefault(
39: "hold_samples", false);
40:
41: // Extended property name
42: String type = JMeterUtils.getPropDefault("mode", "Standard");
43:
44: if (holdSamples || type.equalsIgnoreCase("Hold")) {
45: HoldSampleSender h = new HoldSampleSender(listener);
46: return h;
47: } else if (type.equalsIgnoreCase("Batch")) {
48: BatchSampleSender b = new BatchSampleSender(listener);
49: return b;
50: } else if (type.equalsIgnoreCase("Statistical")) {
51: StatisticalSampleSender s = new StatisticalSampleSender(
52: listener);
53: return s;
54: } else {
55: StandardSampleSender s = new StandardSampleSender(listener);
56: return s;
57: }
58: }
59: }
|