You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2006/07/30 16:41:59 UTC

svn commit: r426888 - in /jakarta/httpcomponents/httpcore/trunk/src: java/org/apache/http/protocol/HttpExecutionContext.java java/org/apache/http/protocol/SyncHttpExecutionContext.java test/org/apache/http/protocol/TestHttpExecutionContext.java

Author: olegk
Date: Sun Jul 30 07:41:59 2006
New Revision: 426888

URL: http://svn.apache.org/viewvc?rev=426888&view=rev
Log:
Added a thread-safe implementation of HttpContext

Added:
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/SyncHttpExecutionContext.java   (with props)
Modified:
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/HttpExecutionContext.java
    jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestHttpExecutionContext.java

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/HttpExecutionContext.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/HttpExecutionContext.java?rev=426888&r1=426887&r2=426888&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/HttpExecutionContext.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/HttpExecutionContext.java Sun Jul 30 07:41:59 2006
@@ -32,7 +32,6 @@
 import java.util.HashMap;
 import java.util.Map;
 
-
 /**
  * Default implementation of the {@link HttpContext HttpContext}.
  *

Added: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/SyncHttpExecutionContext.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/SyncHttpExecutionContext.java?rev=426888&view=auto
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/SyncHttpExecutionContext.java (added)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/SyncHttpExecutionContext.java Sun Jul 30 07:41:59 2006
@@ -0,0 +1,59 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.protocol;
+
+/**
+ * Thread-safe extension of the {@link HttpExecutionContext}.
+ *
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ * 
+ * @since 4.0
+ */
+public class SyncHttpExecutionContext extends HttpExecutionContext {
+    
+    public SyncHttpExecutionContext(final HttpContext parentContext) {
+        super(parentContext);
+    }
+    
+    public synchronized Object getAttribute(final String id) {
+        return super.getAttribute(id);
+    }
+
+    public synchronized void setAttribute(final String id, final Object obj) {
+        super.setAttribute(id, obj);
+    }
+    
+    public synchronized Object removeAttribute(final String id) {
+        return super.removeAttribute(id);
+    }
+
+}

Propchange: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/SyncHttpExecutionContext.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/SyncHttpExecutionContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestHttpExecutionContext.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestHttpExecutionContext.java?rev=426888&r1=426887&r2=426888&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestHttpExecutionContext.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestHttpExecutionContext.java Sun Jul 30 07:41:59 2006
@@ -50,8 +50,8 @@
     }
 
     public void testContextOperations() {
-        HttpExecutionContext parentContext = new HttpExecutionContext(null); 
-        HttpExecutionContext currentContext = new HttpExecutionContext(parentContext); 
+        HttpContext parentContext = new SyncHttpExecutionContext(null); 
+        HttpContext currentContext = new SyncHttpExecutionContext(parentContext); 
 
         parentContext.setAttribute("param1", "1");
         parentContext.setAttribute("param2", "2");
@@ -79,14 +79,14 @@
     }
 
     public void testEmptyContextOperations() {
-        HttpExecutionContext currentContext = new HttpExecutionContext(null); 
+        HttpContext currentContext = new SyncHttpExecutionContext(null); 
         assertEquals(null, currentContext.getAttribute("param1"));
         currentContext.removeAttribute("param1");
         assertEquals(null, currentContext.getAttribute("param1"));
     }
 
     public void testContextInvalidInput() throws Exception {
-        HttpExecutionContext currentContext = new HttpExecutionContext(null); 
+        HttpContext currentContext = new SyncHttpExecutionContext(null); 
         try {
             currentContext.setAttribute(null, null);
             fail("IllegalArgumentException should have been thrown");