tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject tapestry-5 git commit: TAP5-2471: DefaultRequestExceptionHandler creating absolute links for xhr request
Date Mon, 01 Jun 2015 21:15:23 GMT
Repository: tapestry-5
Updated Branches:
  refs/heads/master 6e1ebb30c -> e25fac7e4


TAP5-2471: DefaultRequestExceptionHandler creating absolute links for xhr request


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/e25fac7e
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/e25fac7e
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/e25fac7e

Branch: refs/heads/master
Commit: e25fac7e44f4f043ec8e1787e1b3597173d70bbb
Parents: 6e1ebb3
Author: Howard M. Lewis Ship <hlship@apache.org>
Authored: Mon Jun 1 13:50:08 2015 -0700
Committer: Howard M. Lewis Ship <hlship@apache.org>
Committed: Mon Jun 1 13:50:08 2015 -0700

----------------------------------------------------------------------
 .../apache/tapestry5/ContextAwareException.java | 10 +++++---
 .../tapestry5/ExceptionHandlerAssistant.java    | 26 +++++++++++++++++---
 .../DefaultRequestExceptionHandler.java         |  2 +-
 .../services/RequestExceptionHandler.java       | 11 ++++++++-
 4 files changed, 40 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e25fac7e/tapestry-core/src/main/java/org/apache/tapestry5/ContextAwareException.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/ContextAwareException.java b/tapestry-core/src/main/java/org/apache/tapestry5/ContextAwareException.java
index 9c8b22c..a046fc7 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/ContextAwareException.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/ContextAwareException.java
@@ -1,5 +1,3 @@
-// Copyright 2006, 2008, 2010, 2011 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
@@ -14,6 +12,12 @@
 
 package org.apache.tapestry5;
 
-public interface ContextAwareException {
+/**
+ * An interface implemented by exceptions that get special handling in the default {@link
org.apache.tapestry5.services.RequestExceptionHandler}
+ * service.
+ */
+public interface ContextAwareException
+{
+    /** @returns A page activation context for reporting the exception. */
     Object[] getContext();
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e25fac7e/tapestry-core/src/main/java/org/apache/tapestry5/ExceptionHandlerAssistant.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/ExceptionHandlerAssistant.java
b/tapestry-core/src/main/java/org/apache/tapestry5/ExceptionHandlerAssistant.java
index 7f76075..bfbc553 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/ExceptionHandlerAssistant.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/ExceptionHandlerAssistant.java
@@ -1,5 +1,3 @@
-// Copyright 2006, 2008, 2010, 2011 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
@@ -14,9 +12,29 @@
 
 package org.apache.tapestry5;
 
+import org.apache.tapestry5.services.RequestExceptionHandler;
+
 import java.io.IOException;
 import java.util.List;
 
-public interface ExceptionHandlerAssistant {
-    public Object handleRequestException(Throwable exception, List<Object> exceptionContext)
throws IOException;
+/**
+ * A contribution to the default {@link RequestExceptionHandler} service, this is mapped
to an exception class,
+ * allowing class specific (based on an inheritance search) handling of an exception.
+ *
+ * @see ContextAwareException
+ */
+public interface ExceptionHandlerAssistant
+{
+    /**
+     * Handles the exception, returning a page class or link to redirect to.
+     *
+     * @param exception
+     *         the exception as thrown
+     * @param exceptionContext
+     *         a page activation context that is derived from the root-most exception
+     * @return either a page class or a {@link Link}; a page will be redirected to, with
the exception context
+     * as the page activation context
+     * @throws IOException
+     */
+    Object handleRequestException(Throwable exception, List<Object> exceptionContext)
throws IOException;
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e25fac7e/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandler.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandler.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandler.java
index 26c0a63..39c4bac 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandler.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandler.java
@@ -207,7 +207,7 @@ public class DefaultRequestExceptionHandler implements RequestExceptionHandler
                 OutputStream os = response.getOutputStream("application/json;charset=UTF-8");
 
                 JSONObject reply = new JSONObject();
-                reply.in(InternalConstants.PARTIAL_KEY).put("redirectURL", link.toAbsoluteURI());
+                reply.in(InternalConstants.PARTIAL_KEY).put("redirectURL", link.toRedirectURI());
 
                 os.write(reply.toCompactString().getBytes("UTF-8"));
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e25fac7e/tapestry-core/src/main/java/org/apache/tapestry5/services/RequestExceptionHandler.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/services/RequestExceptionHandler.java
b/tapestry-core/src/main/java/org/apache/tapestry5/services/RequestExceptionHandler.java
index df4fe79..303cf9b 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/services/RequestExceptionHandler.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/services/RequestExceptionHandler.java
@@ -12,12 +12,20 @@
 
 package org.apache.tapestry5.services;
 
+import org.apache.tapestry5.ExceptionHandlerAssistant;
+import org.apache.tapestry5.ioc.annotations.UsesMappedConfiguration;
+
 import java.io.IOException;
 
 /**
  * Service invoked when an uncaught exception occurs. The error handler is responsible for
providing a response to the
  * user to describe the error.
+ *
+ * The default implementation accepts the configuration, which maps an exception class to
a corresponding helper.
+ * The helper is either an instance of {@link ExceptionHandlerAssistant} or is a Class for
a page that will be redirected
+ * to, to present the exception.
  */
+@UsesMappedConfiguration(key = Class.class, value = Object.class)
 public interface RequestExceptionHandler
 {
     /**
@@ -29,7 +37,8 @@ public interface RequestExceptionHandler
      * These are very important in Ajax requests to allow the client-side logic to detect
the error and present it to
      * the user.
      *
-     * @param exception uncaught exception to be reported
+     * @param exception
+     *         uncaught exception to be reported
      * @throws IOException
      */
     void handleRequestException(Throwable exception) throws IOException;


Mime
View raw message