Overview
Package
Class
Use
Tree
Deprecated
Index
All Classes
Help
Prev Class
Next Class
VUtils – Release 1
Interface org.violetlib.io.Transactional
Inherited members: ShowHide
Deprecated: ShowHide
org.violetlib.io

Interface Transactional

  • All Superinterfaces:
    AutoCloseable
    All Known Subinterfaces:
    IOTransactional, TransactionalOutputStream, TransactionalUncheckedOutputStream, TransactionalUncheckedWriter, TransactionalWriter
    public interface Transactional extends AutoCloseable
    A general transactional operation.

    A transactional operation is an atomic operation on data that may be defined incrementally. Between the creation and termination of the operation, creation of other transactional operations may be prevented, to ensure that each operation starts with the latest state of the associated data.

    This interface defines two methods that terminate a transactional operation. These methods change the state of the transactional object to terminated. In the terminated state, invocations of these methods have no effect and invocations of other operations may throw an IllegalStateException.

    The terminating methods are commit() and abort(). The commit method must be called after the operation has been fully defined to actually perform the operation on the data. Otherwise, the abort method must be called, to ensure that temporary resources are released, other transactional operations on the data can be created, and a subsequent invocation of commit(), even by accident, has no effect.

    The above description means that one may call commit() after calling abort() or call abort() after calling commit(); in either case, the second method invocation will have no effect. Thus, it is possible and convenient to call commit() at the end of a try body and call abort() in a finally clause of the same try statement. Even more conveniently, if the transactional writer is created and used within a try-with-resources statement, no explicit invocation of abort() is required, because it will be called implicitly (as close() is defined to call abort()).

    • Methods 
      Modifier and Type Method and Description
      Ordinary member indicator abort Reveal DetailHide Detail
      abstract void abort()
      This method has no effect if the operation has already been committed or aborted.
      void abort()
      This method has no effect if the operation has already been committed or aborted. Otherwise, abort the operation so that (if possible) no partial effects are visible.
      Ordinary member indicator close Reveal DetailHide Detail
      void close()
      The close method is defined to invoke the abort method.
      void close() throws Exception
      The close method is defined to invoke the abort method. This behavior allows a transactional operation to be used in a try-with-resources statement with no explicit invocation of abort().
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception
      Ordinary member indicator commit Reveal DetailHide Detail
      abstract void commit()
      This method has no effect if the operation has already been committed or aborted.
      void commit() throws Exception
      This method has no effect if the operation has already been committed or aborted. Otherwise, commit the operation by updating the associated data.
      Throws:
      Exception - if the attempt to update the data was unsuccessful.