001: package org.apache.turbine.modules;
002:
003: /*
004: * Copyright 2001-2005 The Apache Software Foundation.
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License")
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: import java.util.Hashtable;
020:
021: import org.apache.turbine.Turbine;
022: import org.apache.turbine.TurbineConstants;
023: import org.apache.turbine.util.RunData;
024:
025: /**
026: * This is the base class for the loaders. It contains code that is
027: * used across all of the loaders. It also specifies the interface
028: * that is required to be called a Loader.
029: *
030: * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
031: * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
032: * @version $Id: GenericLoader.java 264148 2005-08-29 14:21:04Z henning $
033: */
034: public abstract class GenericLoader extends Hashtable {
035: /** @serial This can be serialized */
036: private boolean reload = false;
037:
038: /** @serial This can be serialized */
039: private boolean isCaching = true;
040:
041: /** Base packages path for Turbine */
042: private static final String TURBINE_PACKAGE = "org.apache.turbine.modules";
043:
044: /**
045: * Basic constructor for creating a loader.
046: */
047: public GenericLoader() {
048: super ();
049: isCaching = Turbine.getConfiguration().getBoolean(
050: TurbineConstants.MODULE_CACHE_KEY,
051: TurbineConstants.MODULE_CACHE_DEFAULT);
052: }
053:
054: /**
055: * Basic constructor for creating a loader.
056: */
057: public GenericLoader(int i) {
058: super (i);
059: isCaching = Turbine.getConfiguration().getBoolean(
060: TurbineConstants.MODULE_CACHE_KEY,
061: TurbineConstants.MODULE_CACHE_DEFAULT);
062: }
063:
064: /**
065: * If set to true, then cache the Loader objects.
066: *
067: * @return True if the Loader objects are being cached.
068: */
069: public boolean cache() {
070: return this .isCaching;
071: }
072:
073: /**
074: * Attempts to load and execute the external action that has been
075: * set.
076: *
077: * @exception Exception a generic exception.
078: */
079: public abstract void exec(RunData data, String name)
080: throws Exception;
081:
082: /**
083: * Commented out.
084: * This method should return the complete classpath + name.
085: *
086: * @param name
087: * @return
088: *
089: public abstract String getClassName(String name);
090: */
091:
092: /**
093: * Returns whether or not this external action is reload itself.
094: * This is in cases where the Next button would be clicked, but
095: * since we are checking for that, we would go into an endless
096: * loop.
097: *
098: * @return True if the action is reload.
099: */
100: public boolean reload() {
101: return this .reload;
102: }
103:
104: /**
105: * Sets whether or not this external action is reload itself.
106: * This is in cases where the Next button would be clicked, but
107: * since we are checking for that, we would go into an endless
108: * loop.
109: *
110: * @param reload True if the action must be marked as reload.
111: * @return Itself.
112: */
113: public GenericLoader setReload(boolean reload) {
114: this .reload = reload;
115: return this ;
116: }
117:
118: /**
119: * Gets the base package where Turbine should find its default
120: * modules.
121: *
122: * @return A String with the base package name.
123: */
124: public static String getBasePackage() {
125: return TURBINE_PACKAGE;
126: }
127: }
|