You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by he...@apache.org on 2003/02/28 14:13:49 UTC
cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/modules ActionLoader.java Assembler.java GenericLoader.java LayoutLoader.java NavigationLoader.java PageLoader.java ScreenLoader.java
henning 2003/02/28 05:13:48
Modified: src/java/org/apache/turbine TurbineConstants.java
src/java/org/apache/turbine/modules ActionLoader.java
Assembler.java GenericLoader.java LayoutLoader.java
NavigationLoader.java PageLoader.java
ScreenLoader.java
Log:
Removed Usage of the TurbineResources, replaced "magic numbers" with
constants, adding them to TurbineConstants.
Revision Changes Path
1.12 +36 -41 jakarta-turbine-2/src/java/org/apache/turbine/TurbineConstants.java
Index: TurbineConstants.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/TurbineConstants.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- TurbineConstants.java 27 Feb 2003 15:40:00 -0000 1.11
+++ TurbineConstants.java 28 Feb 2003 13:13:48 -0000 1.12
@@ -85,57 +85,52 @@
/** This is the default log file to be used for logging */
String DEFAULT_LOGGER = "turbine";
- /**
- * The logging facility which captures output from the SchedulerService.
- */
+ /** The logging facility which captures output from the SchedulerService. */
String SCHEDULER_LOG_FACILITY = "scheduler";
- /**
- * SMTP server Turbine uses to send mail.
- */
+ /** The SMTP server Turbine uses to send mail. */
String MAIL_SERVER_KEY = "mail.server";
- /**
- * Property that controls whether Turbine modules are
- * cached or not.
- */
- String MODULE_CACHE = "module.cache";
-
- /**
- * The size of the actions cache if module caching is on.
- */
- String ACTION_CACHE_SIZE = "action.cache.size";
-
- /**
- * The size of the layout cache if module caching is on.
- */
- String LAYOUT_CACHE_SIZE = "layout.cache.size";
-
- /**
- * The size of the navigation cache if module caching is on.
- */
- String NAVIGATION_CACHE_SIZE = "navigation.cache.size";
-
- /**
- * The size of the actions page if module caching is on.
- */
- String PAGE_CACHE_SIZE = "page.cache.size";
-
- /**
- * The size of the actions cache if module caching is on.
- */
- String SCREEN_CACHE_SIZE = "screen.cache.size";
-
- /**
- * The size of the actions cache if module caching is on.
- */
- String SCHEDULED_JOB_CACHE_SIZE =
- "scheduledjob.cache.size";
-
- /**
- * The packages where Turbine will look for modules.
- * This is effectively Turbine's classpath.
- */
+ /** Property that controls whether Turbine modules are cached or not. */
+ String MODULE_CACHE_KEY = "module.cache";
+
+ /** Default value of the Turbine Module Caching */
+ boolean MODULE_CACHE_DEFAULT = true;
+
+ /** Property for the size of the action cache if caching is on */
+ String ACTION_CACHE_SIZE_KEY = "action.cache.size";
+
+ /** The default size for the action cache */
+ int ACTION_CACHE_SIZE_DEFAULT = 20;
+
+ /** Property for the size of the layout cache if caching is on */
+ String LAYOUT_CACHE_SIZE_KEY = "layout.cache.size";
+
+ /** The default size for the layout cache */
+ int LAYOUT_CACHE_SIZE_DEFAULT = 10;
+
+ /** Property for the size of the navigation cache if caching is on */
+ String NAVIGATION_CACHE_SIZE_KEY = "navigation.cache.size";
+
+ /** The default size for the navigation cache */
+ int NAVIGATION_CACHE_SIZE_DEFAULT = 10;
+
+ /** Property for the size of the page cache if caching is on */
+ String PAGE_CACHE_SIZE_KEY = "page.cache.size";
+
+ /** The default size for the page cache */
+ int PAGE_CACHE_SIZE_DEFAULT = 5;
+
+ /** Property for the size of the screen cache if caching is on */
+ String SCREEN_CACHE_SIZE_KEY = "screen.cache.size";
+
+ /** The default size for the screen cache */
+ int SCREEN_CACHE_SIZE_DEFAULT = 50;
+
+ /** The size of the schedulder job cache if module caching is on. */
+ String SCHEDULED_JOB_CACHE_SIZE = "scheduledjob.cache.size";
+
+ /** The packages where Turbine will look for modules. */
String MODULE_PACKAGES = "module.packages";
/** Home page template. */
1.4 +12 -4 jakarta-turbine-2/src/java/org/apache/turbine/modules/ActionLoader.java
Index: ActionLoader.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/ActionLoader.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ActionLoader.java 12 Feb 2003 17:52:15 -0000 1.3
+++ ActionLoader.java 28 Feb 2003 13:13:48 -0000 1.4
@@ -56,10 +56,15 @@
import java.util.Vector;
+import org.apache.turbine.Turbine;
import org.apache.turbine.TurbineConstants;
+
import org.apache.turbine.services.TurbineServices;
+
import org.apache.turbine.services.assemblerbroker.AssemblerBrokerService;
+
import org.apache.turbine.services.resources.TurbineResources;
+
import org.apache.turbine.util.ObjectUtils;
import org.apache.turbine.util.RunData;
@@ -68,13 +73,15 @@
* Action modules.
*
* @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
+ * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
* @version $Id$
*/
public class ActionLoader extends GenericLoader
{
/** The single instance of this class. */
private static ActionLoader instance = new ActionLoader(
- TurbineResources.getInt(TurbineConstants.ACTION_CACHE_SIZE, 20));
+ Turbine.getConfiguration().getInt(TurbineConstants.ACTION_CACHE_SIZE_KEY,
+ TurbineConstants.ACTION_CACHE_SIZE_DEFAULT));
/**
* These ctor's are private to force clients to use getInstance()
@@ -166,8 +173,9 @@
// the user a reason for that...
// FIX ME: The AssemblerFactories should each add it's own
// string here...
- Vector packages = TurbineResources.getVector(
- TurbineConstants.MODULE_PACKAGES);
+ Vector packages = Turbine.getConfiguration()
+ .getVector(TurbineConstants.MODULE_PACKAGES);
+
ObjectUtils.addOnce(packages,
GenericLoader.getBasePackage());
1.3 +5 -5 jakarta-turbine-2/src/java/org/apache/turbine/modules/Assembler.java
Index: Assembler.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/Assembler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Assembler.java 12 Feb 2003 17:52:15 -0000 1.2
+++ Assembler.java 28 Feb 2003 13:13:48 -0000 1.3
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
1.5 +11 -7 jakarta-turbine-2/src/java/org/apache/turbine/modules/GenericLoader.java
Index: GenericLoader.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/GenericLoader.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- GenericLoader.java 12 Feb 2003 17:52:15 -0000 1.4
+++ GenericLoader.java 28 Feb 2003 13:13:48 -0000 1.5
@@ -56,8 +56,9 @@
import java.util.Hashtable;
+import org.apache.turbine.Turbine;
import org.apache.turbine.TurbineConstants;
-import org.apache.turbine.services.resources.TurbineResources;
+
import org.apache.turbine.util.RunData;
/**
@@ -69,7 +70,8 @@
* @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
* @version $Id$
*/
-public abstract class GenericLoader extends Hashtable
+public abstract class GenericLoader
+ extends Hashtable
{
/** @serial This can be serialized */
private boolean reload = false;
@@ -84,8 +86,9 @@
public GenericLoader()
{
super();
- isCaching = TurbineResources
- .getBoolean(TurbineConstants.MODULE_CACHE, true);
+ isCaching = Turbine.getConfiguration()
+ .getBoolean(TurbineConstants.MODULE_CACHE_KEY,
+ TurbineConstants.MODULE_CACHE_DEFAULT);
}
/**
@@ -94,8 +97,9 @@
public GenericLoader(int i)
{
super(i);
- isCaching = TurbineResources
- .getBoolean(TurbineConstants.MODULE_CACHE, true);
+ isCaching = Turbine.getConfiguration()
+ .getBoolean(TurbineConstants.MODULE_CACHE_KEY,
+ TurbineConstants.MODULE_CACHE_DEFAULT);
}
/**
1.4 +15 -7 jakarta-turbine-2/src/java/org/apache/turbine/modules/LayoutLoader.java
Index: LayoutLoader.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/LayoutLoader.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LayoutLoader.java 12 Feb 2003 17:52:15 -0000 1.3
+++ LayoutLoader.java 28 Feb 2003 13:13:48 -0000 1.4
@@ -56,10 +56,13 @@
import java.util.Vector;
+import org.apache.turbine.Turbine;
import org.apache.turbine.TurbineConstants;
+
import org.apache.turbine.services.TurbineServices;
+
import org.apache.turbine.services.assemblerbroker.AssemblerBrokerService;
-import org.apache.turbine.services.resources.TurbineResources;
+
import org.apache.turbine.util.ObjectUtils;
import org.apache.turbine.util.RunData;
@@ -68,13 +71,17 @@
* Layout modules.
*
* @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
+ * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
* @version $Id$
*/
-public class LayoutLoader extends GenericLoader
+public class LayoutLoader
+ extends GenericLoader
{
/** The single instance of this class. */
- private static LayoutLoader instance = new LayoutLoader(
- TurbineResources.getInt(TurbineConstants.LAYOUT_CACHE_SIZE, 10));
+ private static LayoutLoader instance =
+ new LayoutLoader(Turbine.getConfiguration()
+ .getInt(TurbineConstants.LAYOUT_CACHE_SIZE_KEY,
+ TurbineConstants.LAYOUT_CACHE_SIZE_DEFAULT));
/**
* These ctor's are private to force clients to use getInstance()
@@ -164,8 +171,9 @@
// the user a reason for that...
// FIX ME: The AssemblerFactories should each add it's own
// string here...
- Vector packages = TurbineResources.getVector(
- TurbineConstants.MODULE_PACKAGES);
+ Vector packages = Turbine.getConfiguration()
+ .getVector(TurbineConstants.MODULE_PACKAGES);
+
ObjectUtils.addOnce(packages,
GenericLoader.getBasePackage());
1.4 +16 -7 jakarta-turbine-2/src/java/org/apache/turbine/modules/NavigationLoader.java
Index: NavigationLoader.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/NavigationLoader.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NavigationLoader.java 12 Feb 2003 17:52:15 -0000 1.3
+++ NavigationLoader.java 28 Feb 2003 13:13:48 -0000 1.4
@@ -57,10 +57,14 @@
import java.util.Vector;
import org.apache.ecs.ConcreteElement;
+
+import org.apache.turbine.Turbine;
import org.apache.turbine.TurbineConstants;
+
import org.apache.turbine.services.TurbineServices;
+
import org.apache.turbine.services.assemblerbroker.AssemblerBrokerService;
-import org.apache.turbine.services.resources.TurbineResources;
+
import org.apache.turbine.util.ObjectUtils;
import org.apache.turbine.util.RunData;
@@ -69,13 +73,17 @@
* Navigation modules.
*
* @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
+ * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
* @version $Id$
*/
-public class NavigationLoader extends GenericLoader
+public class NavigationLoader
+ extends GenericLoader
{
/** The single instance of this class. */
- private static NavigationLoader instance = new NavigationLoader(
- TurbineResources.getInt(TurbineConstants.NAVIGATION_CACHE_SIZE, 10));
+ private static NavigationLoader instance =
+ new NavigationLoader(Turbine.getConfiguration()
+ .getInt(TurbineConstants.NAVIGATION_CACHE_SIZE_KEY,
+ TurbineConstants.NAVIGATION_CACHE_SIZE_DEFAULT));
/**
* These ctor's are private to force clients to use getInstance()
@@ -184,8 +192,9 @@
// the user a reason for that...
// FIX ME: The AssemblerFactories should each add it's own
// string here...
- Vector packages = TurbineResources.getVector(
- TurbineConstants.MODULE_PACKAGES);
+ Vector packages = Turbine.getConfiguration()
+ .getVector(TurbineConstants.MODULE_PACKAGES);
+
ObjectUtils.addOnce(packages,
GenericLoader.getBasePackage());
1.4 +13 -6 jakarta-turbine-2/src/java/org/apache/turbine/modules/PageLoader.java
Index: PageLoader.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/PageLoader.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PageLoader.java 12 Feb 2003 17:52:15 -0000 1.3
+++ PageLoader.java 28 Feb 2003 13:13:48 -0000 1.4
@@ -56,10 +56,13 @@
import java.util.Vector;
+import org.apache.turbine.Turbine;
import org.apache.turbine.TurbineConstants;
+
import org.apache.turbine.services.TurbineServices;
+
import org.apache.turbine.services.assemblerbroker.AssemblerBrokerService;
-import org.apache.turbine.services.resources.TurbineResources;
+
import org.apache.turbine.util.ObjectUtils;
import org.apache.turbine.util.RunData;
@@ -68,13 +71,16 @@
* modules.
*
* @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
+ * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
* @version $Id$
*/
public class PageLoader extends GenericLoader
{
/** The single instance of this class. */
- private static PageLoader instance = new PageLoader(
- TurbineResources.getInt(TurbineConstants.PAGE_CACHE_SIZE, 5));
+ private static PageLoader instance =
+ new PageLoader(Turbine.getConfiguration()
+ .getInt(TurbineConstants.PAGE_CACHE_SIZE_KEY,
+ TurbineConstants.PAGE_CACHE_SIZE_DEFAULT));
/**
* These ctor's are private to force clients to use getInstance()
@@ -166,8 +172,9 @@
// the user a reason for that...
// FIX ME: The AssemblerFactories should each add
// it's own string here...
- Vector packages = TurbineResources.getVector(
- TurbineConstants.MODULE_PACKAGES);
+ Vector packages = Turbine.getConfiguration()
+ .getVector(TurbineConstants.MODULE_PACKAGES);
+
ObjectUtils.addOnce(packages,
GenericLoader.getBasePackage());
1.5 +34 -14 jakarta-turbine-2/src/java/org/apache/turbine/modules/ScreenLoader.java
Index: ScreenLoader.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/ScreenLoader.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ScreenLoader.java 12 Feb 2003 17:52:15 -0000 1.4
+++ ScreenLoader.java 28 Feb 2003 13:13:48 -0000 1.5
@@ -56,11 +56,18 @@
import java.util.Vector;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.apache.ecs.ConcreteElement;
+
+import org.apache.turbine.Turbine;
import org.apache.turbine.TurbineConstants;
+
import org.apache.turbine.services.TurbineServices;
+
import org.apache.turbine.services.assemblerbroker.AssemblerBrokerService;
-import org.apache.turbine.services.resources.TurbineResources;
+
import org.apache.turbine.util.ObjectUtils;
import org.apache.turbine.util.RunData;
@@ -72,11 +79,22 @@
* @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
* @version $Id$
*/
-public class ScreenLoader extends GenericLoader
+public class ScreenLoader
+ extends GenericLoader
{
+ /** Logging */
+ private static Log log = LogFactory.getLog(ScreenLoader.class);
+
/** The single instance of this class. */
- private static ScreenLoader instance = new ScreenLoader(
- TurbineResources.getInt(TurbineConstants.SCREEN_CACHE_SIZE, 50));
+ private static ScreenLoader instance =
+ new ScreenLoader(Turbine.getConfiguration()
+ .getInt(TurbineConstants.SCREEN_CACHE_SIZE_KEY,
+ TurbineConstants.SCREEN_CACHE_SIZE_DEFAULT));
+
+ /** The Assembler Broker Service */
+ private static AssemblerBrokerService ab =
+ (AssemblerBrokerService) TurbineServices.getInstance()
+ .getService(AssemblerBrokerService.SERVICE_NAME);
/**
* These ctor's are private to force clients to use getInstance()
@@ -160,19 +178,20 @@
if (cache() && this.containsKey(name))
{
screen = (Screen) this.get(name);
+ log.debug("Found " + name + " in the cache!");
}
else
{
- // We get the broker service
- AssemblerBrokerService ab =
- (AssemblerBrokerService) TurbineServices.getInstance()
- .getService(AssemblerBrokerService.SERVICE_NAME);
+ log.debug("Loading Screen " + name + " from the Assembler Broker");
try
{
- // Attempt to load the screen
- screen = (Screen) ab
- .getAssembler(AssemblerBrokerService.SCREEN_TYPE, name);
+ if (ab != null)
+ {
+ // Attempt to load the screen
+ screen =
+ (Screen) ab.getAssembler(AssemblerBrokerService.SCREEN_TYPE, name);
+ }
}
catch (ClassCastException cce)
{
@@ -188,8 +207,9 @@
// the user a reason for that...
// FIX ME: The AssemblerFactories should each add it's
// own string here...
- Vector packages = TurbineResources
- .getVector(TurbineConstants.MODULE_PACKAGES);
+ Vector packages = Turbine.getConfiguration()
+ .getVector(TurbineConstants.MODULE_PACKAGES);
+
ObjectUtils.addOnce(packages,
GenericLoader.getBasePackage());
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org