public class HttpInvokerClientInterceptor extends RemoteInvocationBasedAccessor implements MethodInterceptor, HttpInvokerClientConfiguration
MethodInterceptor
。サービス URL は、HTTP 呼び出しサービスを公開する HTTP URL である必要があります。リモート呼び出しオブジェクトをシリアライズし、リモート呼び出し結果オブジェクトをデシリアライズします。RMI と同じように Java 直列化を使用しますが、Caucho の HTTP ベースの Hessian プロトコルと同じ簡単なセットアップを提供します。
HTTP インボーカは非常に拡張可能でカスタマイズ可能なプロトコルです。RMI インボーカーのような RemoteInvocationFactory メカニズムをサポートし、追加の呼び出し属性(たとえば、セキュリティコンテキスト)を含めることができます。さらに、HttpInvokerRequestExecutor
戦略を介してリクエストの実行をカスタマイズできます。
JDK の RMIClassLoader
SE を使用して、特定の codebase
からクラスをロードし、リモートの場所からオンデマンドの動的コードダウンロードを実行できます。コードベースは、スペースで区切られた複数の URL で構成できます。標準 RMI で動的クラスダウンロードを使用する場合と同様に、RMIClassLoader では SecurityManager を設定する必要があることに注意してください。(詳細については、RMI のドキュメントを参照してください。)
警告: 安全でない Java の逆直列化による脆弱性に注意してください。操作された入力ストリームは、逆直列化ステップ中にサーバー上で望ましくないコード実行を引き起こす可能性があります。結果として、HTTP 呼び出し側エンドポイントを信頼できないクライアントに公開するのではなく、独自のサービス間で公開するようにしてください。一般的に、代わりに他のメッセージ形式(JSON など)を強くお勧めします。
UrlBasedRemoteAccessor.setServiceUrl(java.lang.String)
, setCodebaseUrl(java.lang.String)
, RemoteInvocationBasedAccessor.setRemoteInvocationFactory(org.springframework.remoting.support.RemoteInvocationFactory)
, setHttpInvokerRequestExecutor(org.springframework.remoting.httpinvoker.HttpInvokerRequestExecutor)
, HttpInvokerServiceExporter
, HttpInvokerProxyFactoryBean
, RMIClassLoader
SElogger
コンストラクターと説明 |
---|
HttpInvokerClientInterceptor() |
修飾子と型 | メソッドと説明 |
---|---|
void | afterPropertiesSet() 指定されたすべての Bean プロパティを設定した(そして BeanFactoryAware と ApplicationContextAware を満たした)後に BeanFactory によって呼び出されます。 |
protected RemoteAccessException | convertHttpInvokerAccessException(ThrowableSE ex) 指定された HTTP 呼び出しアクセス例外を適切な Spring RemoteAccessException に変換します。 |
protected RemoteInvocationResult | executeRequest(RemoteInvocation invocation) HttpInvokerRequestExecutor を介して、指定されたリモート呼び出しを実行します。 |
protected RemoteInvocationResult | executeRequest(RemoteInvocation invocation, MethodInvocation originalInvocation) HttpInvokerRequestExecutor を介して、指定されたリモート呼び出しを実行します。 |
StringSE | getCodebaseUrl() ローカルで見つからない場合は、クラスをダウンロードするためのコードベース URL を返します。 |
HttpInvokerRequestExecutor | getHttpInvokerRequestExecutor() このリモートアクセサーが使用する HttpInvokerRequestExecutor を返します。 |
ObjectSE | invoke(MethodInvocation methodInvocation) このメソッドを実装して、呼び出しの前後に追加の処理を実行します。 |
void | setCodebaseUrl(StringSE codebaseUrl) ローカルで見つからない場合は、クラスをダウンロードするコードベース URL を設定します。 |
void | setHttpInvokerRequestExecutor(HttpInvokerRequestExecutor httpInvokerRequestExecutor) リモート呼び出しの実行に使用する HttpInvokerRequestExecutor 実装を設定します。 |
createRemoteInvocation, getRemoteInvocationFactory, recreateRemoteInvocationResult, setRemoteInvocationFactory
getServiceUrl, setServiceUrl
getServiceInterface, setServiceInterface
getBeanClassLoader, overrideThreadContextClassLoader, resetThreadContextClassLoader, setBeanClassLoader
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
getServiceUrl
public void setCodebaseUrl(@Nullable StringSE codebaseUrl)
動的クラスダウンロードについては、RMI のコードベース規則に従います。サーバーが("java.rmi.server.codebase" システムプロパティを介して)クラスダウンロードの URL を決定する RMI とは対照的に、ここでコードベース URL を決定するのはクライアントです。サーバーは通常、サービス URL の場合と同じですが、そこにある別のパスを指しているだけです。
@Nullable public StringSE getCodebaseUrl()
HttpInvokerClientConfiguration
の getCodebaseUrl
null
RMIClassLoader
SEpublic void setHttpInvokerRequestExecutor(HttpInvokerRequestExecutor httpInvokerRequestExecutor)
デフォルトは SimpleHttpInvokerRequestExecutor
です。または、より高度なニーズのために HttpComponentsHttpInvokerRequestExecutor
の使用を検討してください。
public HttpInvokerRequestExecutor getHttpInvokerRequestExecutor()
初期化済みの executor がない場合は、デフォルトの SimpleHttpInvokerRequestExecutor を作成します。
public void afterPropertiesSet()
InitializingBean
このメソッドにより、Bean インスタンスは、すべての Bean プロパティが設定されている場合にのみ可能な初期化を実行し、設定ミスの場合に例外をスローできます。
InitializingBean
の afterPropertiesSet
UrlBasedRemoteAccessor
の afterPropertiesSet
public ObjectSE invoke(MethodInvocation methodInvocation) throws ThrowableSE
MethodInterceptor
Joinpoint.proceed()
を呼び出すようにします。MethodInterceptor
の invoke
methodInvocation
- メソッド呼び出しジョインポイント Joinpoint.proceed()
の呼び出しの結果。インターセプターによってインターセプトされる可能性があります ThrowableSE
- インターセプターまたはターゲットオブジェクトが例外をスローする場合 protected RemoteInvocationResult executeRequest(RemoteInvocation invocation, MethodInvocation originalInvocation) throws ExceptionSE
HttpInvokerRequestExecutor
を介して、指定されたリモート呼び出しを実行します。 この実装は executeRequest(RemoteInvocation)
に委譲します。特定のオリジナル MethodInvocation に反応するようにオーバーライドできます。
invocation
- 実行する RemoteInvocationoriginalInvocation
- オリジナルの MethodInvocation (できます。ユーザー属性にアクセスするために ProxyMethodInvocation インターフェースにキャストされます)ExceptionSE
- エラーの場合 protected RemoteInvocationResult executeRequest(RemoteInvocation invocation) throws ExceptionSE
HttpInvokerRequestExecutor
を介して、指定されたリモート呼び出しを実行します。サブクラスでオーバーライドして、別の構成オブジェクトをエグゼキューターに渡すことができます。あるいは、このアクセサーのサブクラスにさらに構成プロパティを追加します。デフォルトでは、アクセサー自体が構成オブジェクトとしてエグゼキューターに渡されました。
invocation
- 実行する RemoteInvocationIOExceptionSE
- I/O 操作によってスローされた場合 ClassNotFoundExceptionSE
- 逆直列化中にスローされた場合 ExceptionSE
- 一般的なエラーの場合 getHttpInvokerRequestExecutor()
, HttpInvokerClientConfiguration
@Nullable protected RemoteAccessException convertHttpInvokerAccessException(ThrowableSE ex)
RemoteAccessException
に変換します。ex
- 変換する例外 null