JMeterContext jmctx = JMeterContextService.getContext();
JMeterVariables vars = jmctx.getVariables();
try
{
Script script = ScriptFactory.createScript(exp);
JexlContext jc = JexlHelper.createContext();
@SuppressWarnings("unchecked")
final Map<String, Object> jexlVars = jc.getVars();
jexlVars.put("log", log); //$NON-NLS-1$
jexlVars.put("ctx", jmctx); //$NON-NLS-1$
jexlVars.put("vars", vars); //$NON-NLS-1$
jexlVars.put("props", JMeterUtils.getJMeterProperties()); //$NON-NLS-1$
// Previously mis-spelt as theadName
jexlVars.put("threadName", Thread.currentThread().getName()); //$NON-NLS-1$
jexlVars.put("sampler", currentSampler); //$NON-NLS-1$ (may be null)
jexlVars.put("sampleResult", previousResult); //$NON-NLS-1$ (may be null)
jexlVars.put("OUT", System.out);//$NON-NLS-1$
// Now evaluate the script, getting the result
Object o = script.execute(jc);
if (o != null)
{
str = o.toString();
}
if (vars != null && varName.length() > 0) {// vars will be null on TestPlan