Class MorphiaGuiceTransaction

java.lang.Object
dev.getelements.elements.dao.mongo.guice.MorphiaGuiceTransaction
All Implemented Interfaces:
Transaction, AutoCloseable

public class MorphiaGuiceTransaction extends Object implements Transaction
  • Field Details

  • Constructor Details

    • MorphiaGuiceTransaction

      public MorphiaGuiceTransaction()
  • Method Details

    • getDao

      public <DaoT> DaoT getDao(Class<DaoT> daoT)
      Description copied from interface: Transaction
      Gets the requested Dao type, bound to this Transaction. The returned DAO is only valid for the life of this Transaction object.
      Specified by:
      getDao in interface Transaction
      Type Parameters:
      DaoT - the DAO Type
      Parameters:
      daoT - the Class<DaoT>
      Returns:
      the DAO Instance
    • isActive

      public boolean isActive()
      Description copied from interface: Transaction
      Returns true if this transaction is still active and open.
      Specified by:
      isActive in interface Transaction
      Returns:
      true if active, false if it has been committed or rolled back.
    • wrap

      public <T> Function<Transaction,T> wrap(Function<Transaction,T> original)
      Description copied from interface: Transaction
      Optionally, wraps the transaction operation in another Function to properly handle any retry exceptions specific to the transaction's implementation. This ensures that any executed code will properly honor the semantics of Transaction.RetryException.
      Specified by:
      wrap in interface Transaction
      Type Parameters:
      T - the return type
      Parameters:
      original - the operation
      Returns:
      the wrapped function, or the original function
    • commit

      public void commit()
      Description copied from interface: Transaction
      Commits the transaction. In the event the transaction fails due to a transient condition, a Transaction.RetryException is thrown. The caller should then rollback the transaction, wait for the recommended delay and then restart and re-execute the entire transaction.
      Specified by:
      commit in interface Transaction
    • start

      public void start()
      Description copied from interface: Transaction
      Starts the transaction. Note, transactions are stared automatically when the Transaction object is created so this is only necessary if the transaction has been explicitly aborted via rollback operation.
      Specified by:
      start in interface Transaction
    • rollback

      public void rollback()
      Description copied from interface: Transaction
      Rolls back the transaction undoing any pending changes to the database.
      Specified by:
      rollback in interface Transaction
    • close

      public void close()
      Description copied from interface: Transaction
      Closes and releases the transaction. Once closed, the transaction is no longer active and any DAOs acquired will have undefined behavior if used.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Transaction
    • getMaxRetries

      public int getMaxRetries()
    • setMaxRetries

      @Inject public void setMaxRetries(@Named("dev.getelements.elements.mongo.transaction.retry.count") int maxRetries)
    • getRetryTimeout

      public long getRetryTimeout()
    • setRetryTimeout

      @Inject public void setRetryTimeout(@Named("dev.getelements.elements.mongo.transaction.retry.timeout") long retryTimeout)
    • getInjector

      public com.google.inject.Injector getInjector()
    • setInjector

      @Inject public void setInjector(com.google.inject.Injector injector)
    • getMorphiaSession

      public dev.morphia.transactions.MorphiaSession getMorphiaSession()
    • setMorphiaSession

      @Inject public void setMorphiaSession(dev.morphia.transactions.MorphiaSession morphiaSession)
    • getBufferedEventPublisher

      public MongoTransactionBufferedEventPublisher getBufferedEventPublisher()
    • setBufferedEventPublisher

      @Inject public void setBufferedEventPublisher(MongoTransactionBufferedEventPublisher bufferedEventPublisher)