From 04d8589d294a08ef1e99c0fc06804343c01decaf Mon Sep 17 00:00:00 2001 From: hns Date: Thu, 18 Aug 2005 21:46:52 +0000 Subject: [PATCH] Make public fields in RequestTrans private, remove transient modifier, add getters and setters as needed, synchronize getter and setter for action to fix inconsistent behaviour. --- src/helma/framework/RequestBean.java | 4 +- src/helma/framework/RequestTrans.java | 42 +++++++++++++++---- .../framework/core/RequestEvaluator.java | 4 +- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/helma/framework/RequestBean.java b/src/helma/framework/RequestBean.java index cbde87dd..4cae0abe 100644 --- a/src/helma/framework/RequestBean.java +++ b/src/helma/framework/RequestBean.java @@ -92,7 +92,7 @@ public class RequestBean implements Serializable { // property related methods: public String getAction() { - return req.action; + return req.getAction(); } /** @@ -110,7 +110,7 @@ public class RequestBean implements Serializable { * @return ... */ public long getRuntime() { - return (System.currentTimeMillis() - req.startTime); + return (System.currentTimeMillis() - req.getStartTime()); } /** diff --git a/src/helma/framework/RequestTrans.java b/src/helma/framework/RequestTrans.java index eaf3156a..5bf17525 100644 --- a/src/helma/framework/RequestTrans.java +++ b/src/helma/framework/RequestTrans.java @@ -46,8 +46,8 @@ public class RequestTrans implements Serializable { public final static String INTERNAL = "INTERNAL"; // the servlet request and response, may be null - HttpServletRequest request; - HttpServletResponse response; + final HttpServletRequest request; + final HttpServletResponse response; // the uri path of the request public String path; @@ -56,10 +56,10 @@ public class RequestTrans implements Serializable { public String session; // the map of form and cookie data - private Map values; + private final Map values; // the HTTP request method - private String method; + private final String method; // timestamp of client-cached version, if present in request private long ifModifiedSince = -1; @@ -68,20 +68,22 @@ public class RequestTrans implements Serializable { private Set etags; // when was execution started on this request? - public transient long startTime; + private final long startTime; // the name of the action being invoked - public transient String action; - private transient String httpUsername; - private transient String httpPassword; - + private String action; + private String httpUsername; + private String httpPassword; + /** * Create a new Request transmitter with an empty data map. */ public RequestTrans(String method) { this.method = method; this.request = null; + this.response = null; values = new SystemMap(); + startTime = System.currentTimeMillis(); } /** @@ -92,6 +94,7 @@ public class RequestTrans implements Serializable { this.request = request; this.response = response; values = new SystemMap(); + startTime = System.currentTimeMillis(); } /** @@ -180,6 +183,27 @@ public class RequestTrans implements Serializable { return POST.equalsIgnoreCase(method); } + /** + * Get the request's action. + */ + public synchronized String getAction() { + return action; + } + + /** + * Set the request's action. + */ + public synchronized void setAction(String action) { + this.action = action; + } + + /** + * Get the time the request was created. + */ + public long getStartTime() { + return startTime; + } + /** * * diff --git a/src/helma/framework/core/RequestEvaluator.java b/src/helma/framework/core/RequestEvaluator.java index 362d2f5f..42faf452 100644 --- a/src/helma/framework/core/RequestEvaluator.java +++ b/src/helma/framework/core/RequestEvaluator.java @@ -160,8 +160,6 @@ public final class RequestEvaluator implements Runnable { root = app.getDataRoot(); - req.startTime = System.currentTimeMillis(); - initGlobals(root); if (error != null) { @@ -319,7 +317,7 @@ public final class RequestEvaluator implements Runnable { // beginning of execution section try { // set the req.action property, cutting off the _action suffix - req.action = action.substring(0, action.length() - 7); + req.setAction(action.substring(0, action.length() - 7)); // reset skin recursion detection counter skinDepth = 0;