001/* 002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Mariana Cedica 016 */ 017package org.nuxeo.ecm.platform.routing.core.api.scripting; 018 019import java.util.Map; 020 021import org.nuxeo.ecm.automation.OperationContext; 022import org.nuxeo.ecm.automation.core.scripting.MvelExpression; 023import org.nuxeo.ecm.automation.core.scripting.Scripting; 024 025/** 026 * Overrides the MVELExpression to add specific helpers depending on the context 027 * 028 * @5.9.3 029 */ 030public class RoutingScriptingExpression extends MvelExpression { 031 032 private static final long serialVersionUID = 1L; 033 034 protected RoutingScriptingFunctions fn; 035 036 public RoutingScriptingExpression(String expr) { 037 super(expr); 038 } 039 040 public RoutingScriptingExpression(String expr, RoutingScriptingFunctions fn) { 041 super(expr); 042 this.fn = fn; 043 } 044 045 @Override 046 protected Map<String, Object> getBindings(OperationContext ctx) { 047 Map<String, Object> bindings = Scripting.initBindings(ctx); 048 if (fn != null) { 049 bindings.put(RoutingScriptingFunctions.BINDING_KEY, fn); 050 } 051 return bindings; 052 } 053}