001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.jmeter.protocol.java.config;
020:
021: import java.io.Serializable;
022:
023: import org.apache.jmeter.config.Arguments;
024: import org.apache.jmeter.config.ConfigTestElement;
025: import org.apache.jmeter.protocol.java.sampler.JavaSampler;
026: import org.apache.jmeter.testelement.property.TestElementProperty;
027:
028: /**
029: * The <code>JavaConfig</code> class contains the configuration data necessary
030: * for the Java protocol. This data is used to configure a
031: * {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerClient} instance to
032: * perform performance test samples.
033: *
034: * @author Brad Kiewel
035: * @author <a href="mailto:jeremy_a@bigfoot.com">Jeremy Arnold</a>
036: * @version $Revision: 493789 $
037: */
038: public class JavaConfig extends ConfigTestElement implements
039: Serializable {
040:
041: /**
042: * Constructor for the JavaConfig object
043: */
044: public JavaConfig() {
045: setArguments(new Arguments());
046: }
047:
048: /**
049: * Sets the class name attribute of the JavaConfig object. This is the class
050: * name of the
051: * {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerClient}
052: * implementation which will be used to execute the test.
053: *
054: * @param classname
055: * the new classname value
056: */
057: public void setClassname(String classname) {
058: setProperty(JavaSampler.CLASSNAME, classname);
059: }
060:
061: /**
062: * Gets the class name attribute of the JavaConfig object. This is the class
063: * name of the
064: * {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerClient}
065: * implementation which will be used to execute the test.
066: *
067: * @return the classname value
068: */
069: public String getClassname() {
070: return getPropertyAsString(JavaSampler.CLASSNAME);
071: }
072:
073: /**
074: * Adds an argument to the list of arguments for this JavaConfig object. The
075: * {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerClient}
076: * implementation can access these arguments through the
077: * {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerContext}.
078: *
079: * @param name
080: * the name of the argument to be added
081: * @param value
082: * the value of the argument to be added
083: */
084: public void addArgument(String name, String value) {
085: Arguments args = this .getArguments();
086: args.addArgument(name, value);
087: }
088:
089: /**
090: * Removes all of the arguments associated with this JavaConfig object.
091: */
092: public void removeArguments() {
093: setProperty(new TestElementProperty(JavaSampler.ARGUMENTS,
094: new Arguments()));
095: }
096:
097: /**
098: * Set all of the arguments for this JavaConfig object. This will replace
099: * any previously added arguments. The
100: * {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerClient}
101: * implementation can access these arguments through the
102: * {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerContext}.
103: *
104: * @param args
105: * the new arguments
106: */
107: public void setArguments(Arguments args) {
108: setProperty(new TestElementProperty(JavaSampler.ARGUMENTS, args));
109: }
110:
111: /**
112: * Gets the arguments for this JavaConfig object. The
113: * {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerClient}
114: * implementation can access these arguments through the
115: * {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerContext}.
116: *
117: * @return the arguments
118: */
119: public Arguments getArguments() {
120: return (Arguments) getProperty(JavaSampler.ARGUMENTS)
121: .getObjectValue();
122: }
123: }
|