Class TransCallbackProxy

Object
com.tailf.dp.annotations.TransCallbackProxy
All Implemented Interfaces:
DpTransCallback

public class TransCallbackProxy extends Object implements DpTransCallback
Callback proxy for Trans Callbacks. Implements the DpTransCallback interface and delegates calls to the registered callback POJO with annotated methods
Since:
3.2.0
  • Constructor Details

    • TransCallbackProxy

      public TransCallbackProxy(Object backupObject)
      Constructor for Callback proxys. Used internally.
      Parameters:
      backupObject - registered callback POJO
  • Method Details

    • getBackupObject

      public Object getBackupObject()
      Retrieve the callback POJO
      Returns:
      Object registered callback object
    • addActionMethod

      public void addActionMethod(String name, Method method)
      Add callback action method to proxy
      Parameters:
      name - canonical action name
      method - registered callback method
    • addActionCapability

      public void addActionCapability(TransCBType transCBType)
      Add action capability from annotated callType used to register capabilities on the server
      Parameters:
      transCBType - action type
    • abort

      public void abort(DpTrans trans) throws DpCallbackException
      Description copied from interface: DpTransCallback
      This callback is responsible for undoing whatever was done in the prepare() phase.
      Specified by:
      abort in interface DpTransCallback
      Parameters:
      trans - Transaction
      Throws:
      DpCallbackException - Callback method failed.
    • commit

      public void commit(DpTrans trans) throws DpCallbackException
      Description copied from interface: DpTransCallback
      This callback is responsible for undoing whatever was done in the prepare() phase.
      Specified by:
      commit in interface DpTransCallback
      Parameters:
      trans - Transaction
      Throws:
      DpCallbackException - Callback method failed.
    • finish

      public void finish(DpTrans trans) throws DpCallbackException
      Description copied from interface: DpTransCallback
      This callback is responsible for releasing resources allocated in the init() phase.
      Specified by:
      finish in interface DpTransCallback
      Parameters:
      trans - Transaction
      Throws:
      DpCallbackException - Callback method failed.
    • init

      public void init(DpTrans trans) throws DpCallbackException
      Description copied from interface: DpTransCallback
      The callback must indicate which WORKER_SOCKET should be used for future communications in this transaction. This is the mechanism which is used by Conf to distribute work among multiple worker threads in the database application.
      Specified by:
      init in interface DpTransCallback
      Parameters:
      trans - Transaction
      Throws:
      DpCallbackException - Callback method failed.
    • mask

      public int mask()
      Description copied from interface: DpTransCallback
      Specified by:
      mask in interface DpTransCallback
    • prepare

      public void prepare(DpTrans trans) throws DpCallbackException
      Description copied from interface: DpTransCallback
      If we have multiple sources of data it is highly recommended that the callback is implemented. The callback is called at the end of the transaction, when all read and write operations for the transaction have been performed and the transaction should prepare to commit.
      Specified by:
      prepare in interface DpTransCallback
      Parameters:
      trans - Transaction
      Throws:
      DpCallbackException - Callback method failed.
    • transLock

      public void transLock(DpTrans trans) throws DpCallbackException
      Description copied from interface: DpTransCallback
      This callback is invoked when the validation phase of the transaction starts. If the underlying database supports real transactions, it is usually appropriate to start such a native transaction here.

      The transaction enters VALIDATE state, where the system will perform a series of read() operations.

      The trans lock is set until either transUnlock() or finish() is called. the system ensures that a transLock is set on a single transaction only.

      Specified by:
      transLock in interface DpTransCallback
      Parameters:
      trans - Transaction
      Throws:
      DpCallbackException - Callback method failed.
    • transUnlock

      public void transUnlock(DpTrans trans) throws DpCallbackException
      Description copied from interface: DpTransCallback
      This callback is called when the validation of the transaction failed, or the validation is triggered explicitly (i.e. not part of a user can enter invalid data. Transactions that originate from NETCONF will never trigger this callback. If the underlying database supports real transactions and they are used, the transaction should be aborted here.

      The transaction re-enters READ state.

      Specified by:
      transUnlock in interface DpTransCallback
      Parameters:
      trans - Transaction
      Throws:
      DpCallbackException - Callback method failed.
    • writeStart

      public void writeStart(DpTrans trans) throws DpCallbackException
      Description copied from interface: DpTransCallback
      This callback is invoked when the validation succeeded and the write phase of the transaction starts. If the underlying database supports real transactions, it is usually appropriate to start such a native transaction here.

      The transaction enters the WRITE state. No more read() operations will be performed by the system.

      Specified by:
      writeStart in interface DpTransCallback
      Parameters:
      trans - Transaction
      Throws:
      DpCallbackException - Callback method failed.
    • getTransCallbackProxys

      public static TransCallbackProxy[] getTransCallbackProxys(Object obj) throws DpCallbackException
      Get array of proxy objects from registered POJO callback. Used internally at callback registration
      Parameters:
      obj - registered Callback POJO
      Returns:
      array of TransCallbackProxy
      Throws:
      DpCallbackException