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

## org.springframework.remoting.httpinvoker
Class HttpInvokerServiceExporter

    java.lang.Object
      org.springframework.remoting.support.RemoteExporter
          org.springframework.remoting.support.RemoteInvocationBasedExporter
              org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter

All Implemented Interfaces:
  BeanClassLoaderAware, InitializingBean, HttpRequestHandler

    public class HttpInvokerServiceExporter

extends RemoteInvocationBasedExporter
implements HttpRequestHandler, InitializingBean

HTTP request handler that exports the specified service bean as HTTP invoker service endpoint, accessible via an HTTP invoker proxy.

Deserializes remote invocation objects and serializes remote invocation result objects. Uses Java serialization just like RMI, but provides the same ease of setup as Caucho's HTTP-based Hessian and Burlap protocols.

HTTP invoker is the recommended protocol for Java-to-Java remoting. It is more powerful and more extensible than Hessian and Burlap, at the expense of being tied to Java. Nevertheless, it is as easy to set up as Hessian and Burlap, which is its main advantage compared to RMI.

Since:
  1.1
Author:
  Juergen Hoeller
See Also:
  `HttpInvokerClientInterceptor`, `HttpInvokerProxyFactoryBean`, `RmiServiceExporter`, `HessianServiceExporter`, `BurlapServiceExporter`

Field Summary
`static String` | `CONTENT_TYPE_SERIALIZED_OBJECT` Default content type: "application/x-java-serialized-object"

Fields inherited from class org.springframework.remoting.support.RemoteExporter
`logger`

Constructor Summary
`HttpInvokerServiceExporter()`

Method Summary
`void` | `afterPropertiesSet()` Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
`protected ObjectInputStream` | `createObjectInputStream(InputStream is)` Create an ObjectInputStream for the given InputStream.
`protected ObjectOutputStream` | `createObjectOutputStream(OutputStream os)` Create an ObjectOutputStream for the given OutputStream.
`protected InputStream` | `decorateInputStream(HttpServletRequest request, InputStream is)` Return the InputStream to use for reading remote invocations, potentially decorating the given original InputStream.
`protected OutputStream` | `decorateOutputStream(HttpServletRequest request, HttpServletResponse response, OutputStream os)` Return the OutputStream to use for writing remote invocation results, potentially decorating the given original OutputStream.
`protected RemoteInvocation` | `doReadRemoteInvocation(ObjectInputStream ois)` Perform the actual reading of an invocation result object from the given ObjectInputStream.
`protected void` | `doWriteRemoteInvocationResult(RemoteInvocationResult result, ObjectOutputStream oos)` Perform the actual writing of the given invocation result object to the given ObjectOutputStream.
`String` | `getContentType()` Return the content type to use for sending HTTP invoker responses.
`void` | `handleRequest(HttpServletRequest request, HttpServletResponse response)` Reads a remote invocation from the request, executes it, and writes the remote invocation result to the response.
`void` | `prepare()` Initialize this service exporter.
`protected RemoteInvocation` | `readRemoteInvocation(HttpServletRequest request)` Read a RemoteInvocation from the given HTTP request.
`protected RemoteInvocation` | `readRemoteInvocation(HttpServletRequest request, InputStream is)` Deserialize a RemoteInvocation object from the given InputStream.
`void` | `setContentType(String contentType)` Specify the content type to use for sending HTTP invoker responses.
`protected void` | `writeRemoteInvocationResult(HttpServletRequest request, HttpServletResponse response, RemoteInvocationResult result)` Write the given RemoteInvocationResult to the given HTTP response.
`protected void` | `writeRemoteInvocationResult(HttpServletRequest request, HttpServletResponse response, RemoteInvocationResult result, OutputStream os)` Serialize the given RemoteInvocation to the given OutputStream.

Methods inherited from class org.springframework.remoting.support.RemoteInvocationBasedExporter
`getRemoteInvocationExecutor, invoke, invokeAndCreateResult, setRemoteInvocationExecutor`

Methods inherited from class org.springframework.remoting.support.RemoteExporter
`checkService, checkServiceInterface, getExporterName, getProxyForService, getService, getServiceInterface, isRegisterTraceInterceptor, setBeanClassLoader, setRegisterTraceInterceptor, setService, setServiceInterface`

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 String CONTENT_TYPE_SERIALIZED_OBJECT

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

  See Also:
    Constant Field Values

Constructor Detail

### HttpInvokerServiceExporter

    public HttpInvokerServiceExporter()

Method Detail

### setContentType

    public void setContentType(String contentType)

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

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

### getContentType

    public String getContentType()

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

### afterPropertiesSet

    public void afterPropertiesSet()

  Description copied from interface: `InitializingBean`
  Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

  This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

  Specified by:
    `afterPropertiesSet` in interface `InitializingBean`

### prepare

    public void prepare()

  Initialize this service exporter.

### handleRequest

    public void handleRequest(HttpServletRequest request,
                              HttpServletResponse response)
                       throws ServletException,
                              IOException

  Reads a remote invocation from the request, executes it, and writes the remote invocation result to the response.

  Specified by:
    `handleRequest` in interface `HttpRequestHandler`
  Parameters:
    `request` - current HTTP request
    `response` - current HTTP response
  Throws:
    `ServletException` - in case of general errors
    `IOException` - in case of I/O errors
  See Also:
    `readRemoteInvocation(HttpServletRequest)`, `RemoteInvocationBasedExporter.invokeAndCreateResult(org.springframework.remoting.support.RemoteInvocation, Object)`, `writeRemoteInvocationResult(HttpServletRequest, HttpServletResponse, RemoteInvocationResult)`

### readRemoteInvocation

    protected RemoteInvocation readRemoteInvocation(HttpServletRequest request)
                                             throws IOException,
                                                    ClassNotFoundException

  Read a RemoteInvocation from the given HTTP request.

  Delegates to `readRemoteInvocation(javax.servlet.http.HttpServletRequest, java.io.InputStream)` with the `servlet request's input stream`.

  Parameters:
    `request` - current HTTP request
  Returns:
    the RemoteInvocation object
  Throws:
    `IOException` - in case of I/O failure
    `ClassNotFoundException` - if thrown by deserialization

### readRemoteInvocation

    protected RemoteInvocation readRemoteInvocation(HttpServletRequest request,
                                                    InputStream is)
                                             throws IOException,
                                                    ClassNotFoundException

  Deserialize a RemoteInvocation object from the given InputStream.

  Gives `decorateInputStream(javax.servlet.http.HttpServletRequest, java.io.InputStream)` a chance to decorate the stream first (for example, for custom encryption or compression). Creates a `CodebaseAwareObjectInputStream` and calls `doReadRemoteInvocation(java.io.ObjectInputStream)` to actually read the object.

  Can be overridden for custom serialization of the invocation.

  Parameters:
    `request` - current HTTP request
    `is` - the InputStream to read from
  Returns:
    the RemoteInvocation object
  Throws:
    `IOException` - in case of I/O failure
    `ClassNotFoundException` - if thrown during deserialization

### decorateInputStream

    protected InputStream decorateInputStream(HttpServletRequest request,
                                              InputStream is)
                                       throws IOException

  Return the InputStream to use for reading remote invocations, 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:
    `request` - current HTTP request
    `is` - the original InputStream
  Returns:
    the potentially decorated InputStream
  Throws:
    `IOException` - in case of I/O failure

### createObjectInputStream

    protected ObjectInputStream createObjectInputStream(InputStream is)
                                                 throws IOException

  Create an ObjectInputStream for the given InputStream.

  The default implementation creates a Spring `CodebaseAwareObjectInputStream`.

  Spring's CodebaseAwareObjectInputStream is used to explicitly resolve primitive class names. This is done by the standard ObjectInputStream on JDK 1.4+, but needs to be done explicitly on JDK 1.3.

  Parameters:
    `is` - the InputStream to read from
  Returns:
    the new ObjectInputStream instance to use
  Throws:
    `IOException` - if creation of the ObjectInputStream failed

### doReadRemoteInvocation

    protected RemoteInvocation doReadRemoteInvocation(ObjectInputStream ois)
                                               throws IOException,
                                                      ClassNotFoundException

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

  The default implementation simply calls `ObjectInputStream.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:
    `IOException` - in case of I/O failure
    `ClassNotFoundException` - if case of a transferred class not being found in the local ClassLoader

### writeRemoteInvocationResult

    protected void writeRemoteInvocationResult(HttpServletRequest request,
                                               HttpServletResponse response,
                                               RemoteInvocationResult result)
                                        throws IOException

  Write the given RemoteInvocationResult to the given HTTP response.

  Parameters:
    `request` - current HTTP request
    `response` - current HTTP response
    `result` - the RemoteInvocationResult object
  Throws:
    `IOException` - in case of I/O failure

### writeRemoteInvocationResult

    protected void writeRemoteInvocationResult(HttpServletRequest request,
                                               HttpServletResponse response,
                                               RemoteInvocationResult result,
                                               OutputStream os)
                                        throws IOException

  Serialize the given RemoteInvocation to the given OutputStream.

  The default implementation gives `decorateOutputStream(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.io.OutputStream)` a chance to decorate the stream first (for example, for custom encryption or compression). Creates an `ObjectOutputStream` for the final stream and calls `doWriteRemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult, java.io.ObjectOutputStream)` to actually write the object.

  Can be overridden for custom serialization of the invocation.

  Parameters:
    `request` - current HTTP request
    `response` - current HTTP response
    `result` - the RemoteInvocationResult object
    `os` - the OutputStream to write to
  Throws:
    `IOException` - in case of I/O failure
  See Also:
    `decorateOutputStream(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.io.OutputStream)`, `doWriteRemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult, java.io.ObjectOutputStream)`

### decorateOutputStream

    protected OutputStream decorateOutputStream(HttpServletRequest request,
                                                HttpServletResponse response,
                                                OutputStream os)
                                         throws IOException

  Return the OutputStream to use for writing remote invocation results, 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:
    `request` - current HTTP request
    `response` - current HTTP response
    `os` - the original OutputStream
  Returns:
    the potentially decorated OutputStream
  Throws:
    `IOException` - in case of I/O failure

### createObjectOutputStream

    protected ObjectOutputStream createObjectOutputStream(OutputStream os)
                                                   throws IOException

  Create an ObjectOutputStream for the given OutputStream.

  The default implementation creates a plain `ObjectOutputStream`.

  Parameters:
    `os` - the OutputStream to write to
  Returns:
    the new ObjectOutputStream instance to use
  Throws:
    `IOException` - if creation of the ObjectOutputStream failed

### doWriteRemoteInvocationResult

    protected void doWriteRemoteInvocationResult(RemoteInvocationResult result,
                                                 ObjectOutputStream oos)
                                          throws IOException

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

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

  Parameters:
    `result` - the RemoteInvocationResult object
    `oos` - the ObjectOutputStream to write to
  Throws:
    `IOException` - if thrown by I/O methods

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

Copyright © 2002-2007 The Spring Framework.