diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-05-04 09:05:58 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-05-04 09:05:58 +0300 |
commit | e6738e64dc2f7db1733aa568fd2713632b9f8966 (patch) | |
tree | 1353d11c5d37ddfe4b15dd97cf11d50149d9286b /src/com/vaadin/terminal/gwt/server/RequestTimer.java | |
parent | 46c74e7362271ccbcf54c506657d8c0846a61858 (diff) | |
parent | b1ef06fdb8d1dc03dba2afb397aed89089ac5445 (diff) | |
download | vaadin-framework-e6738e64dc2f7db1733aa568fd2713632b9f8966.tar.gz vaadin-framework-e6738e64dc2f7db1733aa568fd2713632b9f8966.zip |
Merge remote branch 'origin/6.8'
Conflicts:
src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
src/com/vaadin/terminal/gwt/client/BrowserInfo.java
src/com/vaadin/terminal/gwt/client/HistoryImplIEVaadin.java
src/com/vaadin/terminal/gwt/client/ui/VButton.java
src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendar.java
src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java
src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java
src/com/vaadin/terminal/gwt/client/ui/VNotification.java
src/com/vaadin/terminal/gwt/client/ui/VView.java
src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java
src/com/vaadin/terminal/gwt/server/RequestTimer.java
src/com/vaadin/ui/Button.java
tests/test.xml
tests/testbench/com/vaadin/tests/components/TouchScrollables.java
Diffstat (limited to 'src/com/vaadin/terminal/gwt/server/RequestTimer.java')
-rw-r--r-- | src/com/vaadin/terminal/gwt/server/RequestTimer.java | 55 |
1 files changed, 9 insertions, 46 deletions
diff --git a/src/com/vaadin/terminal/gwt/server/RequestTimer.java b/src/com/vaadin/terminal/gwt/server/RequestTimer.java index d47f444bef..6c0edec466 100644 --- a/src/com/vaadin/terminal/gwt/server/RequestTimer.java +++ b/src/com/vaadin/terminal/gwt/server/RequestTimer.java @@ -4,7 +4,7 @@ package com.vaadin.terminal.gwt.server; -import com.vaadin.terminal.WrappedRequest; +import java.io.Serializable; /** * Times the handling of requests and stores the information as an attribute in @@ -14,67 +14,30 @@ import com.vaadin.terminal.WrappedRequest; * * @author Jonatan Kronqvist / Vaadin Ltd */ -public class RequestTimer { - public static final String SESSION_ATTR_ID = "REQUESTTIMER"; - +public class RequestTimer implements Serializable { private long requestStartTime = 0; - private long totalSessionTime = 0; - private long lastRequestTime = -1; /** * Starts the timing of a request. This should be called before any * processing of the request. - * - * @param request - * the request. */ - public void start(WrappedRequest request) { + public void start() { requestStartTime = System.nanoTime(); - request.setAttribute("TOTAL", totalSessionTime); - request.setAttribute("LASTREQUEST", lastRequestTime); } /** * Stops the timing of a request. This should be called when all processing * of a request has finished. + * + * @param context */ - public void stop() { + public void stop(AbstractWebApplicationContext context) { // Measure and store the total handling time. This data can be // used in TestBench 3 tests. long time = (System.nanoTime() - requestStartTime) / 1000000; - lastRequestTime = time; - totalSessionTime += time; - } - - /** - * Returns a valid request timer for the specified request. Timers are - * session bound. - * - * @param request - * the request for which to get a valid timer. - * @return a valid timer. - */ - public static RequestTimer get(WrappedRequest request) { - RequestTimer timer = (RequestTimer) request - .getSessionAttribute(SESSION_ATTR_ID); - if (timer == null) { - timer = new RequestTimer(); - } - return timer; - } - /** - * Associates the specified request timer with the specified request. Since - * {@link #get(RequestWrapper)} will, at one point or another, return a new - * instance, this method should be called to keep the request <-> timer - * association updated. - * - * @param request - * the request for which to set the timer. - * @param requestTimer - * the timer. - */ - public static void set(WrappedRequest request, RequestTimer requestTimer) { - request.setSessionAttribute(RequestTimer.SESSION_ATTR_ID, requestTimer); + // The timings must be stored in the context, since a new + // RequestTimer is created for every request. + context.setLastRequestTime(time); } } |