Oberon ||
Library ||
Module Index ||
Search Engine ||
Definition ||
Module
Ulm's Oberon Library:
ObjectTransactions
NAME
ObjectTransactions - transactions which involve one object only
SYNOPSIS
TYPE Object = Services.Object;
TYPE BeginProc = PROCEDURE (object: Object;
trans: Transactions.Transaction) : BOOLEAN;
TYPE TransProc = PROCEDURE (object: Object) : BOOLEAN;
TYPE Interface = POINTER TO InterfaceRec;
TYPE InterfaceRec =
RECORD
(Objects.ObjectRec)
begin: BeginProc;
commit, abort, release: TransProc;
END;
CONST notSupported = 0;
CONST oneObjectOnly = 1;
CONST alreadyAttached = 2;
CONST authorizationFailed = 3;
CONST invalidTransition = 4;
CONST noObjectAttached = 5;
CONST transReleased = 6;
CONST errors = 7;
TYPE ErrorCode = SHORTINT; (* notSupported..transReleased *)
TYPE ErrorEvent = POINTER TO ErrorEventRec;
TYPE ErrorEventRec =
RECORD
(Events.EventRec)
errorcode: ErrorCode;
END;
VAR error: Events.EventType;
VAR errormsg: ARRAY errors OF Events.Message;
(* implementors side *)
PROCEDURE Register(type: Services.Type; if: Interface);
(* client side *)
PROCEDURE Supported(object: Object) : BOOLEAN;
PROCEDURE Create(VAR trans: Transactions.Transaction;
object: Object; pot: Shards.Pot;
errors: RelatedEvents.Object) : BOOLEAN;
DESCRIPTION
ObjectTransactions
is a trivial implementation of Transactions
which interfaces those objects which do not support distributed
transactions.
Supporting a Type for ObjectTransactions
Implementors which offer transactions for one specific kind
of objects only have to register themselves at initialization time
by calling Register.
The given interface if is a great simplification in
comparison to that of Transactions and is expected to
meet following specifications:
- begin: PROCEDURE(object: Object; trans: Transactions.Transaction);
-
Begin a transaction in the sense of Transactions
for object.
Note that ObjectTransactions guarantees that the transaction
is neither already running nor released.
FALSE is to be returned if the implementation is for
other reasons unable to start a transaction.
Those operations of object which have a
transaction parameter (e.g. implementations of Containers)
should check it against trans
and fail if it does not match.
- commit: PROCEDURE(object: Object);
-
Commit the running transaction for object.
In case of failures, FALSE is to be returned and the
transaction is considered as aborted, then.
- abort: PROCEDURE(object: Object);
-
Abort the running transaction for object.
FALSE may be returned in case of problems --
but the transaction is to be considered aborted
afterwards independent from the return value, though.
- release: PROCEDURE(object: Object);
-
Final operation on a transaction object which
should cause all resources to be released.
Running Transactions
Supported
allows to check whether an object supports the interface of
this module or not.
Create
creates a transaction in the sense of Transactions
with object attached (if non-NIL) which is
protected by pot (which may be NIL if the
transaction should run unprotected).
If object was not given initially,
one and only one supported object may be attached later by
Transactions.Attach.
Note that objects supported by ObjectTransactions
are not allowed to participate in more than one transaction
concurrently.
All operations of Transactions with the exception
of Transactions.GetName may be applied later under
the restriction that just one object may be attached to it.
Termination of Transactions
ObjectTransactions
supports Resources:
- Released transactions will terminate.
- If a transaction becomes Resources.unreferenced
or Resources.terminated, it will be released
automatically (if this has not been done already).
This includes an implicit abortion if the transaction was active.
- The termination of transaction objects is propagated
to the associated transaction.
Note that terminations by means of Resources.Notify
may bypass the authorization which is needed for
Transactions.Release. This works, however,
only if there are no filter objects involved
because proxy termination is (usually)
not propagated to the original object
(see, for example, RemoteObjects).
DIAGNOSTICS
All operations return FALSE in error cases
and generate appropriate error events in addition to those
generated by underlying levels.
Following error events may be generated by ObjectTransactions:
- notSupported
-
The given object has no support for this module,
i.e. nobody has called Register for its type or one
of its base types.
- oneObjectOnly
-
Transactions created by ObjectTransactions accept one
supported object only.
- alreadyAttached
-
Parallel transactions on one object are not supported.
- authorizationFailed
-
This error gets raised if the given lid auth does
not match the pot which has been passed to Create.
- invalidTransition
-
ObjectTransactions checks all state transitions for
validity, e.g. an aborted transaction must not be committed, or
a not yet begun transaction cannot be aborted.
- noObjectAttached
-
ObjectTransactions does not allow transactions to
be started as long there is no object attached to it.
- transReleased
-
None of the operations must be called after a
transaction has been released.
SEE ALSO
- Resources
-
termination of objects
- Transactions
-
general abstraction of distributed transactions for
which ObjectTransactions offers a trivial implementation
- TransStreams
-
transaction streams support ObjectTransactions
Edited by: borchert, last change: 1996/11/28, revision: 1.2, converted to HTML: 1997/04/28
Oberon ||
Library ||
Module Index ||
Search Engine ||
Definition ||
Module