You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by as...@apache.org on 2008/12/17 00:34:24 UTC

svn commit: r727216 - in /jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client: AbstractHttpClient.java RemoteHttpCacheDispatcher.java

Author: asmuts
Date: Tue Dec 16 15:34:24 2008
New Revision: 727216

URL: http://svn.apache.org/viewvc?rev=727216&view=rev
Log:
encapsulated the client and forced children to go through the base process method.

Modified:
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/AbstractHttpClient.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/AbstractHttpClient.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/AbstractHttpClient.java?rev=727216&r1=727215&r2=727216&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/AbstractHttpClient.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/AbstractHttpClient.java Tue Dec 16 15:34:24 2008
@@ -19,7 +19,11 @@
  * under the License.
  */
 
+import java.io.IOException;
+
 import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HttpState;
 import org.apache.commons.httpclient.HttpVersion;
 import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
 import org.apache.commons.httpclient.cookie.CookiePolicy;
@@ -105,9 +109,44 @@
     }
 
     /**
+     * Extracted method that can be overwritten to do additional things to the post before the call
+     * is made.
+     * <p>
+     * @param post the post that is about to get executed.
+     * @throws IOException on i/o error
+     */
+    protected final void doWebserviceCall( HttpMethod post )
+        throws IOException
+    {
+        HttpState httpState = preProcessWebserviceCall( post );
+        getHttpClient().executeMethod( null, post, httpState );
+        postProcessWebserviceCall( post, httpState );
+    }
+
+    /**
+     * Called before the executeMethod on the client.
+     * <p>
+     * @param post http method
+     * @return HttpState
+     * @throws IOException
+     */
+    public abstract HttpState preProcessWebserviceCall( HttpMethod post )
+        throws IOException;
+
+    /**
+     * Called after the executeMethod on the client.
+     * <p>
+     * @param post http method
+     * @param httpState state
+     * @throws IOException
+     */
+    public abstract void postProcessWebserviceCall( HttpMethod post, HttpState httpState )
+        throws IOException;
+    
+    /**
      * @return Returns the httpClient.
      */
-    public HttpClient getHttpClient()
+    private HttpClient getHttpClient()
     {
         return httpClient;
     }
@@ -115,7 +154,7 @@
     /**
      * @param httpClient The httpClient to set.
      */
-    public void setHttpClient( HttpClient httpClient )
+    private void setHttpClient( HttpClient httpClient )
     {
         this.httpClient = httpClient;
     }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java?rev=727216&r1=727215&r2=727216&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java Tue Dec 16 15:34:24 2008
@@ -116,7 +116,7 @@
         PostMethod post = new PostMethod( url );
         RequestEntity requestEntity = new ByteArrayRequestEntity( requestAsByteArray );
         post.setRequestEntity( requestEntity );
-        getHttpClient().executeMethod( post );
+        doWebserviceCall( post );
         byte[] response = post.getResponseBody();
         return response;
     }
@@ -197,21 +197,6 @@
     }
 
     /**
-     * Extracted method that can be overwritten to do additional things to the post before the call
-     * is made.
-     * <p>
-     * @param post the post that is about to get executed.
-     * @throws IOException on i/o error
-     */
-    protected final void doWebserviceCall( HttpMethod post )
-        throws IOException
-    {
-        HttpState httpState = preProcessWebserviceCall( post );
-        getHttpClient().executeMethod( null, post, httpState );
-        postProcessWebserviceCall( post, httpState );
-    }
-
-    /**
      * Called before the executeMethod on the client.
      * <p>
      * @param post http method



---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-dev-help@jakarta.apache.org