Author: hlship
Date: Mon Jan 12 17:28:40 2009
New Revision: 733980
URL: http://svn.apache.org/viewvc?rev=733980&view=rev
Log:
TAP5-106: When filtering out stack frames in ExceptionAnalyzer, frames for
sun.reflect could easily be omitted
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ApplicationStackTraceElementAnalyzer.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PrefixCheckStackTraceElementAnalyzer.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/StackTraceElementAnalyzer.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/StackTraceElementClassConstants.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/ExceptionDisplay.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/ExceptionDisplay.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/ExceptionDisplay.java?rev=733980&r1=733979&r2=733980&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/ExceptionDisplay.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/ExceptionDisplay.java
Mon Jan 12 17:28:40 2009
@@ -21,10 +21,13 @@
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.internal.InternalConstants;
import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.annotations.Primary;
import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.ioc.services.ExceptionAnalysis;
import org.apache.tapestry5.ioc.services.ExceptionAnalyzer;
import org.apache.tapestry5.ioc.services.ExceptionInfo;
+import org.apache.tapestry5.services.StackTraceElementAnalyzer;
+import org.apache.tapestry5.services.StackTraceElementClassConstants;
import java.util.List;
@@ -70,6 +73,10 @@
private boolean sawDoFilter;
+ @Inject
+ @Primary
+ private StackTraceElementAnalyzer frameAnalyzer;
+
void setupRender()
{
ExceptionAnalysis analysis = analyzer.analyze(exception);
@@ -93,16 +100,13 @@
public String getFrameClass()
{
- String className = frame.getClassName();
- int lineNumber = frame.getLineNumber();
+ if (sawDoFilter) return StackTraceElementClassConstants.OMITTED;
- if (sawDoFilter || className.startsWith("$") && lineNumber <= 0)
return "t-omitted-frame";
+ String result = frameAnalyzer.classForFrame(frame);
sawDoFilter |= frame.getMethodName().equals("doFilter");
- if (className.startsWith(appPackage) && lineNumber > 0) return
"t-usercode-frame";
-
- return null;
+ return result;
}
void afterRender()
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ApplicationStackTraceElementAnalyzer.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ApplicationStackTraceElementAnalyzer.java?rev=733980&view=auto
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ApplicationStackTraceElementAnalyzer.java
(added)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ApplicationStackTraceElementAnalyzer.java
Mon Jan 12 17:28:40 2009
@@ -0,0 +1,45 @@
+// Copyright 2009 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.tapestry5.internal.services;
+
+import org.apache.tapestry5.internal.InternalConstants;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.annotations.Symbol;
+import org.apache.tapestry5.services.StackTraceElementAnalyzer;
+import org.apache.tapestry5.services.StackTraceElementClassConstants;
+
+/**
+ * Identifies frames for application classes.
+ *
+ * @since 5.1.0.0
+ */
+public class ApplicationStackTraceElementAnalyzer implements
StackTraceElementAnalyzer
+{
+ private final String appPackage;
+
+ public ApplicationStackTraceElementAnalyzer(
+ @Inject @Symbol(InternalConstants.TAPESTRY_APP_PACKAGE_PARAM)
+ String appPackage)
+ {
+ this.appPackage = appPackage;
+ }
+
+ public String classForFrame(StackTraceElement frame)
+ {
+ return frame.getClassName().startsWith(appPackage) &&
frame.getLineNumber() > 0
+ ? StackTraceElementClassConstants.USER_CODE
+ : null;
+ }
+}
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PrefixCheckStackTraceElementAnalyzer.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PrefixCheckStackTraceElementAnalyzer.java?rev=733980&view=auto
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PrefixCheckStackTraceElementAnalyzer.java
(added)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PrefixCheckStackTraceElementAnalyzer.java
Mon Jan 12 17:28:40 2009
@@ -0,0 +1,41 @@
+// Copyright 2009 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.tapestry5.internal.services;
+
+import org.apache.tapestry5.services.StackTraceElementAnalyzer;
+
+/**
+ * Checks to see if a class has a given prefix to its class name.
+ *
+ * @since 5.1.0.0
+ */
+public class PrefixCheckStackTraceElementAnalyzer implements
StackTraceElementAnalyzer
+{
+ private final String cssClass;
+ private final String prefix;
+
+ public PrefixCheckStackTraceElementAnalyzer(String cssClass, String prefix)
+ {
+ this.prefix = prefix;
+ this.cssClass = cssClass;
+ }
+
+ public String classForFrame(StackTraceElement frame)
+ {
+ return frame.getClassName().startsWith(prefix)
+ ? cssClass
+ : null;
+ }
+}
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/StackTraceElementAnalyzer.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/StackTraceElementAnalyzer.java?rev=733980&view=auto
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/StackTraceElementAnalyzer.java
(added)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/StackTraceElementAnalyzer.java
Mon Jan 12 17:28:40 2009
@@ -0,0 +1,35 @@
+// Copyright 2009 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.tapestry5.services;
+
+import org.apache.tapestry5.ioc.annotations.UsesOrderedConfiguration;
+
+/**
+ * Used by {...@link org.apache.tapestry5.corelib.components.ExceptionDisplay}
to characterize each stack frame that is
+ * presented. Implemented as a chain-of-command service.
+ *
+ * @since 5.1.0.0
+ */
+...@usesorderedconfiguration(StackTraceElementAnalyzer.class)
+public interface StackTraceElementAnalyzer
+{
+ /**
+ * Returns the CSS class appropriate to the frame.
+ *
+ * @param frame stack trace element to be analyzed
+ * @return the CSS class name, or null
+ */
+ String classForFrame(StackTraceElement frame);
+}
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/StackTraceElementClassConstants.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/StackTraceElementClassConstants.java?rev=733980&view=auto
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/StackTraceElementClassConstants.java
(added)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/StackTraceElementClassConstants.java
Mon Jan 12 17:28:40 2009
@@ -0,0 +1,33 @@
+// Copyright 2009 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.tapestry5.services;
+
+/**
+ * CSS classes, from the default CSS stylesheet, used with {...@link
org.apache.tapestry5.services.StackTraceElementAnalyzer}.
+ *
+ * @since 5.1.0.0
+ */
+public class StackTraceElementClassConstants
+{
+ /**
+ * An omitted frame, because it is not interesting (such as a dynamically
generated proxy). Usually invisible.
+ */
+ public static final String OMITTED = "t-omitted-frame";
+
+ /**
+ * Part of the application's code base, and therefore highlighted.
+ */
+ public static final String USER_CODE = "t-usercode-frame";
+}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=733980&r1=733979&r2=733980&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
Mon Jan 12 17:28:40 2009
@@ -2104,7 +2104,7 @@
}
/**
- * The master SessionPesistedObjectAnalyzer.
+ * The master Sessi`onPesistedObjectAnalyzer.
*
* @since 5.1.0.0
*/
@@ -2144,7 +2144,8 @@
}
/**
- * Adds the following content types: <ul> <li>image/jpeg</li> </ul>
+ * Contibutions are content types that do not benefit from compression.
Adds the following content types: <ul>
+ * <li>image/jpeg</li> </ul>
*
* @since 5.1.0.0
*/
@@ -2152,4 +2153,31 @@
{
configuration.add("image/jpeg");
}
+
+ /**
+ * @since 5.1.1.0
+ */
+ @Marker(Primary.class)
+ public StackTraceElementAnalyzer
buildMasterStackTraceElementAnalyzer(List<StackTraceElementAnalyzer>
configuration)
+ {
+ return chainBuilder.build(StackTraceElementAnalyzer.class,
configuration);
+ }
+
+ /**
+ * Adds two analyzers: <dl> <dt>Application</dt> <dd>Checks for classes in
the application package</dd>
+ * <dt>Proxies</dt> <dd>Checks for classes that appear to be generated
proxies.</dd> <dt>SunReflect</dt> <dd>Checks
+ * for <code>sun.reflect</code> (which are omitted)</dl>
+ *
+ * @since 5.1.0.0
+ */
+ public static void contributeMasterStackTraceElementAnalyzer(
+ OrderedConfiguration<StackTraceElementAnalyzer> configuration)
+ {
+ configuration.addInstance("Application",
ApplicationStackTraceElementAnalyzer.class);
+ configuration.addInstance("Proxies",
ProxiesStackTraceElementAnalyzer.class, "before:Application");
+ configuration.add("SunReflect",
+ new
PrefixCheckStackTraceElementAnalyzer(StackTraceElementClassConstants.OMITTED,
+
"sun.reflect."
+ ));
+ }
}