    001    package org.apache.turbine.services.rundata;
    002
    003    /*
    004     * Licensed to the Apache Software Foundation (ASF) under one
    005     * or more contributor license agreements.  See the NOTICE file
    006     * distributed with this work for additional information
    007     * regarding copyright ownership.  The ASF licenses this file
    008     * to you under the Apache License, Version 2.0 (the
    009     * "License"); you may not use this file except in compliance
    010     * with the License.  You may obtain a copy of the License at
    011     *
    012     *   http://www.apache.org/licenses/LICENSE-2.0
    013     *
    014     * Unless required by applicable law or agreed to in writing,
    015     * software distributed under the License is distributed on an
    016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    017     * KIND, either express or implied.  See the License for the
    018     * specific language governing permissions and limitations
    019     * under the License.
    020     */
    021
    022    import javax.servlet.ServletConfig;
    023    import javax.servlet.http.HttpServletRequest;
    024    import javax.servlet.http.HttpServletResponse;
    025
    026    import org.apache.turbine.services.Service;
    027    import org.apache.turbine.util.RunData;
    028    import org.apache.turbine.util.TurbineException;
    029
    030    /**
    031     * The RunData Service provides the implementations for RunData and
    032     * related interfaces required by request processing. It supports
    033     * different configurations of implementations, which can be selected
    034     * by specifying a configuration key. It may use pooling, in which case
    035     * the implementations should implement the Recyclable interface.
    036     *
    037     * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
    038     * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
    039     * @version $Id: RunDataService.java 938645 2010-04-27 20:57:51Z tv $
    040     */
    041    public interface RunDataService
    042        extends Service
    043    {
    044        /** The key under which this service is stored in TurbineServices. */
    045        String SERVICE_NAME = "RunDataService";
    046
    047        /** The default parser configuration key. */
    048        String DEFAULT_CONFIG = "default";
    049
    050        /** The property for the implemention of the RunData object */
    051        String RUN_DATA_KEY = "run.data";
    052
    053        /** The property for the implemention of the ParameterParser. */
    054        String PARAMETER_PARSER_KEY = "parameter.parser";
    055
    056        /** The property for the implemention of the CookieParser. */
    057        String COOKIE_PARSER_KEY = "cookie.parser";
    058
    059        /**
    060         * Gets a default RunData object.
    061         *
    062         * @param req a servlet request.
    063         * @param res a servlet response.
    064         * @param config a servlet config.
    065         * @return a new or recycled RunData object.
    066         * @throws TurbineException if the operation fails.
    067         */
    068        RunData getRunData(HttpServletRequest req,
    069                           HttpServletResponse res,
    070                           ServletConfig config)
    071                throws TurbineException;
    072
    073        /**
    074         * Gets a RunData object from a specific configuration.
    075         *
    076         * @param key a configuration key.
    077         * @param req a servlet request.
    078         * @param res a servlet response.
    079         * @param config a servlet config.
    080         * @return a new or recycled RunData object.
    081         * @throws TurbineException if the operation fails.
    082         */
    083        RunData getRunData(String key,
    084                           HttpServletRequest req,
    085                           HttpServletResponse res,
    086                           ServletConfig config)
    087                throws TurbineException;
    088
    089        /**
    090         * Puts the used RunData object back to the factory for recycling.
    091         *
    092         * @param data the used RunData object.
    093         * @return true, if pooling is supported and the object was accepted.
    094         */
    095        boolean putRunData(RunData data);
    096    }