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.engine;
016    
017    /**
018     * Encapsulates the logic for encoding and decoding service requests.
019     * 
020     * @since 4.0
021     */
022    public interface ServiceEncoder
023    {
024    
025        /**
026         * Invoked by the {@link org.apache.tapestry.services.LinkFactory} to
027         * encode the request. Encoding is the process of modifying the encoding
028         * object to represent the same data in a different format; the canoncial
029         * example is to replace the
030         * {@link org.apache.tapestry.services.ServiceConstants#PAGE}and
031         * {@link org.apache.tapestry.services.ServiceConstants#SERVICE}query
032         * parameters with a servlet path (i.e., "/Home.html", if the ".html"
033         * extension is mapped to the page service).
034         * <p>
035         * The {@link org.apache.tapestry.services.LinkFactory}&nbsp;iterates over
036         * a collection of encoders, stopping once the ServiceRequestEncoding is
037         * modified in any way.
038         */
039    
040        void encode(ServiceEncoding encoding);
041    
042        /**
043         * Invoked to decode a request. The encoder is responsible for recognizing a
044         * request it may have encoded, and for restoring any query parameters is
045         * may have removed.
046         */
047    
048        void decode(ServiceEncoding encoding);
049    }