|
What this is
Other links
The source code// $Header: /home/cvs/jakarta-jmeter/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java,v 1.20 2004/02/10 00:46:44 sebb Exp $ /* * Copyright 2002-2004 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.java.sampler; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import org.apache.jmeter.config.Arguments; import org.apache.jmeter.engine.event.LoopIterationEvent; import org.apache.jmeter.samplers.AbstractSampler; import org.apache.jmeter.samplers.Entry; import org.apache.jmeter.samplers.SampleResult; import org.apache.jmeter.testelement.TestListener; import org.apache.jmeter.testelement.property.TestElementProperty; import org.apache.jorphan.logging.LoggingManager; import org.apache.log.Logger; /** * A sampler for executing custom Java code in each sample. See * {@link JavaSamplerClient} and {@link AbstractJavaSamplerClient} for * information on writing Java code to be executed by this sampler. * * @author Jeremy Arnold * @version $Revision: 1.20 $ */ public class JavaSampler extends AbstractSampler implements TestListener { /** * Property key representing the classname of the JavaSamplerClient to * user. */ public static final String CLASSNAME = "classname"; /** * Property key representing the arguments for the JavaSamplerClient. */ public static final String ARGUMENTS = "arguments"; /** * The JavaSamplerClient instance used by this sampler to actually perform * the sample. */ private transient JavaSamplerClient javaClient = null; /** * The JavaSamplerContext instance used by this sampler to hold * information related to the test run, such as the parameters * specified for the sampler client. */ private transient JavaSamplerContext context = null; /** * Logging */ private static transient Logger log = LoggingManager.getLoggerForClass(); /** * Set used to register all active JavaSamplers. This is used so that the * samplers can be notified when the test ends. */ private static Set allSamplers = new HashSet(); /** * Create a JavaSampler. */ public JavaSampler() { setArguments(new Arguments()); synchronized (allSamplers) { allSamplers.add(this); } } /** * Set the arguments (parameters) for the JavaSamplerClient to be executed * with. * * @param args the new arguments. These replace any existing arguments. */ public void setArguments(Arguments args) { setProperty(new TestElementProperty(ARGUMENTS, args)); } /** * Get the arguments (parameters) for the JavaSamplerClient to be executed * with. * * @return the arguments */ public Arguments getArguments() { return (Arguments) getProperty(ARGUMENTS).getObjectValue(); } /** * Releases Java Client. */ private void releaseJavaClient () { if (javaClient != null) { javaClient.teardownTest(context); } javaClient = null; context = null; } /** * Sets the Classname attribute of the JavaConfig object * * @param classname the new Classname value */ public void setClassname(String classname) { setProperty(CLASSNAME, classname); } /** * Gets the Classname attribute of the JavaConfig object * * @return the Classname value */ public String getClassname() { return getPropertyAsString(CLASSNAME); } /** * Performs a test sample. * * The |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.