You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/01/24 20:55:44 UTC

svn commit: r614963 - in /tapestry/tapestry5/trunk: quickstart/src/main/resources/archetype-resources/src/main/java/services/ tapestry-core/src/main/java/org/apache/tapestry/ tapestry-core/src/main/java/org/apache/tapestry/corelib/pages/ tapestry-core/...

Author: hlship
Date: Thu Jan 24 11:55:39 2008
New Revision: 614963

URL: http://svn.apache.org/viewvc?rev=614963&view=rev
Log:
TAPESTRY-1843: Tapestry should have a "production mode" (vs. development mode)

Modified:
    tapestry/tapestry5/trunk/quickstart/src/main/resources/archetype-resources/src/main/java/services/AppModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/TapestryConstants.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/pages/ExceptionReport.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.tml
    tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/conf.apt
    tapestry/tapestry5/trunk/tapestry-core/src/site/apt/index.apt
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties

Modified: tapestry/tapestry5/trunk/quickstart/src/main/resources/archetype-resources/src/main/java/services/AppModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/quickstart/src/main/resources/archetype-resources/src/main/java/services/AppModule.java?rev=614963&r1=614962&r2=614963&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/quickstart/src/main/resources/archetype-resources/src/main/java/services/AppModule.java (original)
+++ tapestry/tapestry5/trunk/quickstart/src/main/resources/archetype-resources/src/main/java/services/AppModule.java Thu Jan 24 11:55:39 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
 
 import java.io.IOException;
 
+import org.apache.tapestry.TapestryConstants;
 import org.apache.tapestry.ioc.MappedConfiguration;
 import org.apache.tapestry.ioc.OrderedConfiguration;
 import org.apache.tapestry.ioc.ServiceBinder;
@@ -52,7 +53,12 @@
         // you can extend this list of locales (it's a comma seperated series of locale names;
         // the first locale name is the default when there's no reasonable match).
         
-        configuration.add("tapestry.supported-locales", "en");
+        configuration.add(TapestryConstants.SUPPORTED_LOCALES_SYMBOL, "en");
+
+        // The factory default is true but during the early stages of an application
+        // overriding to false is a good idea. In addition, this is often overridden
+        // on the command line as -Dtapestry.production-mode=false
+        configuration.add(TapestryConstants.PRODUCTION_MODE_SYMBOL, "false");
     }
     
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/TapestryConstants.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/TapestryConstants.java?rev=614963&r1=614962&r2=614963&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/TapestryConstants.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/TapestryConstants.java Thu Jan 24 11:55:39 2008
@@ -66,6 +66,12 @@
     public static final String RESPONSE_ENCODING = "tapestry.response-encoding";
 
     /**
+     * Indicates whether Tapestry is running in production mode or developer mode.  The primary difference is
+     * how exceptions are reported.
+     */
+    public static final String PRODUCTION_MODE_SYMBOL = "tapestry.production-mode";
+
+    /**
      * CSS class name that causes a rendered element to be invisible on the client side.
      */
     public static final String INVISIBLE_CLASS = "t-invisible";

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/pages/ExceptionReport.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/pages/ExceptionReport.java?rev=614963&r1=614962&r2=614963&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/pages/ExceptionReport.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/pages/ExceptionReport.java Thu Jan 24 11:55:39 2008
@@ -14,8 +14,10 @@
 
 package org.apache.tapestry.corelib.pages;
 
+import org.apache.tapestry.TapestryConstants;
 import org.apache.tapestry.annotations.Meta;
 import org.apache.tapestry.ioc.annotations.Inject;
+import org.apache.tapestry.ioc.annotations.Symbol;
 import org.apache.tapestry.ioc.services.ExceptionAnalysis;
 import org.apache.tapestry.ioc.services.ExceptionAnalyzer;
 import org.apache.tapestry.ioc.services.ExceptionInfo;
@@ -26,8 +28,8 @@
 import java.util.List;
 
 /**
- * Responsible for reporting runtime exceptions. This page is quite verbose and is usually
- * overridden in a production application.
+ * Responsible for reporting runtime exceptions. This page is quite verbose and is usually overridden in a production
+ * application.
  */
 @Meta("tapestry.response-content-type=text/html")
 public class ExceptionReport implements ExceptionReporter
@@ -46,8 +48,16 @@
     @Inject
     private Request _request;
 
+    @Inject
+    @Symbol(TapestryConstants.PRODUCTION_MODE_SYMBOL)
+    private boolean _productionMode;
+
+    private Throwable _rootException;
+
     public void reportException(Throwable exception)
     {
+        _rootException = exception;
+
         ExceptionAnalysis analysis = _analyzer.analyze(exception);
 
         _stack = analysis.getExceptionInfos();
@@ -118,5 +128,15 @@
     public Object getAttributeValue()
     {
         return getSession().getAttribute(_attributeName);
+    }
+
+    public boolean isProductionMode()
+    {
+        return _productionMode;
+    }
+
+    public Throwable getRootException()
+    {
+        return _rootException;
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java?rev=614963&r1=614962&r2=614963&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java Thu Jan 24 11:55:39 2008
@@ -1689,6 +1689,8 @@
 
         configuration.add(TapestryConstants.FORCE_ABSOLUTE_URIS_SYMBOL, "false");
 
+        configuration.add(TapestryConstants.PRODUCTION_MODE_SYMBOL, "true");
+
         // This is designed to make it easy to keep synchronized with script.aculo.ous. As we
         // support a new version, we create a new folder, and update the path entry. We can then
         // delete the old version folder (or keep it around). This should be more manageable than

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.tml?rev=614963&r1=614962&r2=614963&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.tml Thu Jan 24 11:55:39 2008
@@ -5,56 +5,61 @@
     <body>
         <h1 class="t-exception-report">An unexpected application exception has occurred.</h1>
 
+        <t:if test="productionMode">
+            <p>${rootException.message}</p>
+            <t:parameter name="else">
+                <div class="t-exception-report">
+                    <ul>
+                        <t:loop source="stack" value="info">
+                            <li>
+                                <span class="t-exception-class-name">${info.className}</span>
 
-        <div class="t-exception-report">
-            <ul>
-                <t:loop source="stack" value="info">
-                    <li>
-                        <span class="t-exception-class-name">${info.className}</span>
-
-                        <t:if test="info.message">
-                            <div class="t-exception-message">${info.message}</div>
-                        </t:if>
+                                <t:if test="info.message">
+                                    <div class="t-exception-message">${info.message}</div>
+                                </t:if>
 
-                        <t:if test="showPropertyList">
-                            <dl>
-                                <t:loop source="info.propertyNames" value="propertyName">
-                                    <dt>${propertyName}</dt>
-                                    <dd>
-                                        <t:renderobject object="propertyValue"/>
-                                    </dd>
-                                </t:loop>
-                                <t:if test="info.stackTrace">
-                                    <dt>Stack trace</dt>
-                                    <dd>
-                                        <ul class="t-stack-trace">
-                                            <t:loop source="info.stackTrace" value="var:frame">
-                                                <li>${var:frame}</li>
-                                            </t:loop>
-                                        </ul>
-                                    </dd>
+                                <t:if test="showPropertyList">
+                                    <dl>
+                                        <t:loop source="info.propertyNames" value="propertyName">
+                                            <dt>${propertyName}</dt>
+                                            <dd>
+                                                <t:renderobject object="propertyValue"/>
+                                            </dd>
+                                        </t:loop>
+                                        <t:if test="info.stackTrace">
+                                            <dt>Stack trace</dt>
+                                            <dd>
+                                                <ul class="t-stack-trace">
+                                                    <t:loop source="info.stackTrace" value="var:frame">
+                                                        <li>${var:frame}</li>
+                                                    </t:loop>
+                                                </ul>
+                                            </dd>
+                                        </t:if>
+                                    </dl>
                                 </t:if>
-                            </dl>
-                        </t:if>
-                    </li>
-                </t:loop>
-            </ul>
-        </div>
-        <div class="t-env-data">
-            <h2>Request</h2>
-            <t:renderobject object="request"/>
+                            </li>
+                        </t:loop>
+                    </ul>
+                </div>
+                <div class="t-env-data">
+                    <h2>Request</h2>
+                    <t:renderobject object="request"/>
 
-            <t:if test="hasSession">
-                <h2>Session</h2>
-                <dl>
-                    <t:loop source="session.attributeNames" value="attributeName">
-                        <dt>${attributeName}</dt>
-                        <dd>
-                            <t:renderobject object="attributeValue"/>
-                        </dd>
-                    </t:loop>
-                </dl>
-            </t:if>
-        </div>
+                    <t:if test="hasSession">
+                        <h2>Session</h2>
+                        <dl>
+                            <t:loop source="session.attributeNames" value="attributeName">
+                                <dt>${attributeName}</dt>
+                                <dd>
+                                    <t:renderobject object="attributeValue"/>
+                                </dd>
+                            </t:loop>
+                        </dl>
+                    </t:if>
+                </div>
+            </t:parameter>
+        </t:if>
     </body>
+
 </html>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/conf.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/conf.apt?rev=614963&r1=614962&r2=614963&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/conf.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/conf.apt Thu Jan 24 11:55:39 2008
@@ -120,10 +120,10 @@
      When true, all URIs will be absolute URIs (including the
      context path, and the complete path for the request).
 
-  [tapestry.scriptaculous]
-    The path to the embedded copy of {{{http://script.aculo.us/}script.aculo.us}} packaged with Tapestry. This value may be overridden
-    to use a different version of the script.aculo.us library. Tapestry's default version is 1.8.0
-    (including Prototype 1.6.0).
+  [tapestry.production-mode]
+    A flag (true or false) indicating whether the application is running in production or in development. The default
+    is true, which means that runtime exceptions are not reported with full detail (only the root exception message
+    is displayed, not the entire stack of exceptions, properties and other information shown in development mode).
 
   [tapestry.page-pool.active-window]
     The time interval that an instantiated page instance may be cached before being removed. As pages are
@@ -156,6 +156,11 @@
   [tapestry.page-pool.soft-wait]
     The time interval that Tapestry will wait for a page instance to become available before deciding whether to create
     an entirely new page instance.  The default is "10 ms".
+
+  [tapestry.scriptaculous]
+    The path to the embedded copy of {{{http://script.aculo.us/}script.aculo.us}} packaged with Tapestry. This value may be overridden
+    to use a different version of the script.aculo.us library. Tapestry's default version is 1.8.0
+    (including Prototype 1.6.0).
 
   [tapestry.start-page-name]
     The logical name of the start page, the page that is rendered for the <root URL>.  This is normally "start".    

Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/index.apt?rev=614963&r1=614962&r2=614963&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/index.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/index.apt Thu Jan 24 11:55:39 2008
@@ -13,6 +13,9 @@
   Progress on Tapestry 5 is really taking off. This space lists some cool new features that have been added
   recently.
 
+  * Tapestry now differentiates between development mode and production mode, primarily in how
+    it reports runtime exceptions.  It defaults to production mode.   
+
   * Components can now supply an event handler for type "exception" which will be invoked when
     an exception occurs in a component event handler method. This is useful for handling errors
     with the context for the "activate" event.

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java?rev=614963&r1=614962&r2=614963&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java Thu Jan 24 11:55:39 2008
@@ -14,6 +14,7 @@
 
 package org.apache.tapestry.integration.app1.services;
 
+import org.apache.tapestry.TapestryConstants;
 import org.apache.tapestry.integration.app1.data.Track;
 import org.apache.tapestry.ioc.MappedConfiguration;
 import org.apache.tapestry.ioc.OrderedConfiguration;
@@ -101,7 +102,9 @@
 
     public static void contributeApplicationDefaults(MappedConfiguration<String, String> configuration)
     {
-        configuration.add("tapestry.supported-locales", "en,fr");
+        configuration.add(TapestryConstants.SUPPORTED_LOCALES_SYMBOL, "en,fr");
+        configuration.add(TapestryConstants.PRODUCTION_MODE_SYMBOL, "false");
+        
         configuration.add("app.injected-symbol", "Symbol contributed to ApplicationDefaults");
     }
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties?rev=614963&r1=614962&r2=614963&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties Thu Jan 24 11:55:39 2008
@@ -21,7 +21,7 @@
 log4j.appender.A1.layout=org.apache.log4j.PatternLayout
 log4j.appender.A1.layout.ConversionPattern= %d{HH:mm:ss,SSS} [%p] %c{1} %m%n
 
-# log4j.category.org.apache.tapestry.integration.app1.pages=debug
+log4j.category.org.apache.tapestry.corelib.pages=debug