001package gu.sql2java;
002
003import gu.sql2java.exception.RuntimeDaoException;
004
005/**
006 * Listener that is notified of table changes.
007 * @param <B> java bean type
008 * @author guyadong
009 */
010public interface TableListener<B>{
011    /**
012     * This adapter class provides default implementations for the
013     * methods declared by the {@link TableListener} interface.<br>
014     * 
015     * @author guyadong
016     */
017    public static class Adapter<B> implements TableListener<B>{
018
019        @Override
020        public void beforeInsert(B bean)throws RuntimeDaoException {}
021
022        @Override
023        public void afterInsert(B bean)throws RuntimeDaoException {}
024
025        @Override
026        public void beforeUpdate(B bean)throws RuntimeDaoException {}
027
028        @Override
029        public void afterUpdate(B bean)throws RuntimeDaoException {}
030
031        @Override
032        public void beforeDelete(B bean)throws RuntimeDaoException {}
033
034        @Override
035        public void afterDelete(B bean)throws RuntimeDaoException {}
036        
037        @Override
038        public void done()throws RuntimeDaoException {}
039    }
040    /**
041     * Invoked just before inserting a B record into the database.
042     *
043     * @param bean the B that is about to be inserted
044     * @throws RuntimeDaoException
045     */
046    public void beforeInsert(B bean)throws RuntimeDaoException;
047
048
049    /**
050     * Invoked just after a B record is inserted in the database.
051     *
052     * @param bean the B that was just inserted
053     * @throws RuntimeDaoException
054     */
055    public void afterInsert(B bean)throws RuntimeDaoException;
056
057
058    /**
059     * Invoked just before updating a B record in the database.
060     *
061     * @param bean the B that is about to be updated
062     * @throws RuntimeDaoException
063     */
064    public void beforeUpdate(B bean)throws RuntimeDaoException;
065
066
067    /**
068     * Invoked just after updating a B record in the database.
069     *
070     * @param bean the B that was just updated
071     * @throws RuntimeDaoException
072     */
073    public void afterUpdate(B bean)throws RuntimeDaoException;
074
075
076    /**
077     * Invoked just before deleting a B record in the database.
078     *
079     * @param bean the B that is about to be deleted
080     * @throws RuntimeDaoException
081     */
082    public void beforeDelete(B bean)throws RuntimeDaoException;
083
084
085    /**
086     * Invoked just after deleting a B record in the database.
087     *
088     * @param bean the B that was just deleted
089     * @throws RuntimeDaoException
090     */
091    public void afterDelete(B bean)throws RuntimeDaoException;
092
093    /**
094     * Invoked in finally block, just after insert,update,delete.
095     *
096     * @throws RuntimeDaoException
097     */
098    public void done()throws RuntimeDaoException;
099}
100