KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > protocol > java > config > JavaConfig


1 // $Header: /home/cvs/jakarta-jmeter/src/protocol/java/org/apache/jmeter/protocol/java/config/JavaConfig.java,v 1.12 2004/02/13 02:40:55 sebb Exp $
2
/*
3  * Copyright 2002-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.protocol.java.config;
20
21 import java.io.Serializable JavaDoc;
22
23 import org.apache.jmeter.config.Arguments;
24 import org.apache.jmeter.config.ConfigTestElement;
25 import org.apache.jmeter.protocol.java.sampler.JavaSampler;
26 import org.apache.jmeter.testelement.property.TestElementProperty;
27
28 /**
29  * The <code>JavaConfig</code> class contains the configuration data
30  * necessary for the Java protocol. This data is used to configure a
31  * {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerClient}
32  * instance to perform performance test samples.
33  *
34  * @author Brad Kiewel
35  * @author <a HREF="mailto:jeremy_a@bigfoot.com">Jeremy Arnold</a>
36  * @version $Revision: 1.12 $
37  */

38 public class JavaConfig extends ConfigTestElement implements Serializable JavaDoc
39 {
40     
41     /**
42      * Constructor for the JavaConfig object
43      */

44     public JavaConfig()
45     {
46         setArguments(new Arguments());
47     }
48
49     /**
50      * Sets the class name attribute of the JavaConfig object. This is the
51      * class name of the
52      * {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerClient}
53      * implementation which will be used to execute the test.
54      *
55      * @param classname the new classname value
56      */

57     public void setClassname(String JavaDoc classname)
58     {
59         setProperty(JavaSampler.CLASSNAME, classname);
60     }
61
62     /**
63      * Gets the class name attribute of the JavaConfig object. This is the
64      * class name of the
65      * {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerClient}
66      * implementation which will be used to execute the test.
67      *
68      * @return the classname value
69      */

70     public String JavaDoc getClassname()
71     {
72         return getPropertyAsString(JavaSampler.CLASSNAME);
73     }
74
75     /**
76      * Adds an argument to the list of arguments for this JavaConfig object.
77      * The {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerClient}
78      * implementation can access these arguments through the
79      * {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerContext}.
80      *
81      * @param name the name of the argument to be added
82      * @param value the value of the argument to be added
83      */

84     public void addArgument(String JavaDoc name, String JavaDoc value)
85     {
86         Arguments args = this.getArguments();
87         args.addArgument(name, value);
88     }
89
90     /**
91      * Removes all of the arguments associated with this JavaConfig object.
92      */

93     public void removeArguments()
94     {
95         setProperty(
96             new TestElementProperty(JavaSampler.ARGUMENTS, new Arguments()));
97     }
98
99     /**
100      * Set all of the arguments for this JavaConfig object. This will replace
101      * any previously added arguments. The
102      * {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerClient}
103      * implementation can access these arguments through the
104      * {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerContext}.
105      *
106      * @param args the new arguments
107      */

108     public void setArguments(Arguments args)
109     {
110         setProperty(new TestElementProperty(JavaSampler.ARGUMENTS, args));
111     }
112
113     /**
114      * Gets the arguments for this JavaConfig object. The
115      * {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerClient}
116      * implementation can access these arguments through the
117      * {@link org.apache.jmeter.protocol.java.sampler.JavaSamplerContext}.
118      *
119      * @return the arguments
120      */

121     public Arguments getArguments()
122     {
123         return (Arguments) getProperty(JavaSampler.ARGUMENTS).getObjectValue();
124     }
125 }
126
Popular Tags