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
27 * Navigation 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$
33 */
34 public final class NavigationLoader
35 extends GenericLoader<Navigation>
36 {
37 /** The single instance of this class. */
38 private static NavigationLoader instance = new NavigationLoader();
39
40 /**
41 * These ctor's are private to force clients to use getInstance()
42 * to access this class.
43 */
44 private NavigationLoader()
45 {
46 super(Navigation.class,
47 () -> Turbine.getConfiguration().getInt(Navigation.CACHE_SIZE_KEY,
48 Navigation.CACHE_SIZE_DEFAULT));
49 }
50
51 /**
52 * Attempts to load and execute the external Navigation. This is
53 * used when you want to execute a Navigation which returns its
54 * output via a MultiPartElement instead of out the data.getPage()
55 * value. This allows you to easily chain the execution of
56 * Navigation modules together.
57 *
58 * @param pipelineData Turbine information.
59 * @param name Name of object that will execute the navigation.
60 * @return the navigation module output
61 * @throws Exception a generic exception.
62 */
63 public String eval(PipelineData pipelineData, String name)
64 throws Exception
65 {
66 // Execute Navigation
67 return getAssembler(name).build(pipelineData);
68 }
69
70 /**
71 * Attempts to load and execute the external Navigation.
72 *
73 * @param pipelineData Turbine information.
74 * @param name Name of object instance.
75 * @throws Exception a generic exception.
76 */
77 @Override
78 public void exec(PipelineData pipelineData, String name)
79 throws Exception
80 {
81 this.eval(pipelineData, name);
82 }
83
84 /**
85 * The method through which this class is accessed.
86 *
87 * @return The single instance of this class.
88 */
89 public static NavigationLoader getInstance()
90 {
91 return instance;
92 }
93 }