public class

HttpInvokerServiceExporter

extends RemoteInvocationSerializingExporter
implements HttpRequestHandler
java.lang.Object
   ↳ org.springframework.remoting.support.RemotingSupport
     ↳ org.springframework.remoting.support.RemoteExporter
       ↳ org.springframework.remoting.support.RemoteInvocationBasedExporter
         ↳ org.springframework.remoting.rmi.RemoteInvocationSerializingExporter
           ↳ org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter

Class Overview

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

Note: Spring also provides an alternative version of this exporter, for Sun's JRE 1.6 HTTP server: SimpleHttpInvokerServiceExporter.

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.

Summary

[Expand]
Inherited Constants
From class org.springframework.remoting.rmi.RemoteInvocationSerializingExporter
[Expand]
Inherited Fields
From class org.springframework.remoting.support.RemotingSupport
Public Constructors
HttpInvokerServiceExporter()
Public Methods
void handleRequest(HttpServletRequest request, HttpServletResponse response)
Reads a remote invocation from the request, executes it, and writes the remote invocation result to the response.
Protected Methods
InputStream decorateInputStream(HttpServletRequest request, InputStream is)
Return the InputStream to use for reading remote invocations, potentially decorating the given original InputStream.
OutputStream decorateOutputStream(HttpServletRequest request, HttpServletResponse response, OutputStream os)
Return the OutputStream to use for writing remote invocation results, potentially decorating the given original OutputStream.
RemoteInvocation readRemoteInvocation(HttpServletRequest request)
Read a RemoteInvocation from the given HTTP request.
RemoteInvocation readRemoteInvocation(HttpServletRequest request, InputStream is)
Deserialize a RemoteInvocation object from the given InputStream.
void writeRemoteInvocationResult(HttpServletRequest request, HttpServletResponse response, RemoteInvocationResult result, OutputStream os)
Serialize the given RemoteInvocation to the given OutputStream.
void writeRemoteInvocationResult(HttpServletRequest request, HttpServletResponse response, RemoteInvocationResult result)
Write the given RemoteInvocationResult to the given HTTP response.
[Expand]
Inherited Methods
From class org.springframework.remoting.rmi.RemoteInvocationSerializingExporter
From class org.springframework.remoting.support.RemoteInvocationBasedExporter
From class org.springframework.remoting.support.RemoteExporter
From class org.springframework.remoting.support.RemotingSupport
From class java.lang.Object
From interface org.springframework.beans.factory.BeanClassLoaderAware
From interface org.springframework.beans.factory.InitializingBean
From interface org.springframework.web.HttpRequestHandler

Public Constructors

public HttpInvokerServiceExporter ()

Public Methods

public void handleRequest (HttpServletRequest request, HttpServletResponse response)

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

Parameters
request current HTTP request
response current HTTP response
Throws
IOException
ServletException

Protected Methods

protected InputStream decorateInputStream (HttpServletRequest request, InputStream is)

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

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.

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

protected RemoteInvocation readRemoteInvocation (HttpServletRequest request)

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

protected RemoteInvocation readRemoteInvocation (HttpServletRequest request, InputStream is)

Deserialize a RemoteInvocation object from the given InputStream.

Gives decorateInputStream(HttpServletRequest, InputStream) a chance to decorate the stream first (for example, for custom encryption or compression). Creates a CodebaseAwareObjectInputStream and calls doReadRemoteInvocation(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

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

Serialize the given RemoteInvocation to the given OutputStream.

The default implementation gives decorateOutputStream(HttpServletRequest, HttpServletResponse, 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(RemoteInvocationResult, 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

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

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