KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > protocol > java > sampler > AbstractJavaSamplerClient


1 // $Header: /home/cvs/jakarta-jmeter/src/protocol/java/org/apache/jmeter/protocol/java/sampler/AbstractJavaSamplerClient.java,v 1.6 2004/02/10 00:46:44 sebb Exp $
2
/*
3  * Copyright 2003-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.sampler;
20
21 import org.apache.jmeter.config.Arguments;
22 import org.apache.jorphan.logging.LoggingManager;
23 import org.apache.log.Logger;
24
25 /**
26  * An abstract implementation of the JavaSamplerClient interface.
27  * This implementation provides default implementations of most
28  * of the methods in the interface, as well as some convenience
29  * methods, in order to simplify development of JavaSamplerClient
30  * implementations.
31  * <p>
32  * See {@link org.apache.jmeter.protocol.java.test.SleepTest} for an
33  * example of how to extend this class.
34  * <p>
35  * While it may be necessary to make changes to the JavaSamplerClient
36  * interface from time to time (therefore requiring changes to any
37  * implementations of this interface), we intend to make this abstract
38  * class provide reasonable implementations of any new methods so that
39  * subclasses do not necessarily need to be updated for new versions.
40  * Therefore, when creating a new JavaSamplerClient implementation,
41  * developers are encouraged to subclass this abstract class rather
42  * than implementing the JavaSamplerClient interface directly.
43  * Implementing JavaSamplerClient directly will continue to be
44  * supported for cases where extending this class is not possible
45  * (for example, when the client class is already a subclass of some
46  * other class).
47  * <p>
48  * The runTest() method of JavaSamplerClient does not have a default
49  * implementation here, so subclasses must define at least this method.
50  * It may be useful to override other methods as well.
51  *
52  * @see JavaSamplerClient#runTest(JavaSamplerContext)
53  *
54  * @author <a HREF="mailto:jeremy_a@bigfoot.com">Jeremy Arnold</a>
55  * @version $Revision: 1.6 $
56  */

57 public abstract class AbstractJavaSamplerClient implements JavaSamplerClient
58 {
59     /**
60      * The Logger to be used by the Java protocol. This can be used
61      * by subclasses through the getLogger() method.
62      *
63      * @see #getLogger()
64      */

65     private static transient Logger log = LoggingManager.getLoggerForClass();
66
67     /* Implements JavaSamplerClient.setupTest(JavaSamplerContext) */
68     public void setupTest(JavaSamplerContext context)
69     {
70         log.debug(getClass().getName() + ": setupTest");
71     }
72
73     /* Implements JavaSamplerClient.teardownTest(JavaSamplerContext) */
74     public void teardownTest(JavaSamplerContext context)
75     {
76         log.debug(getClass().getName() + ": teardownTest");
77     }
78
79     /* Implements JavaSamplerClient.getDefaultParameters() */
80     public Arguments getDefaultParameters()
81     {
82         return null;
83     }
84
85     /**
86      * Get a Logger instance which can be used by subclasses to log
87      * information. This is the same Logger which is used by the base
88      * JavaSampler classes (jmeter.protocol.java).
89      *
90      * @return a Logger instance which can be used for logging
91      */

92     protected Logger getLogger()
93     {
94         return log;
95     }
96 }
97
Popular Tags