Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.remoting.httpinvoker
Class AbstractHttpInvokerRequestExecutor

    java.lang.Object
      org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor

All Implemented Interfaces:
  Aware, BeanClassLoaderAware, HttpInvokerRequestExecutor

Direct Known Subclasses:
  CommonsHttpInvokerRequestExecutor, HttpComponentsHttpInvokerRequestExecutor, SimpleHttpInvokerRequestExecutor

    public abstract class AbstractHttpInvokerRequestExecutor

extends java.lang.Object
implements HttpInvokerRequestExecutor, BeanClassLoaderAware

Abstract base implementation of the HttpInvokerRequestExecutor interface.

Pre-implements serialization of RemoteInvocation objects and deserialization of RemoteInvocationResults objects.

Since:
  1.1
Author:
  Juergen Hoeller
See Also:
  `doExecuteRequest(org.springframework.remoting.httpinvoker.HttpInvokerClientConfiguration, java.io.ByteArrayOutputStream)`

Field Summary
`static java.lang.String` | `CONTENT_TYPE_SERIALIZED_OBJECT` Default content type: "application/x-java-serialized-object"
`protected static java.lang.String` | `ENCODING_GZIP`
`protected static java.lang.String` | `HTTP_HEADER_ACCEPT_ENCODING`
`protected static java.lang.String` | `HTTP_HEADER_ACCEPT_LANGUAGE`
`protected static java.lang.String` | `HTTP_HEADER_CONTENT_ENCODING`
`protected static java.lang.String` | `HTTP_HEADER_CONTENT_LENGTH`
`protected static java.lang.String` | `HTTP_HEADER_CONTENT_TYPE`
`protected static java.lang.String` | `HTTP_METHOD_POST`
`protected org.apache.commons.logging.Log` | `logger`

Constructor Summary
`AbstractHttpInvokerRequestExecutor()`

Method Summary
`protected java.io.ObjectInputStream` | `createObjectInputStream(java.io.InputStream is, java.lang.String codebaseUrl)` Create an ObjectInputStream for the given InputStream and codebase.
`protected java.io.InputStream` | `decorateInputStream(java.io.InputStream is)` Return the InputStream to use for reading remote invocation results, potentially decorating the given original InputStream.
`protected java.io.OutputStream` | `decorateOutputStream(java.io.OutputStream os)` Return the OutputStream to use for writing remote invocations, potentially decorating the given original OutputStream.
`protected abstract RemoteInvocationResult` | `doExecuteRequest(HttpInvokerClientConfiguration config, java.io.ByteArrayOutputStream baos)` Execute a request to send the given serialized remote invocation.
`protected RemoteInvocationResult` | `doReadRemoteInvocationResult(java.io.ObjectInputStream ois)` Perform the actual reading of an invocation object from the given ObjectInputStream.
`protected void` | `doWriteRemoteInvocation(RemoteInvocation invocation, java.io.ObjectOutputStream oos)` Perform the actual writing of the given invocation object to the given ObjectOutputStream.
`RemoteInvocationResult` | `executeRequest(HttpInvokerClientConfiguration config, RemoteInvocation invocation)` Execute a request to send the given remote invocation.
`protected java.lang.ClassLoader` | `getBeanClassLoader()` Return the bean ClassLoader that this executor is supposed to use.
`protected java.io.ByteArrayOutputStream` | `getByteArrayOutputStream(RemoteInvocation invocation)` Serialize the given RemoteInvocation into a ByteArrayOutputStream.
`java.lang.String` | `getContentType()` Return the content type to use for sending HTTP invoker requests.
`boolean` | `isAcceptGzipEncoding()` Return whether to accept GZIP encoding, that is, whether to send the HTTP "Accept-Encoding" header with "gzip" as value.
`protected RemoteInvocationResult` | `readRemoteInvocationResult(java.io.InputStream is, java.lang.String codebaseUrl)` Deserialize a RemoteInvocationResult object from the given InputStream.
`void` | `setAcceptGzipEncoding(boolean acceptGzipEncoding)` Set whether to accept GZIP encoding, that is, whether to send the HTTP "Accept-Encoding" header with "gzip" as value.
`void` | `setBeanClassLoader(java.lang.ClassLoader classLoader)` Callback that supplies the bean `class loader` to a bean instance.
`void` | `setContentType(java.lang.String contentType)` Specify the content type to use for sending HTTP invoker requests.
`protected void` | `writeRemoteInvocation(RemoteInvocation invocation, java.io.OutputStream os)` Serialize the given RemoteInvocation to the given OutputStream.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### CONTENT_TYPE_SERIALIZED_OBJECT

    public static final java.lang.String CONTENT_TYPE_SERIALIZED_OBJECT

  Default content type: "application/x-java-serialized-object"

  See Also:
    Constant Field Values

### HTTP_METHOD_POST

    protected static final java.lang.String HTTP_METHOD_POST

See Also:
  Constant Field Values

### HTTP_HEADER_ACCEPT_LANGUAGE

    protected static final java.lang.String HTTP_HEADER_ACCEPT_LANGUAGE

See Also:
  Constant Field Values

### HTTP_HEADER_ACCEPT_ENCODING

    protected static final java.lang.String HTTP_HEADER_ACCEPT_ENCODING

See Also:
  Constant Field Values

### HTTP_HEADER_CONTENT_ENCODING

    protected static final java.lang.String HTTP_HEADER_CONTENT_ENCODING

See Also:
  Constant Field Values

### HTTP_HEADER_CONTENT_TYPE

    protected static final java.lang.String HTTP_HEADER_CONTENT_TYPE

See Also:
  Constant Field Values

### HTTP_HEADER_CONTENT_LENGTH

    protected static final java.lang.String HTTP_HEADER_CONTENT_LENGTH

See Also:
  Constant Field Values

### ENCODING_GZIP

    protected static final java.lang.String ENCODING_GZIP

See Also:
  Constant Field Values

### logger

    protected final org.apache.commons.logging.Log logger

Constructor Detail

### AbstractHttpInvokerRequestExecutor

    public AbstractHttpInvokerRequestExecutor()

Method Detail

### setContentType

    public void setContentType(java.lang.String contentType)

  Specify the content type to use for sending HTTP invoker requests.

  Default is "application/x-java-serialized-object".

### getContentType

    public java.lang.String getContentType()

  Return the content type to use for sending HTTP invoker requests.

### setAcceptGzipEncoding

    public void setAcceptGzipEncoding(boolean acceptGzipEncoding)

  Set whether to accept GZIP encoding, that is, whether to send the HTTP "Accept-Encoding" header with "gzip" as value.

  Default is "true". Turn this flag off if you do not want GZIP response compression even if enabled on the HTTP server.

### isAcceptGzipEncoding

    public boolean isAcceptGzipEncoding()

  Return whether to accept GZIP encoding, that is, whether to send the HTTP "Accept-Encoding" header with "gzip" as value.

### setBeanClassLoader

    public void setBeanClassLoader(java.lang.ClassLoader classLoader)

  Description copied from interface: `BeanClassLoaderAware`
  Callback that supplies the bean `class loader` to a bean instance.

  Invoked after the population of normal bean properties but before an initialization callback such as `InitializingBean's` `InitializingBean.afterPropertiesSet()` method or a custom init-method.

  Specified by:
    `setBeanClassLoader` in interface `BeanClassLoaderAware`
  Parameters:
    `classLoader` - the owning class loader; may be `null` in which case a default `ClassLoader` must be used, for example the `ClassLoader` obtained via `ClassUtils.getDefaultClassLoader()`

### getBeanClassLoader

    protected java.lang.ClassLoader getBeanClassLoader()

  Return the bean ClassLoader that this executor is supposed to use.

### executeRequest

    public final RemoteInvocationResult executeRequest(HttpInvokerClientConfiguration config,
                                                       RemoteInvocation invocation)
                                                throws java.lang.Exception

  Description copied from interface: `HttpInvokerRequestExecutor`
  Execute a request to send the given remote invocation.

  Specified by:
    `executeRequest` in interface `HttpInvokerRequestExecutor`
  Parameters:
    `config` - the HTTP invoker configuration that specifies the target service
    `invocation` - the RemoteInvocation to execute
  Returns:
    the RemoteInvocationResult object
  Throws:
    `java.io.IOException` - if thrown by I/O operations
    `java.lang.ClassNotFoundException` - if thrown during deserialization
    `java.lang.Exception` - in case of general errors

### getByteArrayOutputStream

    protected java.io.ByteArrayOutputStream getByteArrayOutputStream(RemoteInvocation invocation)
                                                              throws java.io.IOException

  Serialize the given RemoteInvocation into a ByteArrayOutputStream.

  Parameters:
    `invocation` - the RemoteInvocation object
  Returns:
    a ByteArrayOutputStream with the serialized RemoteInvocation
  Throws:
    `java.io.IOException` - if thrown by I/O methods

### writeRemoteInvocation

    protected void writeRemoteInvocation(RemoteInvocation invocation,
                                         java.io.OutputStream os)
                                  throws java.io.IOException

  Serialize the given RemoteInvocation to the given OutputStream.

  The default implementation gives `decorateOutputStream` a chance to decorate the stream first (for example, for custom encryption or compression). Creates an `ObjectOutputStream` for the final stream and calls `doWriteRemoteInvocation` to actually write the object.

  Can be overridden for custom serialization of the invocation.

  Parameters:
    `invocation` - the RemoteInvocation object
    `os` - the OutputStream to write to
  Throws:
    `java.io.IOException` - if thrown by I/O methods
  See Also:
    `decorateOutputStream(java.io.OutputStream)`, `doWriteRemoteInvocation(org.springframework.remoting.support.RemoteInvocation, java.io.ObjectOutputStream)`

### decorateOutputStream

    protected java.io.OutputStream decorateOutputStream(java.io.OutputStream os)
                                                 throws java.io.IOException

  Return the OutputStream to use for writing remote invocations, potentially decorating the given original OutputStream.

  The default implementation returns the given stream as-is. Can be overridden, for example, for custom encryption or compression.

  Parameters:
    `os` - the original OutputStream
  Returns:
    the potentially decorated OutputStream
  Throws:
    `java.io.IOException`

### doWriteRemoteInvocation

    protected void doWriteRemoteInvocation(RemoteInvocation invocation,
                                           java.io.ObjectOutputStream oos)
                                    throws java.io.IOException

  Perform the actual writing of the given invocation object to the given ObjectOutputStream.

  The default implementation simply calls `writeObject`. Can be overridden for serialization of a custom wrapper object rather than the plain invocation, for example an encryption-aware holder.

  Parameters:
    `invocation` - the RemoteInvocation object
    `oos` - the ObjectOutputStream to write to
  Throws:
    `java.io.IOException` - if thrown by I/O methods
  See Also:
    `ObjectOutputStream.writeObject(java.lang.Object)`

### doExecuteRequest

    protected abstract RemoteInvocationResult doExecuteRequest(HttpInvokerClientConfiguration config,
                                                               java.io.ByteArrayOutputStream baos)
                                                        throws java.lang.Exception

  Execute a request to send the given serialized remote invocation.

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

  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:
    `java.io.IOException` - if thrown by I/O operations
    `java.lang.ClassNotFoundException` - if thrown during deserialization
    `java.lang.Exception` - in case of general errors
  See Also:
    `readRemoteInvocationResult(java.io.InputStream, String)`

### readRemoteInvocationResult

    protected RemoteInvocationResult readRemoteInvocationResult(java.io.InputStream is,
                                                                java.lang.String codebaseUrl)
                                                         throws java.io.IOException,
                                                                java.lang.ClassNotFoundException

  Deserialize a RemoteInvocationResult object from the given InputStream.

  Gives `decorateInputStream` a chance to decorate the stream first (for example, for custom encryption or compression). Creates an `ObjectInputStream` via `createObjectInputStream` and calls `doReadRemoteInvocationResult` to actually read the object.

  Can be overridden for custom serialization of the invocation.

  Parameters:
    `is` - the InputStream to read from
    `codebaseUrl` - the codebase URL to load classes from if not found locally
  Returns:
    the RemoteInvocationResult object
  Throws:
    `java.io.IOException` - if thrown by I/O methods
    `java.lang.ClassNotFoundException` - if thrown during deserialization
  See Also:
    `decorateInputStream(java.io.InputStream)`, `createObjectInputStream(java.io.InputStream, java.lang.String)`, `doReadRemoteInvocationResult(java.io.ObjectInputStream)`

### decorateInputStream

    protected java.io.InputStream decorateInputStream(java.io.InputStream is)
                                               throws java.io.IOException

  Return the InputStream to use for reading remote invocation results, potentially decorating the given original InputStream.

  The default implementation returns the given stream as-is. Can be overridden, for example, for custom encryption or compression.

  Parameters:
    `is` - the original InputStream
  Returns:
    the potentially decorated InputStream
  Throws:
    `java.io.IOException`

### createObjectInputStream

    protected java.io.ObjectInputStream createObjectInputStream(java.io.InputStream is,
                                                                java.lang.String codebaseUrl)
                                                         throws java.io.IOException

  Create an ObjectInputStream for the given InputStream and codebase. The default implementation creates a CodebaseAwareObjectInputStream.

  Parameters:
    `is` - the InputStream to read from
    `codebaseUrl` - the codebase URL to load classes from if not found locally (can be `null`)
  Returns:
    the new ObjectInputStream instance to use
  Throws:
    `java.io.IOException` - if creation of the ObjectInputStream failed
  See Also:
    `CodebaseAwareObjectInputStream`

### doReadRemoteInvocationResult

    protected RemoteInvocationResult doReadRemoteInvocationResult(java.io.ObjectInputStream ois)
                                                           throws java.io.IOException,
                                                                  java.lang.ClassNotFoundException

  Perform the actual reading of an invocation object from the given ObjectInputStream.

  The default implementation simply calls `readObject`. Can be overridden for deserialization of a custom wrapper object rather than the plain invocation, for example an encryption-aware holder.

  Parameters:
    `ois` - the ObjectInputStream to read from
  Returns:
    the RemoteInvocationResult object
  Throws:
    `java.io.IOException` - if thrown by I/O methods
    `java.lang.ClassNotFoundException` - if the class name of a serialized object couldn't get resolved
  See Also:
    `ObjectOutputStream.writeObject(java.lang.Object)`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD