/*
 * Copyright 2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

package org.apache.jmeter.protocol.http.sampler;

import org.apache.jmeter.util.JMeterUtils;

/**
 * Factory to return the appropriate HTTPSampler for use with classes that need
 * an HTTPSampler
 * 
 */
public class HTTPSamplerFactory {

	private static final String HTTP_SAMPLER = "HTTPSampler"; //$NON-NLS-1$

	private static final String HTTP_SAMPLER_APACHE = "HTTPSampler2"; //$NON-NLS-1$

	private static final String DEFAULT_CLASSNAME = JMeterUtils.getPropDefault("jmeter.httpsampler", HTTP_SAMPLER); //$NON-NLS-1$

	private HTTPSamplerFactory() {
		// Not intended to be instantiated
	}

	public static HTTPSamplerBase newInstance() {
		return newInstance(DEFAULT_CLASSNAME);
	}

	public static HTTPSamplerBase newInstance(String classname) {
		if (classname.equals(HTTP_SAMPLER)) {
			return new HTTPSampler();
		}
		if (classname.equals(HTTP_SAMPLER_APACHE)) {
			return new HTTPSampler2();
		}
		throw new UnsupportedOperationException("Cannot create class: " + classname);
	}
}

@@ -13,16 +13,21 @@
 ght 2005
+,2006
  The Apa
@@ -855,24 +855,79 @@
 tory %7B%0A%0A
-%09private
+    /** Use the the default Java HTTP implementation */%0A%09public
  static 
@@ -951,16 +951,21 @@
 _SAMPLER
+_JAVA
  = %22HTTP
@@ -985,32 +985,84 @@
 NON-NLS-1$%0A%0A
-%09private
+    /** Use Apache HTTPClient HTTP implementation */%0A%09public
  static fina
@@ -1125,22 +1125,21 @@
 S-1$%0A%0A%09p
-rivate
+ublic
  static 
@@ -1171,16 +1171,25 @@
 SNAME = 
+%0A        
 JMeterUt
@@ -1241,16 +1241,21 @@
 _SAMPLER
+_JAVA
 ); //$NO
@@ -1341,99 +1341,467 @@
 %09%7D%0A%0A
-%09public static HTTPSamplerBase newInstance() %7B%0A%09%09return newInstance(DEFAULT_CLASSNAME);%0A%09%7D%0A
+    /**%0A     * Create a new instance of the default sampler%0A     * %0A     * @return instance of default sampler%0A     */%0A%09public static HTTPSamplerBase newInstance() %7B%0A%09%09return newInstance(DEFAULT_CLASSNAME);%0A%09%7D%0A%0A    /**%0A     * Create a new instance of the required sampler type%0A     * %0A     * @param alias HTTP_SAMPLER or HTTP_SAMPLER_APACHE%0A     * @return the appropriate sampler%0A     * @throws UnsupportedOperationException if alias is not recognised%0A     */
 %0A%09pu
@@ -1847,25 +1847,21 @@
 (String 
-classname
+alias
 ) %7B%0A%09%09if
@@ -1858,33 +1858,29 @@
 as) %7B%0A%09%09if (
-classname
+alias
 .equals(HTTP
@@ -1887,16 +1887,21 @@
 _SAMPLER
+_JAVA
 )) %7B%0A%09%09%09
@@ -1936,25 +1936,21 @@
 %7D%0A%09%09if (
-classname
+alias
 .equals(
@@ -2079,17 +2079,13 @@
 %22 + 
-classname
+alias
 );%0A%09

Make alias names public