Bio::DB::DBI TransactionListener
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvs
Summary
Bio::DB::DBI::TransactionListener - a simple transaction listener
Package variables
Privates (from "my" definitions)
$counter = 1
Included modules
Bio::Root::Root
Inherit
Bio::Root::Root
Synopsis
    # see method section
Description
This object is the contract and at the same time a simple (neutral)
implementation of a transaction listener.
Transaction listeners are notified before and after commit and
rollback on transactions as represented by a
Bio::DB::DBI::Transaction objects.
Note that this is a very loose contract in the sense that it is not
enforced. Therefore it serves more as a guideline of what you *can*
do rather than what you have to do.
You may currently choose between 3 different options on how to listen
to transactions:
    - write your own transaction listener that inherits from this
class and overrides methods as suitable, then use your class to
add listeners to Transactions
- let your adaptor or persistent object module inherit from this class and thereby make it a listener-compliant object that you can then use to register with Transactions - register any object with Transaction that implements at least one of the methods defined here (if it implements none then what's the point?). Transaction will only call the methods defined here if the listener actually implements them.
Methods
newDescriptionCode
register_subDescriptionCode
before_commitDescriptionCode
after_commitDescriptionCode
before_rollbackDescriptionCode
after_rollbackDescriptionCode
Methods description
newcode    nextTop
 Title   : new
Usage : my $obj = Bio::DB::DBI::TransactionListener->new();
Function: Builds a new Bio::DB::DBI::TransactionListener object
Returns : an instance of Bio::DB::DBI::TransactionListener
Args :
register_subcodeprevnextTop
 Title   : register_sub
Usage :
Function: Register an anonymous code block for being executed in
one of the listener methods.
This method is probably mostly useful for testing purposes, but who knows. You may call this as a class method or an object method. Example : Returns : an instance of this class with the supplied anonymous function overriding the specified listener method Args : the code reference to register the name(s) of the interface method(s) to register it for (optional, if not specified the code block will be registered for all 4 methods)
before_commitcodeprevnextTop
 Title   : before_commit
Usage :
Function: Called before a commit is issued.
Any listener may veto a pending commit by returning false. The default implementation returns true. Example : Returns : TRUE if the transaction is good to be committed, and FALSE if it is vetoed. Args : none
after_commitcodeprevnextTop
 Title   : after_commit
Usage :
Function: Called after a commit was issued.
The default implementation here does nothing. Example : Returns : ignored Args : none
before_rollbackcodeprevnextTop
 Title   : before_rollback
Usage :
Function: Called before a rollback is issued.
A listener cannot veto a pending rollback. The return value and even thrown exceptions will be ignored by Transaction. Example : Returns : ignored Args : none
after_rollbackcodeprevnextTop
 Title   : after_rollback
Usage :
Function: Called after a rollback is issued.
Example : Returns : ignored Args : none
Methods code
newdescriptionprevnextTop
sub new {
    my($class,@args) = @_;
    
    my $self = $class->SUPER::new(@args);
    return $self;
}
register_subdescriptionprevnextTop
sub register_sub {
   my ($class,$code,@meths) = @_;

   @meths = ("before_commit","after_commit",
	     "before_rollback","after_rollback") unless @meths;
   $class = ref($class) || $class;
   $class .= ++$counter;
   my $obj = bless {}, $class;
   foreach my $meth (@meths) {
       *{"$class::$meth"} = $code;
   }
   return $obj;
}
before_commitdescriptionprevnextTop
sub before_commit {
    return 1;
}
after_commitdescriptionprevnextTop
sub after_commit {
    return 1;
}
before_rollbackdescriptionprevnextTop
sub before_rollback {
    return 1;
}
after_rollbackdescriptionprevnextTop
sub after_rollback {
    return 1;
}

1;
}
General documentation
FEEDBACKTop
Mailing ListsTop
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.
  bioperl-l@bioperl.org                  - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
Support Top
 
Please direct usage questions or support issues to the mailing list:

bioperl-l@bioperl.org

rather than to the module maintainer directly. Many experienced and
reponsive experts will be able look at the problem and quickly
address it. Please include a thorough description of the problem
with code and data examples if at all possible.
Reporting BugsTop
Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via
the web:
  http://bugzilla.open-bio.org/
AUTHOR - Hilmar LappTop
Email hlapp at gmx.net
Describe contact details here
CONTRIBUTORSTop
Additional contributors names and emails here
APPENDIXTop
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
TransactionListener interface methodsTop
The following methods define the interface for TransactionListeners.