001// Copyright 2013-2014 The Apache Software Foundation
002//
003// Licensed under the Apache License, Version 2.0 (the "License");
004// you may not use this file except in compliance with the License.
005// You may obtain a copy of the License at
006//
007// http://www.apache.org/licenses/LICENSE-2.0
008//
009// Unless required by applicable law or agreed to in writing, software
010// distributed under the License is distributed on an "AS IS" BASIS,
011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012// See the License for the specific language governing permissions and
013// limitations under the License.
014
015package org.apache.tapestry5.internal.webresources;
016
017import org.mozilla.javascript.ScriptableObject;
018
019public interface RhinoExecutor
020{
021    /**
022     * Invokes the named function, which must return a scriptable object (typically, a JavaScript Object).
023     *
024     * @param functionName
025     *         name of function visible to the executor's scope (e.g., loaded from the scripts associated
026     *         with the executor).
027     * @param arguments
028     *         Arguments to pass to the object which must be convertable to JavaScript types; Strings work well here.
029     * @return result of invoking the function.
030     */
031    ScriptableObject invokeFunction(String functionName, Object... arguments);
032
033    /**
034     * Discards the executor, returning it to the pool for reuse.
035     */
036    void discard();
037}