Author: ivaynberg
Date: Mon Feb 22 08:37:34 2010
New Revision: 912510

URL: http://svn.apache.org/viewvc?rev=912510&view=rev
Log:
broght back RestartResponseException and fixed some more tests

Added:
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/AbstractRestartResponseException.java
      - copied, changed from r912493, 
wicket/trunk/wicket/src/main/disabled/org/apache/wicket/AbstractRestartResponseException.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/RestartResponseException.java
      - copied, changed from r912493, 
wicket/trunk/wicket/src/main/disabled/org/apache/wicket/RestartResponseException.java
Removed:
    
wicket/trunk/wicket/src/main/disabled/org/apache/wicket/AbstractRestartResponseException.java
    
wicket/trunk/wicket/src/main/disabled/org/apache/wicket/RestartResponseException.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/session/InvalidateSessionTest$MyPage.html
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/session/InvalidateSessionTest.java
Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/AbortException.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/Response.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/mock/MockWebResponse.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebResponse.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/response/StringResponse.java

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/AbortException.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/AbortException.java?rev=912510&r1=912509&r2=912510&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/AbortException.java 
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/AbortException.java Mon 
Feb 22 08:37:34 2010
@@ -16,16 +16,33 @@
  */
 package org.apache.wicket;
 
+import 
org.apache.wicket.ng.request.cycle.RequestHandlerStack.ReplaceHandlerException;
+import org.apache.wicket.request.target.basic.EmptyRequestHandler;
+
 
 /**
  * Immediately aborts any further processing.
  * 
  * @author Igor Vaynberg (ivaynberg)
  */
-public class AbortException extends RuntimeException
+public class AbortException extends ReplaceHandlerException
 {
        private static final long serialVersionUID = 1L;
 
+
+       protected AbortException(IRequestHandler replacementRequestHandler)
+       {
+               super(replacementRequestHandler, true);
+       }
+
+       /**
+        * Constructor
+        */
+       public AbortException()
+       {
+               super(EmptyRequestHandler.getInstance(), true);
+       }
+
        /**
         * @see java.lang.Throwable#fillInStackTrace()
         */

Copied: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/AbstractRestartResponseException.java
 (from r912493, 
wicket/trunk/wicket/src/main/disabled/org/apache/wicket/AbstractRestartResponseException.java)
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/AbstractRestartResponseException.java?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/AbstractRestartResponseException.java&p1=wicket/trunk/wicket/src/main/disabled/org/apache/wicket/AbstractRestartResponseException.java&r1=912493&r2=912510&rev=912510&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/disabled/org/apache/wicket/AbstractRestartResponseException.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/AbstractRestartResponseException.java
 Mon Feb 22 08:37:34 2010
@@ -16,6 +16,8 @@
  */
 package org.apache.wicket;
 
+import org.apache.wicket.ng.request.cycle.RequestCycle;
+
 /**
  * An exception that causes the request cycle to immediately switch to respond 
stage.
  * 
@@ -32,12 +34,30 @@
        /**
         * Construct.
         */
-       public AbstractRestartResponseException()
+       protected AbstractRestartResponseException(IRequestHandler handler)
+       {
+               super(new ResponseResettingDecorator(handler));
+       }
+
+       private static class ResponseResettingDecorator implements 
IRequestHandler
        {
-               RequestCycle rc = RequestCycle.get();
-               if (rc != null)
+               private final IRequestHandler delegate;
+
+               public ResponseResettingDecorator(IRequestHandler delegate)
+               {
+                       this.delegate = delegate;
+               }
+
+               public void detach(RequestCycle requestCycle)
+               {
+                       delegate.detach(requestCycle);
+               }
+
+               public void respond(RequestCycle requestCycle)
                {
-                       rc.getResponse().reset();
+                       requestCycle.getResponse().reset();
+                       delegate.respond(requestCycle);
                }
+
        }
 }

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/Response.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/Response.java?rev=912510&r1=912509&r2=912510&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/Response.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/Response.java Mon Feb 
22 08:37:34 2010
@@ -23,6 +23,7 @@
  * {...@link #write(CharSequence)} on the same {...@link Response} instance.
  * 
  * @author Matej Knopp
+ * @author igor.vaynberg
  */
 public abstract class Response
 {
@@ -60,4 +61,12 @@
         * @return encoded URL
         */
        public abstract String encodeURL(CharSequence url);
+
+       /**
+        * Called when the Response needs to reset itself. Subclasses can empty 
there buffer or build up
+        * state.
+        */
+       public void reset()
+       {
+       }
 }

Copied: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/RestartResponseException.java
 (from r912493, 
wicket/trunk/wicket/src/main/disabled/org/apache/wicket/RestartResponseException.java)
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/RestartResponseException.java?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/RestartResponseException.java&p1=wicket/trunk/wicket/src/main/disabled/org/apache/wicket/RestartResponseException.java&r1=912493&r2=912510&rev=912510&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/disabled/org/apache/wicket/RestartResponseException.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/RestartResponseException.java
 Mon Feb 22 08:37:34 2010
@@ -16,6 +16,10 @@
  */
 package org.apache.wicket;
 
+import org.apache.wicket.ng.request.component.PageParameters;
+import org.apache.wicket.ng.request.handler.PageProvider;
+import org.apache.wicket.ng.request.handler.impl.RenderPageRequestHandler;
+
 /**
  * Causes wicket to interrupt current request processing and immediately 
respond with the specified
  * page.
@@ -37,7 +41,7 @@
         */
        public <C extends Page> RestartResponseException(Class<C> pageClass)
        {
-               RequestCycle.get().setResponsePage(pageClass);
+               this(pageClass, null);
        }
 
        /**
@@ -53,7 +57,7 @@
         */
        public <C extends Page> RestartResponseException(Class<C> pageClass, 
PageParameters params)
        {
-               RequestCycle.get().setResponsePage(pageClass, params);
+               super(new RenderPageRequestHandler(new PageProvider(pageClass, 
params)));
        }
 
        /**
@@ -64,6 +68,6 @@
         */
        public RestartResponseException(Page page)
        {
-               RequestCycle.get().setResponsePage(page);
+               super(new RenderPageRequestHandler(new PageProvider(page)));
        }
 }

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java?rev=912510&r1=912509&r2=912510&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java 
(original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java 
Mon Feb 22 08:37:34 2010
@@ -207,6 +207,7 @@
                /**
                 * Resets the response to a clean state so it can be reused to 
save on garbage.
                 */
+               @Override
                public void reset()
                {
                        buffer.clear();
@@ -1195,4 +1196,6 @@
        {
                return page.getPageParameters();
        }
+
+
 }

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/mock/MockWebResponse.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/mock/MockWebResponse.java?rev=912510&r1=912509&r2=912510&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/mock/MockWebResponse.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/mock/MockWebResponse.java
 Mon Feb 22 08:37:34 2010
@@ -289,4 +289,32 @@
        public void flush()
        {
        }
+
+       @Override
+       public void reset()
+       {
+               super.reset();
+               if (binaryResponse != null)
+               {
+                       binaryResponse = new ByteArrayOutputStream();
+               }
+               contentLength = null;
+               contentType = null;
+               if (cookies != null)
+               {
+                       cookies.clear();
+               }
+               errorMessage = null;
+               if (headers != null)
+               {
+                       headers.clear();
+               }
+               redirectUrl = null;
+               status = null;
+               if (textResponse != null)
+               {
+                       textResponse.setLength(0);
+               }
+
+       }
 }

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java?rev=912510&r1=912509&r2=912510&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java
 Mon Feb 22 08:37:34 2010
@@ -272,6 +272,15 @@
        private WriteDataAction dataAction;
 
        @Override
+       public void reset()
+       {
+               super.reset();
+               actions.clear();
+               charSequenceAction = null;
+               dataAction = null;
+       }
+
+       @Override
        public void addCookie(Cookie cookie)
        {
                actions.add(new AddCookieAction(cookie));

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebResponse.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebResponse.java?rev=912510&r1=912509&r2=912510&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebResponse.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebResponse.java
 Mon Feb 22 08:37:34 2010
@@ -212,4 +212,12 @@
                        throw new WicketRuntimeException(e);
                }
        }
+
+       @Override
+       public void reset()
+       {
+               super.reset();
+               httpServletResponse.reset();
+               redirect = false;
+       }
 }

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/response/StringResponse.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/response/StringResponse.java?rev=912510&r1=912509&r2=912510&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/response/StringResponse.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/response/StringResponse.java
 Mon Feb 22 08:37:34 2010
@@ -53,6 +53,7 @@
        /**
         * @see org.apache.wicket.Response#reset()
         */
+       @Override
        public void reset()
        {
                out.clear();


Reply via email to