public class HttpInvokerClientInterceptor extends RemoteInvocationBasedAccessor implements MethodInterceptor, HttpInvokerClientConfiguration
MethodInterceptor
。サービス URL は、HTTP 呼び出しサービスを公開する HTTP URL である必要があります。リモート呼び出しオブジェクトをシリアライズし、リモート呼び出し結果オブジェクトをデシリアライズします。RMI と同じように Java 直列化を使用しますが、Caucho の HTTP ベースの Hessian プロトコルと同じ簡単なセットアップを提供します。
HTTP インボーカは非常に拡張可能でカスタマイズ可能なプロトコルです。RMI インボーカーのような RemoteInvocationFactory メカニズムをサポートし、追加の呼び出し属性(たとえば、セキュリティコンテキスト)を含めることができます。さらに、HttpInvokerRequestExecutor
戦略を介してリクエストの実行をカスタマイズできます。
JDK の RMIClassLoader
を使用して、特定の codebase
からクラスをロードし、リモートの場所からオンデマンドの動的コードダウンロードを実行できます。コードベースは、スペースで区切られた複数の URL で構成できます。RMIClassLoader では、SecurityManager を設定する必要があることに注意してください。これは、標準の RMI で動的クラスダウンロードを使用する場合と同様です。(詳細については、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
logger
コンストラクターと説明 |
---|
HttpInvokerClientInterceptor() |
修飾子と型 | メソッドと説明 |
---|---|
void | afterPropertiesSet() |
protected RemoteAccessException | convertHttpInvokerAccessException(java.lang.Throwable ex) 指定された HTTP 呼び出しアクセス例外を適切な Spring RemoteAccessException に変換します。 |
protected RemoteInvocationResult | executeRequest(RemoteInvocation invocation) HttpInvokerRequestExecutor を介して、指定されたリモート呼び出しを実行します。 |
protected RemoteInvocationResult | executeRequest(RemoteInvocation invocation, MethodInvocation originalInvocation) HttpInvokerRequestExecutor を介して、指定されたリモート呼び出しを実行します。 |
java.lang.String | getCodebaseUrl() ローカルで見つからない場合は、クラスをダウンロードするためのコードベース URL を返します。 |
HttpInvokerRequestExecutor | getHttpInvokerRequestExecutor() このリモートアクセサーが使用する HttpInvokerRequestExecutor を返します。 |
java.lang.Object | invoke(MethodInvocation methodInvocation) このメソッドを実装して、呼び出しの前後に追加の処理を実行します。 |
void | setCodebaseUrl(java.lang.String codebaseUrl) ローカルで見つからない場合は、クラスをダウンロードするコードベース URL を設定します。 |
void | setHttpInvokerRequestExecutor(HttpInvokerRequestExecutor httpInvokerRequestExecutor) リモート呼び出しの実行に使用する HttpInvokerRequestExecutor 実装を設定します。 |
createRemoteInvocation, getRemoteInvocationFactory, recreateRemoteInvocationResult, setRemoteInvocationFactory
getServiceUrl, setServiceUrl
getServiceInterface, setServiceInterface
getBeanClassLoader, overrideThreadContextClassLoader, resetThreadContextClassLoader, setBeanClassLoader
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getServiceUrl
public void setCodebaseUrl(@Nullable java.lang.String codebaseUrl)
動的クラスダウンロードについては、RMI のコードベース規則に従います。サーバーが("java.rmi.server.codebase" システムプロパティを介して)クラスダウンロードの URL を決定する RMI とは対照的に、ここでコードベース URL を決定するのはクライアントです。サーバーは通常、サービス URL の場合と同じですが、そこにある別のパスを指しているだけです。
UrlBasedRemoteAccessor.setServiceUrl(java.lang.String)
, CodebaseAwareObjectInputStream
, RMIClassLoader
@Nullable public java.lang.String getCodebaseUrl()
HttpInvokerClientConfiguration
の getCodebaseUrl
null
RMIClassLoader
public void setHttpInvokerRequestExecutor(HttpInvokerRequestExecutor httpInvokerRequestExecutor)
デフォルトは SimpleHttpInvokerRequestExecutor
です。または、より高度なニーズのために HttpComponentsHttpInvokerRequestExecutor
の使用を検討してください。
public HttpInvokerRequestExecutor getHttpInvokerRequestExecutor()
初期化済みの executor がない場合は、デフォルトの SimpleHttpInvokerRequestExecutor を作成します。
public void afterPropertiesSet()
InitializingBean
BeanFactoryAware
、ApplicationContextAware
などを満たした後、包含 BeanFactory
によって呼び出されます。このメソッドにより、Bean インスタンスは、すべての Bean プロパティが設定されたときに、その全体的な構成の検証と最終的な初期化を実行できます。
InitializingBean
の afterPropertiesSet
UrlBasedRemoteAccessor
の afterPropertiesSet
public java.lang.Object invoke(MethodInvocation methodInvocation) throws java.lang.Throwable
MethodInterceptor
Joinpoint.proceed()
を呼び出すようにします。MethodInterceptor
の invoke
methodInvocation
- メソッド呼び出しジョインポイント Joinpoint.proceed()
の呼び出しの結果。インターセプターによってインターセプトされる可能性があります java.lang.Throwable
- インターセプターまたはターゲットオブジェクトが例外をスローする場合 protected RemoteInvocationResult executeRequest(RemoteInvocation invocation, MethodInvocation originalInvocation) throws java.lang.Exception
HttpInvokerRequestExecutor
を介して、指定されたリモート呼び出しを実行します。 この実装は executeRequest(RemoteInvocation)
に委譲します。特定のオリジナル MethodInvocation に反応するようにオーバーライドできます。
invocation
- 実行する RemoteInvocationoriginalInvocation
- オリジナルの MethodInvocation (できます。ユーザー属性にアクセスするために ProxyMethodInvocation インターフェースにキャストされます)java.lang.Exception
- エラーの場合 protected RemoteInvocationResult executeRequest(RemoteInvocation invocation) throws java.lang.Exception
HttpInvokerRequestExecutor
を介して、指定されたリモート呼び出しを実行します。サブクラスでオーバーライドして、別の構成オブジェクトをエグゼキューターに渡すことができます。あるいは、このアクセサーのサブクラスにさらに構成プロパティを追加します。デフォルトでは、アクセサー自体が構成オブジェクトとしてエグゼキューターに渡されました。
invocation
- 実行する RemoteInvocationjava.io.IOException
- I/O 操作によってスローされた場合 java.lang.ClassNotFoundException
- 逆直列化中にスローされた場合 java.lang.Exception
- 一般的なエラーの場合 getHttpInvokerRequestExecutor()
, HttpInvokerClientConfiguration
@Nullable protected RemoteAccessException convertHttpInvokerAccessException(java.lang.Throwable ex)
RemoteAccessException
に変換します。ex
- 変換する例外 null