1.2.7. Example

The simple example below illustrates the relationships between activation, termination and commitment:
    . . .
    O1 objct1 = new objct1(Name-A);/* (i) bind to "old" persistent object A */
    O2 objct2 = new objct2();	 /* create a "new" persistent object */
    OTS.current().begin();		 /* (ii) start of atomic action */
    objct1.op(...);		      /* (iii) object activation and invocations */
    . . .
    OTS.current().commit(true); 	/* (iv) tx commits & objects deactivated */
    } 					/* (v) */
The execution of the above code involves the following sequence of activities:
  • Creation of bindings to persistent objects; this could involve the creation of stub objects and a call to remote objects. In the above example we re-bind to an existing persistent object identified by Name-A, and a new persistent object. A naming system for remote objects maintains the mapping between object names and locations and is described in a later chapter.
  • Start of the atomic transaction.
  • Operation invocations: as a part of a given invocation the object implementation is responsible to ensure that it is locked in read or write mode (assuming no lock conflict), and initialised, if necessary, with the latest committed state from the object store. The first time a lock is acquired on an object within a transaction the object’s state is acquired, if possible, from the object store.
  • Commit of the top-level action. This includes updating of the state of any modified objects in the object store.
  • Breaking of the previously created bindings.