- Revision
- 358
- Author
- mauro
- Date
- 2007-11-12 15:47:51 -0600 (Mon, 12 Nov 2007)
Log Message
Added monitoring to DefaultActionMethodResponseHandler.
Modified Paths
- trunk/core/src/main/java/org/codehaus/waffle/action/DefaultActionMethodResponseHandler.java
- trunk/core/src/main/java/org/codehaus/waffle/action/intercept/SecurityMethodInterceptor.java
- trunk/core/src/main/java/org/codehaus/waffle/monitor/AbstractWritingMonitor.java
- trunk/core/src/main/java/org/codehaus/waffle/monitor/ActionMonitor.java
- trunk/core/src/main/java/org/codehaus/waffle/monitor/CommonsLoggingMonitor.java
- trunk/core/src/test/java/org/codehaus/waffle/action/DefaultActionMethodResponseHandlerTest.java
- trunk/core/src/test/java/org/codehaus/waffle/testmodel/StubMonitor.java
Diff
Modified: trunk/core/src/main/java/org/codehaus/waffle/action/DefaultActionMethodResponseHandler.java (357 => 358)
--- trunk/core/src/main/java/org/codehaus/waffle/action/DefaultActionMethodResponseHandler.java 2007-11-12 20:35:00 UTC (rev 357) +++ trunk/core/src/main/java/org/codehaus/waffle/action/DefaultActionMethodResponseHandler.java 2007-11-12 21:47:51 UTC (rev 358) @@ -20,15 +20,16 @@ import java.io.IOException; /** - * This handler will make decisions based on what is returned from the action method. For example: - * <p/> - * - A View response indicates which view the user should be directed (either redirected or forwarded) to. - * <p/> - * - A ActionMethodException will set the response status and sends the mesage directly (perfect for ajax). - * <p/> - * - otherwise the response value will be sent directly to the browser as a String via Object.toString() method. + * Handler that will make decisions based on what is returned from the action method: + * + * <ol> + * <li>A View response will be directed (either redirected or forwarded)</li> + * <li>A ActionMethodException will set the response status and sends the message directly (perfect for ajax).</li> + * <li>Otherwise the response value will be sent directly to the browser as a String via Object.toString() method.</li> + * </ol> * * @author Michael Ward + * @author Mauro Talevi */ public class DefaultActionMethodResponseHandler implements ActionMethodResponseHandler { private final ViewDispatcher viewDispatcher; @@ -50,6 +51,7 @@ HttpServletResponse response, ActionMethodResponse actionMethodResponse) throws IOException, ServletException { if (response.isCommitted()) { + actionMonitor.responseIsCommitted(response); return; // do NOT go any further } @@ -58,6 +60,7 @@ if (returnValue instanceof View) { View view = (View) returnValue; viewDispatcher.dispatch(request, response, view); + actionMonitor.viewDispatched(view); } else if (returnValue instanceof ActionMethodException) { ActionMethodException exception = (ActionMethodException) returnValue; actionMonitor.actionMethodExecutionFailed(exception);
Modified: trunk/core/src/main/java/org/codehaus/waffle/action/intercept/SecurityMethodInterceptor.java (357 => 358)
--- trunk/core/src/main/java/org/codehaus/waffle/action/intercept/SecurityMethodInterceptor.java 2007-11-12 20:35:00 UTC (rev 357) +++ trunk/core/src/main/java/org/codehaus/waffle/action/intercept/SecurityMethodInterceptor.java 2007-11-12 21:47:51 UTC (rev 358) @@ -19,8 +19,8 @@ import java.lang.reflect.Method; /** - * This interceptor ensure that only annotated methods are invokable as <i>Actions</i>. Usage of this will help protect - * your application against malicious attacks. + * This interceptor ensure that only annotated methods are invokable as <i>Actions</i>. + * Usage of this will help protect your application against malicious attacks. */ public class SecurityMethodInterceptor implements MethodInterceptor {
Modified: trunk/core/src/main/java/org/codehaus/waffle/monitor/AbstractWritingMonitor.java (357 => 358)
--- trunk/core/src/main/java/org/codehaus/waffle/monitor/AbstractWritingMonitor.java 2007-11-12 20:35:00 UTC (rev 357) +++ trunk/core/src/main/java/org/codehaus/waffle/monitor/AbstractWritingMonitor.java 2007-11-12 21:47:51 UTC (rev 358) @@ -16,9 +16,12 @@ import java.util.Set; +import javax.servlet.http.HttpServletResponse; + import org.codehaus.waffle.action.MethodDefinition; import org.codehaus.waffle.action.HierarchicalArgumentResolver.Scope; import org.codehaus.waffle.validation.BindErrorMessage; +import org.codehaus.waffle.view.View; /** * Abstract implementation of Monitor that delegates writing to concrete subclasses. @@ -81,4 +84,13 @@ public void bindFailed(Object controller, Throwable cause){ write(WARN, "Bind failed for controller " + controller + ": " + cause); } + + public void responseIsCommitted(HttpServletResponse response) { + write(INFO, "Reponse is already committed: "+response); + } + + public void viewDispatched(View view) { + write(DEBUG, "Dispached view "+view); + } + }
Modified: trunk/core/src/main/java/org/codehaus/waffle/monitor/ActionMonitor.java (357 => 358)
--- trunk/core/src/main/java/org/codehaus/waffle/monitor/ActionMonitor.java 2007-11-12 20:35:00 UTC (rev 357) +++ trunk/core/src/main/java/org/codehaus/waffle/monitor/ActionMonitor.java 2007-11-12 21:47:51 UTC (rev 358) @@ -12,8 +12,11 @@ import java.util.Set; +import javax.servlet.http.HttpServletResponse; + import org.codehaus.waffle.action.MethodDefinition; import org.codehaus.waffle.action.HierarchicalArgumentResolver.Scope; +import org.codehaus.waffle.view.View; /** * A monitor for action-related events @@ -38,4 +41,8 @@ void methodNameResolved(String methodName, String methodKey, Set<String> keys); + void responseIsCommitted(HttpServletResponse response); + + void viewDispatched(View view); + }
Modified: trunk/core/src/main/java/org/codehaus/waffle/monitor/CommonsLoggingMonitor.java (357 => 358)
--- trunk/core/src/main/java/org/codehaus/waffle/monitor/CommonsLoggingMonitor.java 2007-11-12 20:35:00 UTC (rev 357) +++ trunk/core/src/main/java/org/codehaus/waffle/monitor/CommonsLoggingMonitor.java 2007-11-12 21:47:51 UTC (rev 358) @@ -80,4 +80,5 @@ log.error(exception.getMessage(), exception); } } + }
Modified: trunk/core/src/test/java/org/codehaus/waffle/action/DefaultActionMethodResponseHandlerTest.java (357 => 358)
--- trunk/core/src/test/java/org/codehaus/waffle/action/DefaultActionMethodResponseHandlerTest.java 2007-11-12 20:35:00 UTC (rev 357) +++ trunk/core/src/test/java/org/codehaus/waffle/action/DefaultActionMethodResponseHandlerTest.java 2007-11-12 21:47:51 UTC (rev 358) @@ -56,8 +56,11 @@ }}); ViewDispatcher viewDispatcher = mockery.mock(ViewDispatcher.class); - ActionMonitor actionMonitor = mockery.mock(ActionMonitor.class); - + final ActionMonitor actionMonitor = mockery.mock(ActionMonitor.class); + mockery.checking(new Expectations() {{ + one (actionMonitor).responseIsCommitted(response); + }}); + ActionMethodResponseHandler handler = new DefaultActionMethodResponseHandler(viewDispatcher, actionMonitor); handler.handle(null, response, null); } @@ -79,9 +82,12 @@ mockery.checking(new Expectations() {{ one (viewDispatcher).dispatch(request, response, view); }}); + + final ActionMonitor actionMonitor = mockery.mock(ActionMonitor.class); + mockery.checking(new Expectations() {{ + one (actionMonitor).viewDispatched(view); + }}); - ActionMonitor actionMonitor = mockery.mock(ActionMonitor.class); - ActionMethodResponseHandler handler = new DefaultActionMethodResponseHandler(viewDispatcher, actionMonitor); handler.handle(request, response, actionMethodResponse); }
Modified: trunk/core/src/test/java/org/codehaus/waffle/testmodel/StubMonitor.java (357 => 358)
--- trunk/core/src/test/java/org/codehaus/waffle/testmodel/StubMonitor.java 2007-11-12 20:35:00 UTC (rev 357) +++ trunk/core/src/test/java/org/codehaus/waffle/testmodel/StubMonitor.java 2007-11-12 21:47:51 UTC (rev 358) @@ -2,11 +2,14 @@ import java.util.Set; +import javax.servlet.http.HttpServletResponse; + import org.codehaus.waffle.action.MethodDefinition; import org.codehaus.waffle.action.HierarchicalArgumentResolver.Scope; import org.codehaus.waffle.monitor.ActionMonitor; import org.codehaus.waffle.monitor.BindMonitor; import org.codehaus.waffle.validation.BindErrorMessage; +import org.codehaus.waffle.view.View; public class StubMonitor implements ActionMonitor, BindMonitor { @@ -40,4 +43,10 @@ public void bindFailed(Object controller, Throwable cause) { } + public void responseIsCommitted(HttpServletResponse response) { + } + + public void viewDispatched(View view) { + } + }
To unsubscribe from this list please visit:
