    001package 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
    022import org.apache.turbine.pipeline.PipelineData;
    023
    024/**
    025 * This is the base class that defines what a Page module is.
    026 *
    027 * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
    028 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
    029 * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
    030 * @version $Id: Page.java 1773378 2016-12-09 13:19:59Z tv $
    031 */
    032public abstract class Page
    033    extends Assembler
    034{
    035    /** Prefix for page related classes and templates */
    036    public static final String PREFIX = "pages";
    037
    038    /** Property for the size of the page cache if caching is on */
    039    public static final String CACHE_SIZE_KEY = "page.cache.size";
    040
    041    /** The default size for the page cache */
    042    public static final int CACHE_SIZE_DEFAULT = 5;
    043
    044    /** Represents Page Objects */
    045    public static final String NAME = "page";
    046
    047    /**
    048     * @see org.apache.turbine.modules.Assembler#getPrefix()
    049     */
    050    @Override
    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 PipelineData or
    059     * to write the page to the output stream referenced in PipelineData.
    060     * @param pipelineData Turbine information.
    061     * @throws Exception a generic exception.
    062     */
    063    protected abstract void doBuild(PipelineData pipelineData) throws Exception;
    064
    065    /**
    066     * Subclasses can override this method to add additional
    067     * functionality.  This method is protected to force clients to
    068     * use PageLoader to build a Page.
    069     *
    070     * @param pipelineData Turbine information.
    071     * @throws Exception a generic exception.
    072     */
    073    protected void build(PipelineData pipelineData)
    074        throws Exception
    075    {
    076        doBuild(pipelineData);
    077    }
    078}