Revision: 660
          http://stripes.svn.sourceforge.net/stripes/?rev=660&view=rev
Author:   bengunter
Date:     2007-12-10 20:55:00 -0800 (Mon, 10 Dec 2007)

Log Message:
-----------
Fixed STS-454: Add global debug flag to Configuration interface. New 
StripesFilter init-param is Stripes.DebugMode

Modified Paths:
--------------
    trunk/stripes/src/net/sourceforge/stripes/config/Configuration.java
    trunk/stripes/src/net/sourceforge/stripes/config/DefaultConfiguration.java
    trunk/stripes/src/net/sourceforge/stripes/config/RuntimeConfiguration.java

Modified: trunk/stripes/src/net/sourceforge/stripes/config/Configuration.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/config/Configuration.java 
2007-12-11 01:03:44 UTC (rev 659)
+++ trunk/stripes/src/net/sourceforge/stripes/config/Configuration.java 
2007-12-11 04:55:00 UTC (rev 660)
@@ -78,6 +78,12 @@
      */
     ServletContext getServletContext();
 
+    /** Enable or disable debug mode. */
+    void setDebugMode(boolean debugMode);
+
+    /** Returns true if the Stripes application is running in debug mode. */
+    boolean isDebugMode();
+
     /**
      * Returns an instance of ActionResolver that will be used by Stripes to 
lookup and resolve
      * ActionBeans.  The instance should be cached by the Configuration since 
multiple entities

Modified: 
trunk/stripes/src/net/sourceforge/stripes/config/DefaultConfiguration.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/config/DefaultConfiguration.java  
2007-12-11 01:03:44 UTC (rev 659)
+++ trunk/stripes/src/net/sourceforge/stripes/config/DefaultConfiguration.java  
2007-12-11 04:55:00 UTC (rev 660)
@@ -76,6 +76,7 @@
     /** Log implementation for use within this class. */
     private static final Log log = Log.getInstance(DefaultConfiguration.class);
 
+    private boolean debugMode;
     private BootstrapPropertyResolver resolver;
     private ActionResolver actionResolver;
     private ActionBeanPropertyBinder actionBeanPropertyBinder;
@@ -101,6 +102,14 @@
      */
     public void init() {
         try {
+               Boolean debugMode = initDebugMode();
+            if (debugMode != null) {
+                this.debugMode = debugMode;
+            }
+            else {
+                this.debugMode = false;
+            }
+
             this.actionResolver = initActionResolver();
             if (this.actionResolver == null) {
                 this.actionResolver = new NameBasedActionResolver();
@@ -198,6 +207,21 @@
         return 
getBootstrapPropertyResolver().getFilterConfig().getServletContext();
     }
 
+       /** Enable or disable debug mode. */
+       public void setDebugMode(boolean debugMode) {
+               this.debugMode = debugMode;
+       }
+
+       /** Returns true if the Stripes application is running in debug mode. */
+       public boolean isDebugMode() {
+               return debugMode;
+       }
+
+       /** Allows subclasses to initialize a non-default debug mode value. */
+       protected Boolean initDebugMode() {
+               return null;
+       }
+
     /**
      * Returns an instance of [EMAIL PROTECTED] NameBasedActionResolver} 
unless a subclass has
      * overridden the default.

Modified: 
trunk/stripes/src/net/sourceforge/stripes/config/RuntimeConfiguration.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/config/RuntimeConfiguration.java  
2007-12-11 01:03:44 UTC (rev 659)
+++ trunk/stripes/src/net/sourceforge/stripes/config/RuntimeConfiguration.java  
2007-12-11 04:55:00 UTC (rev 660)
@@ -55,6 +55,9 @@
     /** Log implementation for use within this class. */
     private static final Log log = Log.getInstance(RuntimeConfiguration.class);
 
+    /** The Configuration Key for enabling debug mode. */
+    public static final String DEBUG_MODE = "Stripes.DebugMode";
+
     /** The Configuration Key for looking up the name of the ActionResolver 
class. */
     public static final String ACTION_RESOLVER = "ActionResolver.Class";
 
@@ -94,6 +97,16 @@
     /** The Configuration Key for looking up the comma separated list of 
interceptor classes. */
     public static final String INTERCEPTOR_LIST = "Interceptor.Classes";
 
+    /** Looks for a true/false value in config. */
+    @Override protected Boolean initDebugMode() {
+        try {
+            return 
Boolean.valueOf(getBootstrapPropertyResolver().getProperty(DEBUG_MODE)
+                    .toLowerCase());
+        }
+        catch (Exception e) {
+            return null;
+        }
+    }
 
     /** Looks for a class name in config and uses that to create the 
component. */
     @Override protected ActionResolver initActionResolver() {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to