HttpInvokerServiceExporter
@Deprecated @UsesSunHttpServer public class SimpleHttpInvokerServiceExporter extends RemoteInvocationSerializingExporter implements com.sun.net.httpserver.HttpHandler
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 protocol.
HTTP invoker is the recommended protocol for Java-to-Java remoting. It is more powerful and more extensible than Hessian, at the expense of being tied to Java. Nevertheless, it is as easy to set up as Hessian, which is its main advantage compared to RMI.
WARNING: Be aware of vulnerabilities due to unsafe Java deserialization: Manipulated input streams could lead to unwanted code execution on the server during the deserialization step. As a consequence, do not expose HTTP invoker endpoints to untrusted clients but rather just between your own services. In general, we strongly recommend any other message format (e.g. JSON) instead.
HttpInvokerClientInterceptor
,
HttpInvokerProxyFactoryBean
CONTENT_TYPE_SERIALIZED_OBJECT
logger
Constructor and Description |
---|
SimpleHttpInvokerServiceExporter()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected java.io.InputStream |
decorateInputStream(com.sun.net.httpserver.HttpExchange exchange,
java.io.InputStream is)
Deprecated.
Return the InputStream to use for reading remote invocations,
potentially decorating the given original InputStream.
|
protected java.io.OutputStream |
decorateOutputStream(com.sun.net.httpserver.HttpExchange exchange,
java.io.OutputStream os)
Deprecated.
Return the OutputStream to use for writing remote invocation results,
potentially decorating the given original OutputStream.
|
void |
handle(com.sun.net.httpserver.HttpExchange exchange)
Deprecated.
Reads a remote invocation from the request, executes it,
and writes the remote invocation result to the response.
|
protected RemoteInvocation |
readRemoteInvocation(com.sun.net.httpserver.HttpExchange exchange)
Deprecated.
Read a RemoteInvocation from the given HTTP request.
|
protected RemoteInvocation |
readRemoteInvocation(com.sun.net.httpserver.HttpExchange exchange,
java.io.InputStream is)
Deprecated.
Deserialize a RemoteInvocation object from the given InputStream.
|
protected void |
writeRemoteInvocationResult(com.sun.net.httpserver.HttpExchange exchange,
RemoteInvocationResult result)
Deprecated.
Write the given RemoteInvocationResult to the given HTTP response.
|
protected void |
writeRemoteInvocationResult(com.sun.net.httpserver.HttpExchange exchange,
RemoteInvocationResult result,
java.io.OutputStream os)
Deprecated.
Serialize the given RemoteInvocation to the given OutputStream.
|
afterPropertiesSet, createObjectInputStream, createObjectOutputStream, doReadRemoteInvocation, doWriteRemoteInvocationResult, getContentType, getProxy, isAcceptProxyClasses, prepare, setAcceptProxyClasses, setContentType
getRemoteInvocationExecutor, invoke, invokeAndCreateResult, setRemoteInvocationExecutor
checkService, checkServiceInterface, getExporterName, getProxyForService, getService, getServiceInterface, setInterceptors, setRegisterTraceInterceptor, setService, setServiceInterface
getBeanClassLoader, overrideThreadContextClassLoader, resetThreadContextClassLoader, setBeanClassLoader
public SimpleHttpInvokerServiceExporter()
public void handle(com.sun.net.httpserver.HttpExchange exchange) throws java.io.IOException
handle
in interface com.sun.net.httpserver.HttpHandler
java.io.IOException
readRemoteInvocation(HttpExchange)
,
RemoteInvocationBasedExporter.invokeAndCreateResult(RemoteInvocation, Object)
,
writeRemoteInvocationResult(HttpExchange, RemoteInvocationResult)
protected RemoteInvocation readRemoteInvocation(com.sun.net.httpserver.HttpExchange exchange) throws java.io.IOException, java.lang.ClassNotFoundException
Delegates to readRemoteInvocation(HttpExchange, InputStream)
with the HttpExchange.getRequestBody()
request's input stream}.
exchange
- current HTTP request/responsejava.io.IOException
- in case of I/O failurejava.lang.ClassNotFoundException
- if thrown by deserializationprotected RemoteInvocation readRemoteInvocation(com.sun.net.httpserver.HttpExchange exchange, java.io.InputStream is) throws java.io.IOException, java.lang.ClassNotFoundException
Gives decorateInputStream(com.sun.net.httpserver.HttpExchange, java.io.InputStream)
a chance to decorate the stream
first (for example, for custom encryption or compression). Creates a
CodebaseAwareObjectInputStream
and calls RemoteInvocationSerializingExporter.doReadRemoteInvocation(java.io.ObjectInputStream)
to actually read the object.
Can be overridden for custom serialization of the invocation.
exchange
- current HTTP request/responseis
- the InputStream to read fromjava.io.IOException
- in case of I/O failurejava.lang.ClassNotFoundException
- if thrown during deserializationprotected java.io.InputStream decorateInputStream(com.sun.net.httpserver.HttpExchange exchange, java.io.InputStream is) throws java.io.IOException
The default implementation returns the given stream as-is. Can be overridden, for example, for custom encryption or compression.
exchange
- current HTTP request/responseis
- the original InputStreamjava.io.IOException
- in case of I/O failureprotected void writeRemoteInvocationResult(com.sun.net.httpserver.HttpExchange exchange, RemoteInvocationResult result) throws java.io.IOException
exchange
- current HTTP request/responseresult
- the RemoteInvocationResult objectjava.io.IOException
- in case of I/O failureprotected void writeRemoteInvocationResult(com.sun.net.httpserver.HttpExchange exchange, RemoteInvocationResult result, java.io.OutputStream os) throws java.io.IOException
The default implementation gives decorateOutputStream(com.sun.net.httpserver.HttpExchange, 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
RemoteInvocationSerializingExporter.doWriteRemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult, java.io.ObjectOutputStream)
to actually write the object.
Can be overridden for custom serialization of the invocation.
exchange
- current HTTP request/responseresult
- the RemoteInvocationResult objectos
- the OutputStream to write tojava.io.IOException
- in case of I/O failuredecorateOutputStream(com.sun.net.httpserver.HttpExchange, java.io.OutputStream)
,
RemoteInvocationSerializingExporter.doWriteRemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult, java.io.ObjectOutputStream)
protected java.io.OutputStream decorateOutputStream(com.sun.net.httpserver.HttpExchange exchange, java.io.OutputStream os) throws java.io.IOException
The default implementation returns the given stream as-is. Can be overridden, for example, for custom encryption or compression.
exchange
- current HTTP request/responseos
- the original OutputStreamjava.io.IOException
- in case of I/O failure