HttpInvokerServiceExporter を推奨 @DeprecatedSE @UsesSunHttpServer public class SimpleHttpInvokerServiceExporter extends RemoteInvocationSerializingExporter implements com.sun.net.httpserver.HttpHandler
HttpHandler インターフェースを実装します。リモート呼び出しオブジェクトをデシリアライズし、リモート呼び出し結果オブジェクトを直列化します。RMI と同様に Java シリアライゼーションを使用しますが、Caucho の HTTP ベースの Hessian プロトコルと同じように簡単にセットアップできます。
HTTP 呼び出し側は、Java から Java へのリモート化の推奨プロトコルです。Hessian よりも強力で拡張性がありますが、Java に縛られています。それでも、Hessian と同じように簡単にセットアップできます。これは、RMI と比較した場合の主な利点です。
警告: 安全でない Java の逆直列化による脆弱性に注意してください。操作された入力ストリームは、逆直列化ステップ中にサーバー上で望ましくないコード実行を引き起こす可能性があります。結果として、HTTP 呼び出し側エンドポイントを信頼できないクライアントに公開するのではなく、独自のサービス間で公開するようにしてください。一般的に、代わりに他のメッセージ形式(JSON など)を強くお勧めします。
HttpInvokerClientInterceptor, HttpInvokerProxyFactoryBeanCONTENT_TYPE_SERIALIZED_OBJECTlogger| コンストラクターと説明 |
|---|
SimpleHttpInvokerServiceExporter() 使用すべきではありません。 |
| 修飾子と型 | メソッドと説明 |
|---|---|
protected InputStreamSE | decorateInputStream(com.sun.net.httpserver.HttpExchange exchange, InputStreamSE is) 使用すべきではありません。 リモート呼び出しの読み取りに使用する InputStream を返します。指定された元の InputStream を装飾する可能性があります。 |
protected OutputStreamSE | decorateOutputStream(com.sun.net.httpserver.HttpExchange exchange, OutputStreamSE os) 使用すべきではありません。 リモート呼び出し結果の書き込みに使用する OutputStream を返します。指定された元の OutputStream を装飾する可能性があります。 |
void | handle(com.sun.net.httpserver.HttpExchange exchange) 使用すべきではありません。 リクエストからリモート呼び出しを読み取り、それを実行して、リモート呼び出し結果をレスポンスに書き込みます。 |
protected RemoteInvocation | readRemoteInvocation(com.sun.net.httpserver.HttpExchange exchange) 使用すべきではありません。 指定された HTTP リクエストから RemoteInvocation を読み取ります。 |
protected RemoteInvocation | readRemoteInvocation(com.sun.net.httpserver.HttpExchange exchange, InputStreamSE is) 使用すべきではありません。 指定された InputStream から RemoteInvocation オブジェクトを逆直列化します。 |
protected void | writeRemoteInvocationResult(com.sun.net.httpserver.HttpExchange exchange, RemoteInvocationResult result) 使用すべきではありません。 指定された RemoteInvocationResult を指定された HTTP レスポンスに書き込みます。 |
protected void | writeRemoteInvocationResult(com.sun.net.httpserver.HttpExchange exchange, RemoteInvocationResult result, OutputStreamSE os) 使用すべきではありません。 指定された RemoteInvocation を指定された OutputStream に直列化します。 |
afterPropertiesSet, createObjectInputStream, createObjectOutputStream, doReadRemoteInvocation, doWriteRemoteInvocationResult, getContentType, getProxy, isAcceptProxyClasses, prepare, setAcceptProxyClasses, setContentTypegetRemoteInvocationExecutor, invoke, invokeAndCreateResult, setRemoteInvocationExecutorcheckService, checkServiceInterface, getExporterName, getProxyForService, getService, getServiceInterface, setInterceptors, setRegisterTraceInterceptor, setService, setServiceInterfacegetBeanClassLoader, overrideThreadContextClassLoader, resetThreadContextClassLoader, setBeanClassLoadercloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEpublic void handle(com.sun.net.httpserver.HttpExchange exchange)
throws IOExceptionSEcom.sun.net.httpserver.HttpHandler の handle IOExceptionSEreadRemoteInvocation(HttpExchange), RemoteInvocationBasedExporter.invokeAndCreateResult(RemoteInvocation, Object), writeRemoteInvocationResult(HttpExchange, RemoteInvocationResult)protected RemoteInvocation readRemoteInvocation(com.sun.net.httpserver.HttpExchange exchange) throws IOExceptionSE, ClassNotFoundExceptionSE
HttpExchange.getRequestBody() リクエストの入力ストリームを使用して readRemoteInvocation(HttpExchange, InputStream) にデリゲートします。}。
exchange - 現在の HTTP リクエスト / レスポンス IOExceptionSE - I/O 障害の場合 ClassNotFoundExceptionSE - 逆直列化によってスローされた場合 protected RemoteInvocation readRemoteInvocation(com.sun.net.httpserver.HttpExchange exchange, InputStreamSE is) throws IOExceptionSE, ClassNotFoundExceptionSE
decorateInputStream(com.sun.net.httpserver.HttpExchange, java.io.InputStream) に最初にストリームを装飾する機会を与えます(たとえば、カスタム暗号化または圧縮のため)。CodebaseAwareObjectInputStream を作成し、RemoteInvocationSerializingExporter.doReadRemoteInvocation(java.io.ObjectInputStream) を呼び出して実際にオブジェクトを読み取ります。
呼び出しのカスタム直列化のためにオーバーライドできます。
exchange - 現在の HTTP リクエスト / レスポンス is - 読み込み元の InputStreamIOExceptionSE - I/O 障害の場合 ClassNotFoundExceptionSE - 逆直列化中にスローされた場合 protected InputStreamSE decorateInputStream(com.sun.net.httpserver.HttpExchange exchange, InputStreamSE is) throws IOExceptionSE
デフォルトの実装は、指定されたストリームをそのまま返します。たとえば、カスタムの暗号化や圧縮のためにオーバーライドできます。
exchange - 現在の HTTP リクエスト / レスポンス is - オリジナルの InputStreamIOExceptionSE - I/O 障害の場合 protected void writeRemoteInvocationResult(com.sun.net.httpserver.HttpExchange exchange,
RemoteInvocationResult result)
throws IOExceptionSEexchange - 現在の HTTP リクエスト / レスポンス result - RemoteInvocationResult オブジェクト IOExceptionSE - I/O 障害の場合 protected void writeRemoteInvocationResult(com.sun.net.httpserver.HttpExchange exchange,
RemoteInvocationResult result,
OutputStreamSE os)
throws IOExceptionSE デフォルトの実装では、decorateOutputStream(com.sun.net.httpserver.HttpExchange, java.io.OutputStream) が最初にストリームを装飾する機会が与えられます(たとえば、カスタムの暗号化または圧縮のため)。最終ストリームの ObjectOutputStreamSE を作成し、RemoteInvocationSerializingExporter.doWriteRemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult, java.io.ObjectOutputStream) を呼び出して実際にオブジェクトを書き込みます。
呼び出しのカスタム直列化のためにオーバーライドできます。
exchange - 現在の HTTP リクエスト / レスポンス result - RemoteInvocationResult オブジェクト os - 書き込む OutputStreamIOExceptionSE - I/O 障害の場合 decorateOutputStream(com.sun.net.httpserver.HttpExchange, java.io.OutputStream), RemoteInvocationSerializingExporter.doWriteRemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult, java.io.ObjectOutputStream)protected OutputStreamSE decorateOutputStream(com.sun.net.httpserver.HttpExchange exchange, OutputStreamSE os) throws IOExceptionSE
デフォルトの実装は、指定されたストリームをそのまま返します。たとえば、カスタムの暗号化や圧縮のためにオーバーライドできます。
exchange - 現在の HTTP リクエスト / レスポンス os - オリジナルの OutputStreamIOExceptionSE - I/O 障害の場合