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.
This commit is contained in:
hns 2005-08-18 21:46:52 +00:00
parent 97c5399c9b
commit 04d8589d29
3 changed files with 36 additions and 14 deletions

View file

@ -92,7 +92,7 @@ public class RequestBean implements Serializable {
// property related methods: // property related methods:
public String getAction() { public String getAction() {
return req.action; return req.getAction();
} }
/** /**
@ -110,7 +110,7 @@ public class RequestBean implements Serializable {
* @return ... * @return ...
*/ */
public long getRuntime() { public long getRuntime() {
return (System.currentTimeMillis() - req.startTime); return (System.currentTimeMillis() - req.getStartTime());
} }
/** /**

View file

@ -46,8 +46,8 @@ public class RequestTrans implements Serializable {
public final static String INTERNAL = "INTERNAL"; public final static String INTERNAL = "INTERNAL";
// the servlet request and response, may be null // the servlet request and response, may be null
HttpServletRequest request; final HttpServletRequest request;
HttpServletResponse response; final HttpServletResponse response;
// the uri path of the request // the uri path of the request
public String path; public String path;
@ -56,10 +56,10 @@ public class RequestTrans implements Serializable {
public String session; public String session;
// the map of form and cookie data // the map of form and cookie data
private Map values; private final Map values;
// the HTTP request method // the HTTP request method
private String method; private final String method;
// timestamp of client-cached version, if present in request // timestamp of client-cached version, if present in request
private long ifModifiedSince = -1; private long ifModifiedSince = -1;
@ -68,12 +68,12 @@ public class RequestTrans implements Serializable {
private Set etags; private Set etags;
// when was execution started on this request? // when was execution started on this request?
public transient long startTime; private final long startTime;
// the name of the action being invoked // the name of the action being invoked
public transient String action; private String action;
private transient String httpUsername; private String httpUsername;
private transient String httpPassword; private String httpPassword;
/** /**
* Create a new Request transmitter with an empty data map. * Create a new Request transmitter with an empty data map.
@ -81,7 +81,9 @@ public class RequestTrans implements Serializable {
public RequestTrans(String method) { public RequestTrans(String method) {
this.method = method; this.method = method;
this.request = null; this.request = null;
this.response = null;
values = new SystemMap(); values = new SystemMap();
startTime = System.currentTimeMillis();
} }
/** /**
@ -92,6 +94,7 @@ public class RequestTrans implements Serializable {
this.request = request; this.request = request;
this.response = response; this.response = response;
values = new SystemMap(); values = new SystemMap();
startTime = System.currentTimeMillis();
} }
/** /**
@ -180,6 +183,27 @@ public class RequestTrans implements Serializable {
return POST.equalsIgnoreCase(method); 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;
}
/** /**
* *
* *

View file

@ -160,8 +160,6 @@ public final class RequestEvaluator implements Runnable {
root = app.getDataRoot(); root = app.getDataRoot();
req.startTime = System.currentTimeMillis();
initGlobals(root); initGlobals(root);
if (error != null) { if (error != null) {
@ -319,7 +317,7 @@ public final class RequestEvaluator implements Runnable {
// beginning of execution section // beginning of execution section
try { try {
// set the req.action property, cutting off the _action suffix // 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 // reset skin recursion detection counter
skinDepth = 0; skinDepth = 0;