View Javadoc

1   package org.apache.turbine.modules;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.turbine.pipeline.PipelineData;
23  import org.apache.turbine.util.RunData;
24  
25  /**
26   * This is the base class that defines what a Page module is.
27   *
28   * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
29   * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
30   * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
31   * @version $Id: Page.java 717934 2008-11-15 21:48:47Z tv $
32   */
33  public abstract class Page
34      extends Assembler
35  {
36      /** Prefix for page related classes and templates */
37      public static final String PREFIX = "pages";
38      
39      /** Property for the size of the page cache if caching is on */
40      public static final String CACHE_SIZE_KEY = "page.cache.size";
41      
42      /** The default size for the page cache */
43      public static final int CACHE_SIZE_DEFAULT = 5;
44  
45      /** Represents Page Objects */
46      public static final String NAME = "page";
47  
48      /**
49       * @see org.apache.turbine.modules.Assembler#getPrefix()
50       */
51      public String getPrefix()
52      {
53          return PREFIX;
54      }
55  
56      /**
57       * A subclass must override this method to build itself.
58       * Subclasses override this method to store the page in RunData or
59       * to write the page to the output stream referenced in RunData.
60       * @deprecated Use <code>doBuild(PipelineData pipelineData)</code> instead
61       * @param data Turbine information.
62       * @exception Exception a generic exception.
63       */
64      protected abstract void doBuild(RunData data)
65          throws Exception;
66  
67  
68      /**
69       * A subclass must override this method to build itself.
70       * Subclasses override this method to store the page in RunData or
71       * to write the page to the output stream referenced in RunData.
72       * Should revert to abstract when RunData goes.
73       * @param data Turbine information.
74       * @exception Exception a generic exception.
75       */
76      protected void doBuild(PipelineData pipelineData)
77      	throws Exception
78      {
79          RunData data = getRunData(pipelineData);
80          doBuild(data);
81      }
82  
83      /**
84       * Subclasses can override this method to add additional
85       * functionality.  This method is protected to force clients to
86       * use PageLoader to build a Page.
87       * @deprecated Use <code>build(PipelineData)</code> instead.
88       * @param data Turbine information.
89       * @exception Exception a generic exception.
90       */
91      protected void build(RunData data)
92          throws Exception
93      {
94          doBuild(data);
95      }
96  
97  
98  
99      /**
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 }