クラス ContextSourceTransactionManager

java.lang.ObjectSE
org.springframework.transaction.support.AbstractPlatformTransactionManager
org.springframework.ldap.transaction.compensating.manager.ContextSourceTransactionManager
実装されているすべてのインターフェース:
SerializableSEorg.springframework.beans.factory.InitializingBeanorg.springframework.transaction.ConfigurableTransactionManagerorg.springframework.transaction.PlatformTransactionManagerorg.springframework.transaction.TransactionManager

public class ContextSourceTransactionManager extends org.springframework.transaction.support.AbstractPlatformTransactionManager implements org.springframework.beans.factory.InitializingBean
TransactionManager LDAP トランザクション管理用。LDAP プロトコルではトランザクションがサポートされていないため、このクラスとそのコラボレータは、代わりにカバレッジトランザクションを提供することを目的としています。トランザクションをロールバックする必要がある場合、この 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
関連事項:
  • ネストされたクラスの要約

    クラス 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
  • コンストラクターの概要

    コンストラクター
    コンストラクター
    説明
  • メソッドのサマリー

    修飾子と型
    メソッド
    説明
    void
    protected void
    doBegin(ObjectSE transaction, org.springframework.transaction.TransactionDefinition definition)
    protected void
    protected void
    doCommit(org.springframework.transaction.support.DefaultTransactionStatus status)
    protected ObjectSE
    protected void
    doRollback(org.springframework.transaction.support.DefaultTransactionStatus status)
    ContextSource を入手。
    protected boolean
    void
    ContextSource を設定します。
    void
    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.AbstractPlatformTransactionManagerdoBegin 
    • doCleanupAfterCompletion

      protected void doCleanupAfterCompletion(ObjectSE transaction)
      オーバーライド:
      クラス org.springframework.transaction.support.AbstractPlatformTransactionManagerdoCleanupAfterCompletion 
    • doCommit

      protected void doCommit(org.springframework.transaction.support.DefaultTransactionStatus status)
      次で指定:
      クラス org.springframework.transaction.support.AbstractPlatformTransactionManagerdoCommit 
    • doGetTransaction

      protected ObjectSE doGetTransaction()
      次で指定:
      クラス org.springframework.transaction.support.AbstractPlatformTransactionManagerdoGetTransaction 
    • doRollback

      protected void doRollback(org.springframework.transaction.support.DefaultTransactionStatus status)
      次で指定:
      クラス org.springframework.transaction.support.AbstractPlatformTransactionManagerdoRollback 
    • getContextSource

      public ContextSource getContextSource()
      ContextSource を入手。
      戻り値:
      contextSource。
      関連事項:
    • setContextSource

      public void setContextSource(ContextSource contextSource)
      ContextSource を設定します。
      パラメーター:
      contextSource - ContextSource。
      関連事項:
    • setRenamingStrategy

      public void setRenamingStrategy(TempEntryRenamingStrategy renamingStrategy)
      TempEntryRenamingStrategy を設定してください。
      パラメーター:
      renamingStrategy - 名前変更戦略。
      関連事項:
    • afterPropertiesSet

      public void afterPropertiesSet() throws ExceptionSE
      次で指定:
      インターフェース org.springframework.beans.factory.InitializingBeanafterPropertiesSet 
      例外:
      ExceptionSE
    • isExistingTransaction

      protected boolean isExistingTransaction(ObjectSE transaction) throws org.springframework.transaction.TransactionException
      オーバーライド:
      クラス org.springframework.transaction.support.AbstractPlatformTransactionManagerisExistingTransaction 
      例外:
      org.springframework.transaction.TransactionException