Coverage Report - org.apache.turbine.modules.PageLoader
 
Classes in this File Line Coverage Branch Coverage Complexity
PageLoader
90%
9/10
N/A
1
 
 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.Turbine;
 23  
 import org.apache.turbine.pipeline.PipelineData;
 24  
 
 25  
 /**
 26  
  * The purpose of this class is to allow one to load and execute Page
 27  
  * modules.
 28  
  *
 29  
  * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
 30  
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
 31  
  * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
 32  
  * @version $Id: PageLoader.java 1773378 2016-12-09 13:19:59Z tv $
 33  
  */
 34  0
 public class PageLoader
 35  
     extends GenericLoader<Page>
 36  
     implements Loader<Page>
 37  
 {
 38  
     /** The single instance of this class. */
 39  32
     private static PageLoader instance = new PageLoader();
 40  
 
 41  
     /**
 42  
      * These ctor's are private to force clients to use getInstance()
 43  
      * to access this class.
 44  
      */
 45  
     private PageLoader()
 46  
     {
 47  32
         super();
 48  32
     }
 49  
 
 50  
     /**
 51  
      * Attempts to load and execute the external page.
 52  
      *
 53  
      * @param pipelineData Turbine information.
 54  
      * @param name Name of object that will execute the page.
 55  
      * @throws Exception a generic exception.
 56  
      */
 57  
     @Override
 58  
     public void exec(PipelineData pipelineData, String name)
 59  
             throws Exception
 60  
     {
 61  
         // Execute page
 62  4
         getAssembler(name).build(pipelineData);
 63  2
     }
 64  
 
 65  
     /**
 66  
      * Pulls out an instance of the object by name.  Name is just the
 67  
      * single name of the object.
 68  
      *
 69  
      * @param name Name of object instance.
 70  
      * @return A Screen with the specified name, or null.
 71  
      * @throws Exception a generic exception.
 72  
      */
 73  
     @Override
 74  
     public Page getAssembler(String name)
 75  
         throws Exception
 76  
     {
 77  4
         return getAssembler(Page.class, name);
 78  
     }
 79  
 
 80  
     /**
 81  
      * @see org.apache.turbine.modules.Loader#getCacheSize()
 82  
      */
 83  
     @Override
 84  
     public int getCacheSize()
 85  
     {
 86  39
         return PageLoader.getConfiguredCacheSize();
 87  
     }
 88  
 
 89  
     /**
 90  
      * The method through which this class is accessed.
 91  
      *
 92  
      * @return The single instance of this class.
 93  
      */
 94  
     public static PageLoader getInstance()
 95  
     {
 96  69
         return instance;
 97  
     }
 98  
 
 99  
     /**
 100  
      * Helper method to get the configured cache size for this module
 101  
      *
 102  
      * @return the configure cache size
 103  
      */
 104  
     private static int getConfiguredCacheSize()
 105  
     {
 106  39
         return Turbine.getConfiguration().getInt(Page.CACHE_SIZE_KEY,
 107  
                 Page.CACHE_SIZE_DEFAULT);
 108  
     }
 109  
 }