org.eclipse.emf.transaction.impl
Interface TransactionValidator

All Known Implementing Classes:
ReadOnlyValidatorImpl, ReadWriteValidatorImpl

public interface TransactionValidator

Interface for an object that validates a transaction when it commits. Different implementations are provided for read and for write transactions.

See Also:
ReadOnlyValidatorImpl, ReadWriteValidatorImpl, Transaction.commit()

Nested Class Summary
static interface TransactionValidator.Factory
          Interface that clients implement to define a validator factory.
 
Field Summary
static TransactionValidator NULL
          A "null" instance that is suitable for use when there is no active transaction.
 
Method Summary
 void add(InternalTransaction transaction)
          Adds a transaction for eventual validation.
 void dispose()
          Disposes me by clearing my state and cleaning up any resources that I am retaining.
 List<Notification> getNotificationsForPostcommit(Transaction tx)
          Obtains the notifications that I need to broadcast in a post-commit resource-change event for the specified transaction.
 List<Notification> getNotificationsForPrecommit(Transaction tx)
          Obtains the notifications that I need to broadcast in a pre-commit resource-change event for the specified transaction.
 List<Notification> getNotificationsForValidation(Transaction tx)
          Obtains the notifications received, in order, during the execution of the (possibly nested) transaction(s) that I am validating.
 void remove(InternalTransaction transaction)
          Removes a transaction that has rolled back.
 IStatus validate(Transaction tx)
          Performs the validation step of a commit.
 

Field Detail

NULL

static final TransactionValidator NULL
A "null" instance that is suitable for use when there is no active transaction. It does not provide any notifications, nor does it validate anything.

Method Detail

add

void add(InternalTransaction transaction)
Adds a transaction for eventual validation. Transactions must be added to the editing domain's current validator as soon as they are activated, so that it does not miss any notifications.

Parameters:
transaction - the transaction (root or a nested transaction) to add

remove

void remove(InternalTransaction transaction)
Removes a transaction that has rolled back. Transactions must be removed as soon as they roll back. Removal ensures that we do not pass to the resource set listeners any notifications of changes that were rolled back.

Note that, for efficiency, transactions that have successfully committed should also be removed after they have been deactivated. This ensures that they are no longer referenced by validator and can, therefore, be reclaimed (the validator retains the notifications, only).

Parameters:
transaction - the transaction (root or a nested transaction) to remove

validate

IStatus validate(Transaction tx)
Performs the validation step of a commit.

Parameters:
tx - the transaction to validate
Returns:
the status of validation. If the severity is error or worse, then the transaction must roll back, and this status included in the exception
See Also:
Transaction.commit(), RollbackException

getNotificationsForValidation

List<Notification> getNotificationsForValidation(Transaction tx)
Obtains the notifications received, in order, during the execution of the (possibly nested) transaction(s) that I am validating.

Parameters:
tx - the transaction to be validated
Returns:
the transaction's notifications, or null if the transaction has not started yet

getNotificationsForPrecommit

List<Notification> getNotificationsForPrecommit(Transaction tx)
Obtains the notifications that I need to broadcast in a pre-commit resource-change event for the specified transaction. Note that this does not include notifications from "no-triggers" transactions.

Parameters:
tx - the transaction to be broadcast
Returns:
those of the transaction's notifications that are eligible to be broadcast, or null if the transaction has not started

getNotificationsForPostcommit

List<Notification> getNotificationsForPostcommit(Transaction tx)
Obtains the notifications that I need to broadcast in a post-commit resource-change event for the specified transaction. Note that this does not include notifications from "silent" transactions.

Parameters:
tx - the transaction to be broadcast
Returns:
those of the transaction's notifications that are eligible to be broadcast, or null if the transaction has not started

dispose

void dispose()
Disposes me by clearing my state and cleaning up any resources that I am retaining.


Copyright 2002, 2007 IBM Corporation and others.
All Rights Reserved.