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/02/24 04:07:20 UTC

svn commit: r630577 - in /tapestry/tapestry5/trunk/tapestry-core/src/main: java/org/apache/tapestry/corelib/components/ java/org/apache/tapestry/corelib/pages/ resources/org/apache/tapestry/corelib/components/ resources/org/apache/tapestry/corelib/pages/

Author: hlship
Date: Sat Feb 23 19:07:18 2008
New Revision: 630577

URL: http://svn.apache.org/viewvc?rev=630577&view=rev
Log:
TAPESTRY-2169: Create an ExceptionAnalysisDisplay component

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/ExceptionDisplay.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/ExceptionDisplay.tml
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/pages/ExceptionReport.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.tml

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/ExceptionDisplay.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/ExceptionDisplay.java?rev=630577&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/ExceptionDisplay.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/ExceptionDisplay.java Sat Feb 23 19:07:18 2008
@@ -0,0 +1,91 @@
+// Copyright 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.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.corelib.components;
+
+import org.apache.tapestry.annotations.Parameter;
+import org.apache.tapestry.ioc.annotations.Inject;
+import org.apache.tapestry.ioc.services.ExceptionAnalysis;
+import org.apache.tapestry.ioc.services.ExceptionAnalyzer;
+import org.apache.tapestry.ioc.services.ExceptionInfo;
+
+import java.util.List;
+
+/**
+ * Integral part of the default {@link org.apache.tapestry.corelib.pages.ExceptionReport} page used to break apart and
+ * display the properties of the exception.
+ *
+ * @see org.apache.tapestry.ioc.services.ExceptionAnalyzer
+ */
+public class ExceptionDisplay
+{
+    /**
+     * Exception to report.
+     */
+    @Parameter(required = true)
+    private Throwable _exception;
+
+    @Inject
+    private ExceptionAnalyzer _analyzer;
+
+    private ExceptionInfo _info;
+
+    private String _propertyName;
+
+    private List<ExceptionInfo> _stack;
+
+    void setupRender()
+    {
+        ExceptionAnalysis analysis = _analyzer.analyze(_exception);
+
+        _stack = analysis.getExceptionInfos();
+    }
+
+    public List<ExceptionInfo> getStack()
+    {
+        return _stack;
+    }
+
+    public ExceptionInfo getInfo()
+    {
+        return _info;
+    }
+
+    public void setInfo(ExceptionInfo info)
+    {
+        _info = info;
+    }
+
+    public String getPropertyName()
+    {
+        return _propertyName;
+    }
+
+    public void setPropertyName(String propertyName)
+    {
+        _propertyName = propertyName;
+    }
+
+    public boolean getShowPropertyList()
+    {
+        // True if either is non-empty
+
+        return !(_info.getPropertyNames().isEmpty() && _info.getStackTrace().isEmpty());
+    }
+
+    public Object getPropertyValue()
+    {
+        return _info.getProperty(_propertyName);
+    }
+}

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=630577&r1=630576&r2=630577&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 Sat Feb 23 19:07:18 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 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.
@@ -15,37 +15,26 @@
 package org.apache.tapestry.corelib.pages;
 
 import org.apache.tapestry.TapestryConstants;
-import org.apache.tapestry.annotations.Meta;
+import org.apache.tapestry.annotations.ContentType;
 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;
 import org.apache.tapestry.services.ExceptionReporter;
 import org.apache.tapestry.services.Request;
 import org.apache.tapestry.services.Session;
 
-import java.util.List;
-
 /**
  * Responsible for reporting runtime exceptions. This page is quite verbose and is usually overridden in a production
- * application. When {@link org.apache.tapestry.TapestryConstants#PRODUCTION_MODE_SYMBOL} is "true", it is very abbreviated.
+ * application. When {@link org.apache.tapestry.TapestryConstants#PRODUCTION_MODE_SYMBOL} is "true", it is very
+ * abbreviated.
+ *
+ * @see org.apache.tapestry.corelib.components.ExceptionDisplay
  */
-@Meta("tapestry.response-content-type=text/html")
+@ContentType("text/html")
 public class ExceptionReport implements ExceptionReporter
 {
-    private List<ExceptionInfo> _stack;
-
-    private ExceptionInfo _info;
-
-    private String _propertyName;
-
     private String _attributeName;
 
     @Inject
-    private ExceptionAnalyzer _analyzer;
-
-    @Inject
     private Request _request;
 
     @Inject
@@ -57,47 +46,6 @@
     public void reportException(Throwable exception)
     {
         _rootException = exception;
-
-        ExceptionAnalysis analysis = _analyzer.analyze(exception);
-
-        _stack = analysis.getExceptionInfos();
-    }
-
-    public List<ExceptionInfo> getStack()
-    {
-        return _stack;
-    }
-
-    public ExceptionInfo getInfo()
-    {
-        return _info;
-    }
-
-    public void setInfo(ExceptionInfo info)
-    {
-        _info = info;
-    }
-
-    public String getPropertyName()
-    {
-        return _propertyName;
-    }
-
-    public void setPropertyName(String propertyName)
-    {
-        _propertyName = propertyName;
-    }
-
-    public boolean getShowPropertyList()
-    {
-        // True if either is non-empty
-
-        return !(_info.getPropertyNames().isEmpty() && _info.getStackTrace().isEmpty());
-    }
-
-    public Object getPropertyValue()
-    {
-        return _info.getProperty(_propertyName);
     }
 
     public boolean getHasSession()

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/ExceptionDisplay.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/ExceptionDisplay.tml?rev=630577&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/ExceptionDisplay.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/ExceptionDisplay.tml Sat Feb 23 19:07:18 2008
@@ -0,0 +1,34 @@
+<div xml:space="default" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" 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="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>
+            </li>
+        </t:loop>
+    </ul>
+</div>
\ No newline at end of file

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=630577&r1=630576&r2=630577&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 Sat Feb 23 19:07:18 2008
@@ -8,40 +8,8 @@
         <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>
+                <t:exceptiondisplay exception="rootException"/>
 
-                                <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>
-                                    </dl>
-                                </t:if>
-                            </li>
-                        </t:loop>
-                    </ul>
-                </div>
                 <div class="t-env-data">
                     <h2>Request</h2>
                     <t:renderobject object="request"/>