public class

SimpleHttpInvokerServiceExporter

extends RemoteInvocationSerializingExporter
implements HttpHandler
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.SimpleHttpInvokerServiceExporter

Class Overview

HTTP request handler that exports the specified service bean as HTTP invoker service endpoint, accessible via an HTTP invoker proxy. Designed for Sun's JRE 1.6 HTTP server, implementing the com.sun.net.httpserver.HttpHandler interface.

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
SimpleHttpInvokerServiceExporter()
Public Methods
void handle(HttpExchange exchange)
Reads a remote invocation from the request, executes it, and writes the remote invocation result to the response.
Protected Methods
InputStream decorateInputStream(HttpExchange exchange, InputStream is)
Return the InputStream to use for reading remote invocations, potentially decorating the given original InputStream.
OutputStream decorateOutputStream(HttpExchange exchange, OutputStream os)
Return the OutputStream to use for writing remote invocation results, potentially decorating the given original OutputStream.
RemoteInvocation readRemoteInvocation(HttpExchange exchange, InputStream is)
Deserialize a RemoteInvocation object from the given InputStream.
RemoteInvocation readRemoteInvocation(HttpExchange exchange)
Read a RemoteInvocation from the given HTTP request.
void writeRemoteInvocationResult(HttpExchange exchange, RemoteInvocationResult result, OutputStream os)
Serialize the given RemoteInvocation to the given OutputStream.
void writeRemoteInvocationResult(HttpExchange exchange, 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 com.sun.net.httpserver.HttpHandler
From interface org.springframework.beans.factory.BeanClassLoaderAware
From interface org.springframework.beans.factory.InitializingBean

Public Constructors

public SimpleHttpInvokerServiceExporter ()

Public Methods

Protected Methods

protected InputStream decorateInputStream (HttpExchange exchange, 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
exchange current HTTP request/response
is the original InputStream
Returns
  • the potentially decorated InputStream
Throws
IOException in case of I/O failure

protected OutputStream decorateOutputStream (HttpExchange exchange, 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
exchange current HTTP request/response
os the original OutputStream
Returns
  • the potentially decorated OutputStream
Throws
IOException in case of I/O failure

protected RemoteInvocation readRemoteInvocation (HttpExchange exchange, InputStream is)

Deserialize a RemoteInvocation object from the given InputStream.

Gives decorateInputStream(HttpExchange, 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
exchange current HTTP request/response
is the InputStream to read from
Returns
  • the RemoteInvocation object
Throws
IOException in case of I/O failure
ClassNotFoundException if thrown during deserialization

protected RemoteInvocation readRemoteInvocation (HttpExchange exchange)

Read a RemoteInvocation from the given HTTP request.

Delegates to readRemoteInvocation(com.sun.net.httpserver.HttpExchange, java.io.InputStream) with the getRequestBody() request's input stream}.

Parameters
exchange current HTTP request/response
Returns
  • the RemoteInvocation object
Throws
IOException in case of I/O failure
ClassNotFoundException if thrown by deserialization

protected void writeRemoteInvocationResult (HttpExchange exchange, RemoteInvocationResult result, OutputStream os)

Serialize the given RemoteInvocation to the given OutputStream.

The default implementation gives decorateOutputStream(HttpExchange, 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
exchange current HTTP request/response
result the RemoteInvocationResult object
os the OutputStream to write to
Throws
IOException in case of I/O failure

protected void writeRemoteInvocationResult (HttpExchange exchange, RemoteInvocationResult result)

Write the given RemoteInvocationResult to the given HTTP response.

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