    001    package org.apache.turbine.modules;
    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 org.apache.turbine.pipeline.PipelineData;
    023    import org.apache.turbine.util.RunData;
    024
    025    /**
    026     * This is the base class that defines what a Page module is.
    027     *
    028     * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
    029     * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
    030     * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
    031     * @version $Id: Page.java 717934 2008-11-15 21:48:47Z tv $
    032     */
    033    public abstract class Page
    034        extends Assembler
    035    {
    036        /** Prefix for page related classes and templates */
    037        public static final String PREFIX = "pages";
    038
    039        /** Property for the size of the page cache if caching is on */
    040        public static final String CACHE_SIZE_KEY = "page.cache.size";
    041
    042        /** The default size for the page cache */
    043        public static final int CACHE_SIZE_DEFAULT = 5;
    044
    045        /** Represents Page Objects */
    046        public static final String NAME = "page";
    047
    048        /**
    049         * @see org.apache.turbine.modules.Assembler#getPrefix()
    050         */
    051        public String getPrefix()
    052        {
    053            return PREFIX;
    054        }
    055
    056        /**
    057         * A subclass must override this method to build itself.
    058         * Subclasses override this method to store the page in RunData or
    059         * to write the page to the output stream referenced in RunData.
    060         * @deprecated Use <code>doBuild(PipelineData pipelineData)</code> instead
    061         * @param data Turbine information.
    062         * @exception Exception a generic exception.
    063         */
    064        protected abstract void doBuild(RunData data)
    065            throws Exception;
    066
    067
    068        /**
    069         * A subclass must override this method to build itself.
    070         * Subclasses override this method to store the page in RunData or
    071         * to write the page to the output stream referenced in RunData.
    072         * Should revert to abstract when RunData goes.
    073         * @param data Turbine information.
    074         * @exception Exception a generic exception.
    075         */
    076        protected void doBuild(PipelineData pipelineData)
    077            throws Exception
    078        {
    079            RunData data = getRunData(pipelineData);
    080            doBuild(data);
    081        }
    082
    083        /**
    084         * Subclasses can override this method to add additional
    085         * functionality.  This method is protected to force clients to
    086         * use PageLoader to build a Page.
    087         * @deprecated Use <code>build(PipelineData)</code> instead.
    088         * @param data Turbine information.
    089         * @exception Exception a generic exception.
    090         */
    091        protected void build(RunData data)
    092            throws Exception
    093        {
    094            doBuild(data);
    095        }
    096
    097
    098
    099        /**
    100         * Subclasses can override this method to add additional
    101         * functionality.  This method is protected to force clients to
    102         * use PageLoader to build a Page.
    103         *
    104         * @param data Turbine information.
    105         * @exception Exception a generic exception.
    106         */
    107        protected void build(PipelineData pipelineData)
    108            throws Exception
    109        {
    110            doBuild(pipelineData);
    111        }
    112
    113    }