Author: remm
Date: Mon Apr 16 18:52:50 2007
New Revision: 529466
URL: http://svn.apache.org/viewvc?view=rev&rev=529466
Log:
- Code cleanup (less thread local manipulation).
- Submitted by Arvind Srinivasan.
Modified:
tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationContext.java
Modified:
tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationContext.java
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationContext.java?view=diff&rev=529466&r1=529465&r2=529466
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationContext.java
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationContext.java
Mon Apr 16 18:52:50 2007
@@ -137,15 +137,10 @@
/**
- * Thread local mapping data.
+ * Thread local data used during request dispatch.
*/
- private ThreadLocal localMappingData = new ThreadLocal();
-
-
- /**
- * Thread local URI message bytes.
- */
- private ThreadLocal localUriMB = new ThreadLocal();
+ private ThreadLocal<DispatchData> dispatchData =
+ new ThreadLocal<DispatchData>();
// --------------------------------------------------------- Public Methods
@@ -377,17 +372,16 @@
if (path == null)
return (null);
- // Retrieve the thread local URI
- MessageBytes uriMB = (MessageBytes) localUriMB.get();
- if (uriMB == null) {
- uriMB = MessageBytes.newInstance();
- CharChunk uriCC = uriMB.getCharChunk();
- uriCC.setLimit(-1);
- localUriMB.set(uriMB);
- } else {
- uriMB.recycle();
+ // Use the thread local URI and mapping data
+ DispatchData dd = dispatchData.get();
+ if (dd == null) {
+ dd = new DispatchData();
+ dispatchData.set(dd);
}
+ MessageBytes uriMB = dd.uriMB;
+ uriMB.recycle();
+
// Get query string
String queryString = null;
int pos = path.indexOf('?');
@@ -397,12 +391,8 @@
pos = path.length();
}
- // Retrieve the thread local mapping data
- MappingData mappingData = (MappingData) localMappingData.get();
- if (mappingData == null) {
- mappingData = new MappingData();
- localMappingData.set(mappingData);
- }
+ // Use the thread local mapping data
+ MappingData mappingData = dd.mappingData;
// Map the URI
CharChunk uriCC = uriMB.getCharChunk();
@@ -960,6 +950,24 @@
return "/" + hostName + "/" + path;
else
return "/" + hostName + path;
+ }
+
+
+ /**
+ * Internal class used as thread-local storage when doing path
+ * mapping during dispatch.
+ */
+ private final class DispatchData {
+
+ public MessageBytes uriMB;
+ public MappingData mappingData;
+
+ public DispatchData() {
+ uriMB = MessageBytes.newInstance();
+ CharChunk uriCC = uriMB.getCharChunk();
+ uriCC.setLimit(-1);
+ mappingData = new MappingData();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]