Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*-
  * See the file LICENSE for redistribution information.
  *
  * Copyright (c) 2002, 2013 Oracle and/or its affiliates.  All rights reserved.
  *
  * $Id$
  */
 package com.sleepycat.je.trigger;
 
TransactionTrigger defines the methods that track a transaction through its lifecycle. The following table captures the relationship between transaction lifecycle operations and their trigger methods.

WARNING: Only transient triggers are currently supported, and the documention below has not yet been updated to reflect this fact. See details at the top of Trigger.java. Also see the warning at the top of ReplicatedDatabaseTrigger.java.

Transaction OperationTrigger Method
Transaction.commit. If the database was was modified in the scope of the transaction.commit
Transaction.abort. If the database was was modified in the scope of the transaction.abort

The use of method names in the above table is intended to cover all overloaded methods with that name.

The trigger methods are also invoked for transactions that are implicitly initiated on behalf of the application in the following two cases:

  1. When using auto-commit.
  2. During the replay of transactions on a Replica when using a ReplicatedEnvironment.

A TransactionTrigger is associated with a database via DatabaseConfig.setTriggers.

Trigger applications that only make changes to the JE environment in the transaction scope of the transaction supplied to the DatbaseTrigger do not typically need to define Transaction triggers, since the changes they make are committed and rolled back automatically by this transaction. For example, triggers defined solely to create additional indexes in the environment do not need to define transaction triggers. Only sophisticated applications that manage state outside of JE, or in independent transactions typically define such triggers.
public interface TransactionTrigger {

    
The trigger method invoked after a transaction has been committed. The method is only invoked if the database was modified during the course of the transaction, that is, if a DatabaseTrigger trigger method was invoked within the scope of the transaction.

Parameters:
txn the transaction that was committed
    public abstract void commit(Transaction txn);

    
The trigger method invoked after the transaction has been aborted. The method is only invoked if the database was modified during the course of the transaction, that is, if a DatabaseTrigger trigger method was invoked within the scope of the transaction.

Parameters:
txn the transaction that was aborted
    public abstract void abort(Transaction txn);
New to GrepCode? Check out our FAQ X