You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2008/02/03 18:12:03 UTC
svn commit: r618024 -
/jakarta/jmeter/trunk/src/core/org/apache/jmeter/functions/AbstractFunction.java
Author: sebb
Date: Sun Feb 3 09:11:58 2008
New Revision: 618024
URL: http://svn.apache.org/viewvc?rev=618024&view=rev
Log:
Document need to synch execute() and setParameters()
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/functions/AbstractFunction.java
Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/functions/AbstractFunction.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/functions/AbstractFunction.java?rev=618024&r1=618023&r2=618024&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/functions/AbstractFunction.java (original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/functions/AbstractFunction.java Sun Feb 3 09:11:58 2008
@@ -31,35 +31,44 @@
*/
public abstract class AbstractFunction implements Function {
- /**
- * @see Function#execute(SampleResult, Sampler)
- */
- abstract public String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException;
-
- public String execute() throws InvalidVariableException {
- JMeterContext context = JMeterContextService.getContext();
- SampleResult previousResult = context.getPreviousResult();
- Sampler currentSampler = context.getCurrentSampler();
- return execute(previousResult, currentSampler);
- }
-
- /**
- * @see Function#setParameters(Collection)
- * <br/>
+ /**
+ * <p><b>
+ * N.B. setParameters() and execute() are called from different threads,
+ * so both must be synchronized unless there are no parameters to save
+ * </b></p>
+ * @see Function#execute(SampleResult, Sampler)
+ */
+ abstract public String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException;
+
+ public String execute() throws InvalidVariableException {
+ JMeterContext context = JMeterContextService.getContext();
+ SampleResult previousResult = context.getPreviousResult();
+ Sampler currentSampler = context.getCurrentSampler();
+ return execute(previousResult, currentSampler);
+ }
+
+ /**
+ *
+ * <p><b>
+ * N.B. setParameters() and execute() are called from different threads,
+ * so both must be synchronized unless there are no parameters to save
+ * </b></p>
+ *
+ * @see Function#setParameters(Collection)
+ * <br/>
* Note: This is always called even if no parameters are provided
* (versions of JMeter after 2.3.1)
- *
- */
- abstract public void setParameters(Collection parameters) throws InvalidVariableException;
+ */
+ abstract public void setParameters(Collection parameters) throws InvalidVariableException;
- /**
- * @see Function#getReferenceKey()
- */
- abstract public String getReferenceKey();
-
- protected JMeterVariables getVariables() {
- return JMeterContextService.getContext().getVariables();
- }
+ /**
+ * @see Function#getReferenceKey()
+ */
+ abstract public String getReferenceKey();
+
+ protected JMeterVariables getVariables() {
+ return JMeterContextService.getContext().getVariables();
+ }
/**
* Utility method to check parameter counts.
@@ -76,12 +85,12 @@
int num = parameters.size();
if ((num > max) || (num < min)) {
throw new InvalidVariableException(
- getReferenceKey() +
+ getReferenceKey() +
" called with wrong number of parameters. Actual: "+num+
(
- min==max ?
- ". Expected: "+min+"."
- : ". Expected: >= "+min+" and <= "+max
+ min==max ?
+ ". Expected: "+min+"."
+ : ". Expected: >= "+min+" and <= "+max
)
);
}
@@ -101,7 +110,7 @@
int num = parameters.size();
if (num != count) {
throw new InvalidVariableException(
- getReferenceKey() +
+ getReferenceKey() +
" called with wrong number of parameters. Actual: "+num+". Expected: "+count+"."
);
}
@@ -121,7 +130,7 @@
int num = parameters.size();
if (num < minimum) {
throw new InvalidVariableException(
- getReferenceKey() +
+ getReferenceKey() +
" called with wrong number of parameters. Actual: "+num+". Expected at least: "+minimum+"."
);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org