Coverage Report - org.apache.turbine.modules.NavigationLoader
 
Classes in this File Line Coverage Branch Coverage Complexity
NavigationLoader
57%
8/14
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.ecs.ConcreteElement;
 23  
 import org.apache.turbine.Turbine;
 24  
 import org.apache.turbine.pipeline.PipelineData;
 25  
 import org.apache.turbine.util.RunData;
 26  
 
 27  
 /**
 28  
  * The purpose of this class is to allow one to load and execute
 29  
  * Navigation modules.
 30  
  *
 31  
  * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
 32  
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
 33  
  * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
 34  
  * @version $Id: NavigationLoader.java 1078552 2011-03-06 19:58:46Z tv $
 35  
  */
 36  46
 public class NavigationLoader
 37  
     extends GenericLoader<Navigation>
 38  
     implements Loader<Navigation>
 39  
 {
 40  
     /** The single instance of this class. */
 41  58
     private static NavigationLoader instance = new NavigationLoader();
 42  
 
 43  
     /**
 44  
      * These ctor's are private to force clients to use getInstance()
 45  
      * to access this class.
 46  
      */
 47  
     private NavigationLoader()
 48  
     {
 49  58
         super();
 50  58
     }
 51  
 
 52  
     /**
 53  
      * Attempts to load and execute the external Navigation. This is
 54  
      * used when you want to execute a Navigation which returns its
 55  
      * output via a MultiPartElement instead of out the data.getPage()
 56  
      * value.  This allows you to easily chain the execution of
 57  
      * Navigation modules together.
 58  
      *
 59  
      * @deprecated Use PipelineData version instead.
 60  
      * @param data Turbine information.
 61  
      * @param name Name of object that will execute the navigation.
 62  
      * @exception Exception a generic exception.
 63  
      */
 64  
     @Deprecated
 65  
     public ConcreteElement eval(RunData data, String name)
 66  
             throws Exception
 67  
     {
 68  
         // Execute Navigation
 69  0
         return getAssembler(name).build(data);
 70  
     }
 71  
 
 72  
     /**
 73  
      * Attempts to load and execute the external Navigation. This is
 74  
      * used when you want to execute a Navigation which returns its
 75  
      * output via a MultiPartElement instead of out the data.getPage()
 76  
      * value.  This allows you to easily chain the execution of
 77  
      * Navigation modules together.
 78  
      *
 79  
      * @param data Turbine information.
 80  
      * @param name Name of object that will execute the navigation.
 81  
      * @exception Exception a generic exception.
 82  
      */
 83  
     public ConcreteElement eval(PipelineData pipelineData, String name)
 84  
             throws Exception
 85  
     {
 86  
         // Execute Navigation
 87  0
         return getAssembler(name).build(pipelineData);
 88  
     }
 89  
 
 90  
 
 91  
     /**
 92  
      * Attempts to load and execute the external Navigation.
 93  
      * @deprecated Use PipelineData version instead.
 94  
      * @param data Turbine information.
 95  
      * @param name Name of object instance.
 96  
      * @exception Exception a generic exception.
 97  
      */
 98  
     @Deprecated
 99  
     @Override
 100  
     public void exec(RunData data, String name)
 101  
             throws Exception
 102  
     {
 103  0
         this.eval(data, name);
 104  0
     }
 105  
 
 106  
     /**
 107  
      * Attempts to load and execute the external Navigation.
 108  
      *
 109  
      * @param pipelineData Turbine information.
 110  
      * @param name Name of object instance.
 111  
      * @exception Exception a generic exception.
 112  
      */
 113  
     @Override
 114  
     public void exec(PipelineData pipelineData, String name)
 115  
                     throws Exception
 116  
     {
 117  0
         this.eval(pipelineData, name);
 118  0
     }
 119  
 
 120  
 
 121  
     /**
 122  
      * Pulls out an instance of the object by name.  Name is just the
 123  
      * single name of the object. This is equal to getInstance but
 124  
      * returns an Assembler object and is needed to fulfil the Loader
 125  
      * interface.
 126  
      *
 127  
      * @param name Name of object instance.
 128  
      * @return A Layout with the specified name, or null.
 129  
      * @exception Exception a generic exception.
 130  
      */
 131  
     public Navigation getAssembler(String name)
 132  
         throws Exception
 133  
     {
 134  46
         return getAssembler(Navigation.NAME, name);
 135  
     }
 136  
 
 137  
     /**
 138  
      * @see org.apache.turbine.modules.Loader#getCacheSize()
 139  
      */
 140  
     public int getCacheSize()
 141  
     {
 142  188
         return NavigationLoader.getConfiguredCacheSize();
 143  
     }
 144  
 
 145  
     /**
 146  
      * The method through which this class is accessed.
 147  
      *
 148  
      * @return The single instance of this class.
 149  
      */
 150  
     public static NavigationLoader getInstance()
 151  
     {
 152  154
         return instance;
 153  
     }
 154  
 
 155  
     /**
 156  
      * Helper method to get the configured cache size for this module
 157  
      *
 158  
      * @return the configure cache size
 159  
      */
 160  
     private static int getConfiguredCacheSize()
 161  
     {
 162  188
         return Turbine.getConfiguration().getInt(Navigation.CACHE_SIZE_KEY,
 163  
                 Navigation.CACHE_SIZE_DEFAULT);
 164  
     }
 165  
 }