public class HttpInvokerServiceExporter extends RemoteInvocationSerializingExporter implements HttpRequestHandler
リモート呼び出しオブジェクトをデシリアライズし、リモート呼び出し結果オブジェクトを直列化します。RMI と同様に Java シリアライゼーションを使用しますが、Caucho の HTTP ベースの Hessian プロトコルと同じように簡単にセットアップできます。
HTTP 呼び出し側は、Java から Java へのリモート化の推奨プロトコルです。Hessian よりも強力で拡張性がありますが、Java に縛られています。それでも、Hessian と同じように簡単にセットアップできます。これは、RMI と比較した場合の主な利点です。
警告: 安全でない Java の逆直列化による脆弱性に注意してください。操作された入力ストリームは、逆直列化ステップ中にサーバー上で望ましくないコード実行を引き起こす可能性があります。結果として、HTTP 呼び出し側エンドポイントを信頼できないクライアントに公開するのではなく、独自のサービス間で公開するようにしてください。一般的に、代わりに他のメッセージ形式(JSON など)を強くお勧めします。
HttpInvokerClientInterceptor
, HttpInvokerProxyFactoryBean
, RmiServiceExporter
, HessianServiceExporter
CONTENT_TYPE_SERIALIZED_OBJECT
logger
コンストラクターと説明 |
---|
HttpInvokerServiceExporter() |
修飾子と型 | メソッドと説明 |
---|---|
protected InputStreamSE | decorateInputStream(HttpServletRequestEE request, InputStreamSE is) リモート呼び出しの読み取りに使用する InputStream を返します。指定された元の InputStream を装飾する可能性があります。 |
protected OutputStreamSE | decorateOutputStream(HttpServletRequestEE request, HttpServletResponseEE response, OutputStreamSE os) リモート呼び出し結果の書き込みに使用する OutputStream を返します。指定された元の OutputStream を装飾する可能性があります。 |
void | handleRequest(HttpServletRequestEE request, HttpServletResponseEE response) リクエストからリモート呼び出しを読み取り、それを実行して、リモート呼び出し結果をレスポンスに書き込みます。 |
protected RemoteInvocation | readRemoteInvocation(HttpServletRequestEE request) 指定された HTTP リクエストから RemoteInvocation を読み取ります。 |
protected RemoteInvocation | readRemoteInvocation(HttpServletRequestEE request, InputStreamSE is) 指定された InputStream から RemoteInvocation オブジェクトを逆直列化します。 |
protected void | writeRemoteInvocationResult(HttpServletRequestEE request, HttpServletResponseEE response, RemoteInvocationResult result) 指定された RemoteInvocationResult を指定された HTTP レスポンスに書き込みます。 |
protected void | writeRemoteInvocationResult(HttpServletRequestEE request, HttpServletResponseEE response, RemoteInvocationResult result, OutputStreamSE os) 指定された RemoteInvocation を指定された 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
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public void handleRequest(HttpServletRequestEE request, HttpServletResponseEE response) throws ServletExceptionEE, IOExceptionSE
HttpRequestHandler
の handleRequest
request
- 現在の HTTP リクエスト response
- 現在の HTTP レスポンス ServletExceptionEE
- 一般的なエラーの場合 IOExceptionSE
- I/O エラーの場合 readRemoteInvocation(HttpServletRequest)
, RemoteInvocationBasedExporter.invokeAndCreateResult(org.springframework.remoting.support.RemoteInvocation, Object)
, writeRemoteInvocationResult(HttpServletRequest, HttpServletResponse, RemoteInvocationResult)
protected RemoteInvocation readRemoteInvocation(HttpServletRequestEE request) throws IOExceptionSE, ClassNotFoundExceptionSE
servlet request's input stream
EE を使用して readRemoteInvocation(HttpServletRequest, InputStream)
にデリゲートします。
request
- 現在の HTTP リクエスト IOExceptionSE
- I/O 障害の場合 ClassNotFoundExceptionSE
- 逆直列化によってスローされた場合 protected RemoteInvocation readRemoteInvocation(HttpServletRequestEE request, InputStreamSE is) throws IOExceptionSE, ClassNotFoundExceptionSE
decorateInputStream(javax.servlet.http.HttpServletRequest, java.io.InputStream)
に最初にストリームを装飾する機会を与えます(たとえば、カスタム暗号化または圧縮のため)。CodebaseAwareObjectInputStream
を作成し、RemoteInvocationSerializingExporter.doReadRemoteInvocation(java.io.ObjectInputStream)
を呼び出して実際にオブジェクトを読み取ります。
呼び出しのカスタム直列化のためにオーバーライドできます。
request
- 現在の HTTP リクエスト is
- 読み込み元の InputStreamIOExceptionSE
- I/O 障害の場合 ClassNotFoundExceptionSE
- 逆直列化中にスローされた場合 protected InputStreamSE decorateInputStream(HttpServletRequestEE request, InputStreamSE is) throws IOExceptionSE
デフォルトの実装は、指定されたストリームをそのまま返します。たとえば、カスタムの暗号化や圧縮のためにオーバーライドできます。
request
- 現在の HTTP リクエスト is
- オリジナルの InputStreamIOExceptionSE
- I/O 障害の場合 protected void writeRemoteInvocationResult(HttpServletRequestEE request, HttpServletResponseEE response, RemoteInvocationResult result) throws IOExceptionSE
request
- 現在の HTTP リクエスト response
- 現在の HTTP レスポンス result
- RemoteInvocationResult オブジェクト IOExceptionSE
- I/O 障害の場合 protected void writeRemoteInvocationResult(HttpServletRequestEE request, HttpServletResponseEE response, RemoteInvocationResult result, OutputStreamSE os) throws IOExceptionSE
デフォルトの実装では、decorateOutputStream(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.io.OutputStream)
が最初にストリームを装飾する機会が与えられます(たとえば、カスタムの暗号化または圧縮のため)。最終ストリームの ObjectOutputStream
SE を作成し、RemoteInvocationSerializingExporter.doWriteRemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult, java.io.ObjectOutputStream)
を呼び出して実際にオブジェクトを書き込みます。
呼び出しのカスタム直列化のためにオーバーライドできます。
request
- 現在の HTTP リクエスト response
- 現在の HTTP レスポンス result
- RemoteInvocationResult オブジェクト os
- 書き込む OutputStreamIOExceptionSE
- I/O 障害の場合 decorateOutputStream(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.io.OutputStream)
, RemoteInvocationSerializingExporter.doWriteRemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult, java.io.ObjectOutputStream)
protected OutputStreamSE decorateOutputStream(HttpServletRequestEE request, HttpServletResponseEE response, OutputStreamSE os) throws IOExceptionSE
デフォルトの実装は、指定されたストリームをそのまま返します。たとえば、カスタムの暗号化や圧縮のためにオーバーライドできます。
request
- 現在の HTTP リクエスト response
- 現在の HTTP レスポンス os
- オリジナルの OutputStreamIOExceptionSE
- I/O 障害の場合