001    // Copyright 2004, 2005 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    
015    package org.apache.tapestry;
016    
017    import java.util.Map;
018    
019    import org.apache.hivemind.Resource;
020    
021    /**
022     *  An object that can convert a set of symbols into a collection of JavaScript statements.
023     *
024     *  <p>IScript implementation must be threadsafe.
025     *
026     *  @author Howard Lewis Ship
027     *  @since 1.0.2
028     * 
029     **/
030    
031    public interface IScript
032    {
033        /**
034         *  Returns the location from which the script was loaded.
035         *
036         **/
037    
038        Resource getScriptResource();
039    
040        /**
041         * Executes the script, which will read and modify the symbols {@link Map}.  The
042         * script works with the {@link IScriptProcessor} to get the generated JavaScript
043         * included on the page.
044         * 
045         * @param cycle the current request cycle
046         * @param processor an object that processes the results of the script, typically
047         * an instance of {@link org.apache.tapestry.html.Body}
048         * @param symbols Map of input symbols; execution of the script may modify the map,
049         * creating new output symbols
050         * 
051         * @see TapestryUtils#getPageRenderSupport(IRequestCycle, IComponent)
052         * @deprecated To be removed in Tapestry 4.2. 
053         *              Use the new {@link #execute(IComponent, IRequestCycle, IScriptProcessor, Map)} method instead.
054         */
055    
056        void execute(IRequestCycle cycle, IScriptProcessor processor, Map symbols);
057        
058        /**
059         * Executes the script, which will read and modify the symbols {@link Map}.  The
060         * script works with the {@link IScriptProcessor} to get the generated JavaScript
061         * included on the page.
062         * 
063         * @param target The component this script is being executed by/for
064         * @param cycle the current request cycle
065         * @param processor an object that processes the results of the script, typically
066         * an instance of {@link org.apache.tapestry.html.Body}
067         * @param symbols Map of input symbols; execution of the script may modify the map,
068         * creating new output symbols
069         * 
070         * @see TapestryUtils#getPageRenderSupport(IRequestCycle, IComponent)
071         *
072         */
073    
074        void execute(IComponent target, IRequestCycle cycle, IScriptProcessor processor, Map symbols);
075    }