@@ -0,0 +1,3235 @@
+/*%0A * Copyright 2004-2005 The Apache Software Foundation or its licensors,%0A *                     as applicable.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.apache.jmeter.functions;%0A%0Aimport java.io.Serializable;%0Aimport java.util.Collection;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0A%0Aimport org.apache.commons.jexl.Expression;%0Aimport org.apache.commons.jexl.ExpressionFactory;%0Aimport org.apache.commons.jexl.JexlContext;%0Aimport org.apache.commons.jexl.JexlHelper;%0Aimport org.apache.jmeter.engine.util.CompoundVariable;%0Aimport org.apache.jmeter.samplers.SampleResult;%0Aimport org.apache.jmeter.samplers.Sampler;%0Aimport org.apache.jorphan.logging.LoggingManager;%0Aimport org.apache.log.Logger;%0A%0A/**%0A * A function which understands Commons JEXL%0A */%0Apublic class JexlFunction extends AbstractFunction implements Serializable%0A%7B%0A    /**%0A     * %3Ccode%3EserialVersionUID%3C/code%3E%0A     */%0A    private static final long serialVersionUID = 3546359539474968625L;%0A%0A    private static Logger log = LoggingManager.getLoggerForClass();%0A%0A    private static final String KEY = %22__jexl%22;%0A%0A    private static final List desc = new LinkedList();%0A%0A    static%0A    %7B%0A        desc.add(%22expression%22);%0A    %7D%0A%0A    private Object%5B%5D values;%0A%0A    public String execute(SampleResult result, Sampler sampler)%0A            throws InvalidVariableException%0A    %7B%0A        String str = %22%22;%0A%0A        CompoundVariable var = (CompoundVariable) values%5B0%5D;%0A        String exp = var.getRawParameters();%0A%0A        try%0A        %7B%0A            Expression e = ExpressionFactory.createExpression(exp);%0A            JexlContext jc = JexlHelper.createContext();%0A            jc.getVars().put(%22ctx%22, sampler.getThreadContext());%0A            jc.getVars().put(%22vars%22, getVariables());%0A            jc.getVars().put(%22theadName%22, sampler.getThreadName());%0A            jc.getVars().put(%22sampler%22, sampler);%0A            jc.getVars().put(%22sampleResult%22, result);%0A%0A            // Now evaluate the expression, getting the result%0A            Object o = e.evaluate(jc);%0A            if (o != null)%0A            %7B%0A                str = o.toString();%0A            %7D%0A        %7D catch (Exception e)%0A        %7B%0A            log.error(%22An error occurred while evaluating the expression %5C%22%22%0A                    + exp + %22%5C%22%22);%0A        %7D%0A        return str;%0A    %7D%0A%0A    public List getArgumentDesc()%0A    %7B%0A        return desc;%0A    %7D%0A%0A    public String getReferenceKey()%0A    %7B%0A        return KEY;%0A    %7D%0A%0A    public void setParameters(Collection parameters)%0A            throws InvalidVariableException%0A    %7B%0A        values = parameters.toArray();%0A        if (values.length != 1)%0A        %7B%0A            throw new InvalidVariableException(%22it only accepts one parameter%22);%0A        %7D%0A    %7D%0A%0A%7D

Add Jexl function TODO: update functions.xml/changes