1 package org.apache.turbine.modules;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import java.util.Hashtable;
20
21 import org.apache.turbine.Turbine;
22 import org.apache.turbine.TurbineConstants;
23 import org.apache.turbine.util.RunData;
24
25 /***
26 * This is the base class for the loaders. It contains code that is
27 * used across all of the loaders. It also specifies the interface
28 * that is required to be called a Loader.
29 *
30 * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
31 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
32 * @version $Id: GenericLoader.java 264148 2005-08-29 14:21:04Z henning $
33 */
34 public abstract class GenericLoader
35 extends Hashtable
36 {
37 /*** @serial This can be serialized */
38 private boolean reload = false;
39
40 /*** @serial This can be serialized */
41 private boolean isCaching = true;
42
43 /**<Turbine *//package-summary/html">Base packages path for Turbine *//package-summary.html">em>* Turbine *//package-summary.html">Base packages path for Turbine */
44 private static final String TURBINE_PACKAGE = "org.apache.turbine.modules";
45
46 /***
47 * Basic constructor for creating a loader.
48 */
49 public GenericLoader()
50 {
51 super();
52 isCaching = Turbine.getConfiguration()
53 .getBoolean(TurbineConstants.MODULE_CACHE_KEY,
54 TurbineConstants.MODULE_CACHE_DEFAULT);
55 }
56
57 /***
58 * Basic constructor for creating a loader.
59 */
60 public GenericLoader(int i)
61 {
62 super(i);
63 isCaching = Turbine.getConfiguration()
64 .getBoolean(TurbineConstants.MODULE_CACHE_KEY,
65 TurbineConstants.MODULE_CACHE_DEFAULT);
66 }
67
68 /***
69 * If set to true, then cache the Loader objects.
70 *
71 * @return True if the Loader objects are being cached.
72 */
73 public boolean cache()
74 {
75 return this.isCaching;
76 }
77
78 /***
79 * Attempts to load and execute the external action that has been
80 * set.
81 *
82 * @exception Exception a generic exception.
83 */
84 public abstract void exec(RunData data, String name)
85 throws Exception;
86
87 /***
88 * Commented out.
89 * This method should return the complete classpath + name.
90 *
91 * @param name
92 * @return
93 *
94 public abstract String getClassName(String name);
95 */
96
97 /***
98 * Returns whether or not this external action is reload itself.
99 * This is in cases where the Next button would be clicked, but
100 * since we are checking for that, we would go into an endless
101 * loop.
102 *
103 * @return True if the action is reload.
104 */
105 public boolean reload()
106 {
107 return this.reload;
108 }
109
110 /***
111 * Sets whether or not this external action is reload itself.
112 * This is in cases where the Next button would be clicked, but
113 * since we are checking for that, we would go into an endless
114 * loop.
115 *
116 * @param reload True if the action must be marked as reload.
117 * @return Itself.
118 */
119 public GenericLoader setReload(boolean reload)
120 {
121 this.reload = reload;
122 return this;
123 }
124
125 /***
126 * Gets the base package where Turbine should find its default
127 * modules.
128 *
129 * @return A String with the base package name.
130 */
131 public static String getBasePackage()
132 {
133 return TURBINE_PACKAGE;
134 }
135 }