クラス ContextSourceTransactionManager
- 実装されているすべてのインターフェース:
SerializableSE、org.springframework.beans.factory.InitializingBean、org.springframework.transaction.ConfigurableTransactionManager、org.springframework.transaction.PlatformTransactionManager、org.springframework.transaction.TransactionManager
注 : この TransactionManager によって提供されるトランザクションはすべてクライアント側であり、通常のデータベースの世界で知られているという意味では決して「本物の」トランザクションではありません。例:
- トランザクション障害がネットワーク障害によって引き起こされた場合、この TransactionManager がデータベースの状態を復元する方法はまったくありません。この場合、ロールバックの可能性は完全に失われます。
- トランザクションの分離は提供されません。つまり、あるクライアントのトランザクションに参加しているエントリが、同時に別のクライアントの別のトランザクションに参加する可能性があります。これらのトランザクションの 1 つがロールバックされた場合、その結果は未定であり、最悪の場合は完全に失敗する可能性があります。
上記の点に注意して考慮する必要がありますが、最も不幸な状況を除いて、カバレッジ取引アプローチは完全に十分です。現在、LDAP の世界にはサーバー側のトランザクションサポートがまったく存在しないことを考慮すると、リレーショナルデータベース操作と同じ方法で操作をトランザクションとしてマークできることは、確実に前進です。
LDAP トランザクションは ContextSource に関連付けられ、setContextSource(ContextSource) メソッドに提供されます。ターゲット LdapTemplate インスタンスによって使用される実際の ContextSource は TransactionAwareContextSourceProxy 型である必要がありますが、このクラスに提供される ContextSource は実際のターゲット ContextSource である必要があります。
この TransactionManager を TransactionAwareContextSourceProxy と一緒に使用すると、トランザクション内のすべての変更操作 (バインド、アンバインド、再バインド、名前変更、modifyAttributes) がインターセプトされます。各変更には対応する CompensatingTransactionOperationRecorder があり、ロールバックを実行するために必要な情報を収集して CompensatingTransactionOperationExecutor を生成します。CompensatingTransactionOperationExecutor は実際の操作を実行するために使用され、後でコミットまたはロールバックを実行するために呼び出されます。
一部の操作では、ロールバックの実行は非常に簡単です。例: 名前変更操作をロールバックするには、エントリの名前を元の位置に戻すだけで済みます。ただし、他の操作の場合は少し複雑になります。元のエントリから取得した属性を使用してエントリを単にバインドして戻すだけでは、バインド解除操作をロールバックすることはできません。元のエントリからすべての情報を取得できない場合があります。その結果、UnbindOperationExecutor は元のエントリを performOperation() メソッドの一時的な場所に移動します。commit() メソッドはすべてがうまくいったことを認識しているため、エントリのバインドを解除しても問題ありません。ロールバック操作では、エントリの名前を変更して元の場所に戻します。同じ動作が rebind() 操作にも使用されます。エントリの一時的な場所を計算する操作は、setRenamingStrategy(TempEntryRenamingStrategy) で指定された TempEntryRenamingStrategy (デフォルトは DefaultTempEntryRenamingStrategy ) に委譲されます。
このトランザクションマネージャーの実際の作業は ContextSourceTransactionManagerDelegate に委譲されます。これは、JDBC トランザクションと LDAP トランザクションを同じ論理トランザクションにラップする場合、まったく同じロジックを使用する必要があるためです。
- 導入:
- 1.2
- 関連事項:
ContextSourceAndDataSourceTransactionManagerContextSourceTransactionManagerDelegateDefaultCompensatingTransactionOperationManagerTempEntryRenamingStrategyTransactionAwareContextSourceProxy- 連載形式
ネストされたクラスの要約
クラス org.springframework.transaction.support.AbstractPlatformTransactionManager から継承されたネストクラス / インターフェース
org.springframework.transaction.support.AbstractPlatformTransactionManager.SuspendedResourcesHolderフィールドのサマリー
クラス org.springframework.transaction.support.AbstractPlatformTransactionManager から継承されたフィールド
logger, SYNCHRONIZATION_ALWAYS, SYNCHRONIZATION_NEVER, SYNCHRONIZATION_ON_ACTUAL_TRANSACTIONコンストラクターの概要
コンストラクターメソッドのサマリー
修飾子と型メソッド説明voidprotected voidprotected voiddoCleanupAfterCompletion(ObjectSE transaction) protected voiddoCommit(org.springframework.transaction.support.DefaultTransactionStatus status) protected ObjectSEprotected voiddoRollback(org.springframework.transaction.support.DefaultTransactionStatus status) ContextSource を入手。protected booleanisExistingTransaction(ObjectSE transaction) voidsetContextSource(ContextSource contextSource) ContextSource を設定します。voidsetRenamingStrategy(TempEntryRenamingStrategy renamingStrategy) TempEntryRenamingStrategyを設定してください。クラス org.springframework.transaction.support.AbstractPlatformTransactionManager から継承されたメソッド
commit, determineTimeout, doResume, doSetRollbackOnly, doSuspend, getDefaultTimeout, getTransaction, getTransactionExecutionListeners, getTransactionSynchronization, invokeAfterCompletion, isFailEarlyOnGlobalRollbackOnly, isGlobalRollbackOnParticipationFailure, isNestedTransactionAllowed, isRollbackOnCommitFailure, isValidateExistingTransaction, prepareForCommit, prepareSynchronization, registerAfterCompletionWithExistingTransaction, resume, rollback, setDefaultTimeout, setFailEarlyOnGlobalRollbackOnly, setGlobalRollbackOnParticipationFailure, setNestedTransactionAllowed, setRollbackOnCommitFailure, setTransactionExecutionListeners, setTransactionSynchronization, setTransactionSynchronizationName, setValidateExistingTransaction, shouldCommitOnGlobalRollbackOnly, suspend, triggerBeforeCommit, triggerBeforeCompletion, useSavepointForNestedTransactionクラス java.lang.ObjectSE から継承されたメソッド
clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, toString, wait, waitSE, waitSEインターフェース org.springframework.transaction.ConfigurableTransactionManager から継承されたメソッド
addListener
コンストラクターの詳細
ContextSourceTransactionManager
public ContextSourceTransactionManager()
メソッドの詳細
doBegin
protected void doBegin(ObjectSE transaction, org.springframework.transaction.TransactionDefinition definition) - 次で指定:
- クラス
org.springframework.transaction.support.AbstractPlatformTransactionManagerのdoBegin
doCleanupAfterCompletion
- オーバーライド:
- クラス
org.springframework.transaction.support.AbstractPlatformTransactionManagerのdoCleanupAfterCompletion
doCommit
protected void doCommit(org.springframework.transaction.support.DefaultTransactionStatus status) - 次で指定:
- クラス
org.springframework.transaction.support.AbstractPlatformTransactionManagerのdoCommit
doGetTransaction
- 次で指定:
- クラス
org.springframework.transaction.support.AbstractPlatformTransactionManagerのdoGetTransaction
doRollback
protected void doRollback(org.springframework.transaction.support.DefaultTransactionStatus status) - 次で指定:
- クラス
org.springframework.transaction.support.AbstractPlatformTransactionManagerのdoRollback
getContextSource
ContextSource を入手。- 戻り値:
- contextSource。
- 関連事項:
setContextSource
ContextSource を設定します。- パラメーター:
contextSource- ContextSource。- 関連事項:
setRenamingStrategy
TempEntryRenamingStrategyを設定してください。- パラメーター:
renamingStrategy- 名前変更戦略。- 関連事項:
afterPropertiesSet
- 次で指定:
- インターフェース
org.springframework.beans.factory.InitializingBeanのafterPropertiesSet - 例外:
ExceptionSE
isExistingTransaction
protected boolean isExistingTransaction(ObjectSE transaction) throws org.springframework.transaction.TransactionException - オーバーライド:
- クラス
org.springframework.transaction.support.AbstractPlatformTransactionManagerのisExistingTransaction - 例外:
org.springframework.transaction.TransactionException