类 SimpleHttpInvokerServiceExporter
- 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
- 所有已实现的接口:
com.sun.net.httpserver.HttpHandler
,Aware
,BeanClassLoaderAware
,InitializingBean
@UsesSunHttpServer public class SimpleHttpInvokerServiceExporter extends RemoteInvocationSerializingExporter implements com.sun.net.httpserver.HttpHandler
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 theHttpHandler
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.
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.
- 从以下版本开始:
- 2.5.1
- 作者:
- Juergen Hoeller
- 另请参阅:
HttpInvokerClientInterceptor
,HttpInvokerProxyFactoryBean
,SimpleHessianServiceExporter
,SimpleBurlapServiceExporter
字段概要
从类继承的字段 org.springframework.remoting.rmi.RemoteInvocationSerializingExporter
CONTENT_TYPE_SERIALIZED_OBJECT
从类继承的字段 org.springframework.remoting.support.RemotingSupport
logger
构造器概要
构造器 构造器 说明 SimpleHttpInvokerServiceExporter()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected InputStream
decorateInputStream(com.sun.net.httpserver.HttpExchange exchange, InputStream is)
Return the InputStream to use for reading remote invocations, potentially decorating the given original InputStream.protected OutputStream
decorateOutputStream(com.sun.net.httpserver.HttpExchange exchange, OutputStream os)
Return the OutputStream to use for writing remote invocation results, potentially decorating the given original OutputStream.void
handle(com.sun.net.httpserver.HttpExchange exchange)
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)
Read a RemoteInvocation from the given HTTP request.protected RemoteInvocation
readRemoteInvocation(com.sun.net.httpserver.HttpExchange exchange, InputStream is)
Deserialize a RemoteInvocation object from the given InputStream.protected void
writeRemoteInvocationResult(com.sun.net.httpserver.HttpExchange exchange, RemoteInvocationResult result)
Write the given RemoteInvocationResult to the given HTTP response.protected void
writeRemoteInvocationResult(com.sun.net.httpserver.HttpExchange exchange, RemoteInvocationResult result, OutputStream os)
Serialize the given RemoteInvocation to the given OutputStream.从类继承的方法 org.springframework.remoting.rmi.RemoteInvocationSerializingExporter
afterPropertiesSet, createObjectInputStream, createObjectOutputStream, doReadRemoteInvocation, doWriteRemoteInvocationResult, getContentType, getProxy, isAcceptProxyClasses, prepare, setAcceptProxyClasses, setContentType
从类继承的方法 org.springframework.remoting.support.RemoteInvocationBasedExporter
getRemoteInvocationExecutor, invoke, invokeAndCreateResult, setRemoteInvocationExecutor
从类继承的方法 org.springframework.remoting.support.RemoteExporter
checkService, checkServiceInterface, getExporterName, getProxyForService, getService, getServiceInterface, setInterceptors, setRegisterTraceInterceptor, setService, setServiceInterface
从类继承的方法 org.springframework.remoting.support.RemotingSupport
getBeanClassLoader, overrideThreadContextClassLoader, resetThreadContextClassLoader, setBeanClassLoader
构造器详细资料
SimpleHttpInvokerServiceExporter
public SimpleHttpInvokerServiceExporter()
方法详细资料
handle
public void handle(com.sun.net.httpserver.HttpExchange exchange) throws IOException
Reads a remote invocation from the request, executes it, and writes the remote invocation result to the response.- 指定者:
handle
在接口中com.sun.net.httpserver.HttpHandler
- 抛出:
IOException
- 另请参阅:
readRemoteInvocation(HttpExchange)
,RemoteInvocationBasedExporter.invokeAndCreateResult(RemoteInvocation, Object)
,writeRemoteInvocationResult(HttpExchange, RemoteInvocationResult)
readRemoteInvocation
protected RemoteInvocation readRemoteInvocation(com.sun.net.httpserver.HttpExchange exchange) throws IOException, ClassNotFoundException
Read a RemoteInvocation from the given HTTP request.Delegates to
readRemoteInvocation(HttpExchange, InputStream)
with theHttpExchange.getRequestBody()
request's input stream}.- 参数:
exchange
- current HTTP request/response- 返回:
- the RemoteInvocation object
- 抛出:
IOException
- in case of I/O failureClassNotFoundException
- if thrown by deserialization
readRemoteInvocation
protected RemoteInvocation readRemoteInvocation(com.sun.net.httpserver.HttpExchange exchange, InputStream is) throws IOException, ClassNotFoundException
Deserialize a RemoteInvocation object from the given InputStream.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 aCodebaseAwareObjectInputStream
and callsRemoteInvocationSerializingExporter.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 from- 返回:
- the RemoteInvocation object
- 抛出:
IOException
- in case of I/O failureClassNotFoundException
- if thrown during deserialization
decorateInputStream
protected InputStream decorateInputStream(com.sun.net.httpserver.HttpExchange exchange, 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.
- 参数:
exchange
- current HTTP request/responseis
- the original InputStream- 返回:
- the potentially decorated InputStream
- 抛出:
IOException
- in case of I/O failure
writeRemoteInvocationResult
protected void writeRemoteInvocationResult(com.sun.net.httpserver.HttpExchange exchange, RemoteInvocationResult result) throws IOException
Write the given RemoteInvocationResult to the given HTTP response.- 参数:
exchange
- current HTTP request/responseresult
- the RemoteInvocationResult object- 抛出:
IOException
- in case of I/O failure
writeRemoteInvocationResult
protected void writeRemoteInvocationResult(com.sun.net.httpserver.HttpExchange exchange, RemoteInvocationResult result, OutputStream os) throws IOException
Serialize the given RemoteInvocation to the given OutputStream.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 anObjectOutputStream
for the final stream and callsRemoteInvocationSerializingExporter.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 to- 抛出:
IOException
- in case of I/O failure- 另请参阅:
decorateOutputStream(com.sun.net.httpserver.HttpExchange, java.io.OutputStream)
,RemoteInvocationSerializingExporter.doWriteRemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult, java.io.ObjectOutputStream)
decorateOutputStream
protected OutputStream decorateOutputStream(com.sun.net.httpserver.HttpExchange exchange, 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.
- 参数:
exchange
- current HTTP request/responseos
- the original OutputStream- 返回:
- the potentially decorated OutputStream
- 抛出:
IOException
- in case of I/O failure