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