org.springframework.remoting.httpinvoker
Class CommonsHttpInvokerRequestExecutor

java.lang.Object
  extended byorg.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor
      extended byorg.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor
All Implemented Interfaces:
HttpInvokerRequestExecutor

public class CommonsHttpInvokerRequestExecutor
extends AbstractHttpInvokerRequestExecutor

HttpInvokerRequestExecutor implementation that uses Jakarta Commons HttpClient to execute POST requests.

Allows to use a preconfigured HttpClient instance, potentially with authentication, HTTP connection pooling, etc.

Since:
1.1
Author:
Juergen Hoeller
See Also:
SimpleHttpInvokerRequestExecutor

Field Summary
 
Fields inherited from class org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor
CONTENT_TYPE_SERIALIZED_OBJECT, HTTP_HEADER_CONTENT_LENGTH, HTTP_HEADER_CONTENT_TYPE, HTTP_METHOD_POST, logger
 
Constructor Summary
CommonsHttpInvokerRequestExecutor()
          Create a new CommonsHttpInvokerRequestExecutor with a default HttpClient that uses a default MultiThreadedHttpConnectionManager.
CommonsHttpInvokerRequestExecutor(HttpClient httpClient)
          Create a new CommonsHttpInvokerRequestExecutor with the given HttpClient instance.
 
Method Summary
protected  PostMethod createPostMethod(HttpInvokerClientConfiguration config)
          Create a PostMethod for the given configuration.
protected  RemoteInvocationResult doExecuteRequest(HttpInvokerClientConfiguration config, ByteArrayOutputStream baos)
          Execute a request to send the given serialized remote invocation.
protected  void executePostMethod(HttpInvokerClientConfiguration config, HttpClient httpClient, PostMethod postMethod)
          Execute the given PostMethod instance.
 HttpClient getHttpClient()
          Return the HttpClient instance that this request executor uses.
 void setHttpClient(HttpClient httpClient)
          Set the HttpClient instance to use for this request executor.
 
Methods inherited from class org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor
createObjectInputStream, decorateInputStream, decorateOutputStream, doReadRemoteInvocationResult, doWriteRemoteInvocation, executeRequest, getByteArrayOutputStream, readRemoteInvocationResult, readRemoteInvocationResult, writeRemoteInvocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommonsHttpInvokerRequestExecutor

public CommonsHttpInvokerRequestExecutor()
Create a new CommonsHttpInvokerRequestExecutor with a default HttpClient that uses a default MultiThreadedHttpConnectionManager.

See Also:
HttpClient, MultiThreadedHttpConnectionManager

CommonsHttpInvokerRequestExecutor

public CommonsHttpInvokerRequestExecutor(HttpClient httpClient)
Create a new CommonsHttpInvokerRequestExecutor with the given HttpClient instance.

Parameters:
httpClient - the HttpClient instance to use for this request executor
Method Detail

setHttpClient

public void setHttpClient(HttpClient httpClient)
Set the HttpClient instance to use for this request executor.


getHttpClient

public HttpClient getHttpClient()
Return the HttpClient instance that this request executor uses.


doExecuteRequest

protected RemoteInvocationResult doExecuteRequest(HttpInvokerClientConfiguration config,
                                                  ByteArrayOutputStream baos)
                                           throws IOException,
                                                  ClassNotFoundException
Description copied from class: AbstractHttpInvokerRequestExecutor
Execute a request to send the given serialized remote invocation.

Implementations will usually call readRemoteInvocationResult to deserialize a returned RemoteInvocationResult object.

Specified by:
doExecuteRequest in class AbstractHttpInvokerRequestExecutor
Parameters:
config - the HTTP invoker configuration that specifies the target service
baos - the ByteArrayOutputStream that contains the serialized RemoteInvocation object
Returns:
the RemoteInvocationResult object
Throws:
ClassNotFoundException - if thrown during deserialization
IOException - if thrown by I/O operations
See Also:
AbstractHttpInvokerRequestExecutor.readRemoteInvocationResult(java.io.InputStream, String)

createPostMethod

protected PostMethod createPostMethod(HttpInvokerClientConfiguration config)
                               throws IOException
Create a PostMethod for the given configuration.

Parameters:
config - the HTTP invoker configuration that specifies the target service
Returns:
the PostMethod instance
Throws:
IOException - if thrown by I/O methods

executePostMethod

protected void executePostMethod(HttpInvokerClientConfiguration config,
                                 HttpClient httpClient,
                                 PostMethod postMethod)
                          throws IOException
Execute the given PostMethod instance.

Parameters:
config - the HTTP invoker configuration that specifies the target service
httpClient - the HttpClient to execute on
postMethod - the PostMethod to execute
Throws:
IOException - if thrown by I/O methods


Copyright (C) 2003-2004 The Spring Framework Project.