001    /*
002     * 
003     * $Revision: 13085 $ $Date: 2008-02-06 18:27:24 +0100 (Mi, 06 Feb 2008) $
004     *
005     * This file is part of ***  M y C o R e  ***
006     * See http://www.mycore.de/ for details.
007     *
008     * This program is free software; you can use it, redistribute it
009     * and / or modify it under the terms of the GNU General Public License
010     * (GPL) as published by the Free Software Foundation; either version 2
011     * of the License or (at your option) any later version.
012     *
013     * This program is distributed in the hope that it will be useful, but
014     * WITHOUT ANY WARRANTY; without even the implied warranty of
015     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016     * GNU General Public License for more details.
017     *
018     * You should have received a copy of the GNU General Public License
019     * along with this program, in a file called gpl.txt or license.txt.
020     * If not, write to the Free Software Foundation Inc.,
021     * 59 Temple Place - Suite 330, Boston, MA  02111-1307 USA
022     */
023    
024    package org.mycore.common.events;
025    
026    import org.mycore.common.MCRException;
027    
028    /**
029     * Objects that implement this interface can react when some kind of predefined
030     * event happens in MyCoRe. Implementing classes are registered using the
031     * configuration property
032     * 
033     * MCR.EventHandler.[objType].X.Class=[package and class name]
034     * 
035     * where [objType] is the object type like "MCRObject" or "MCRFile" and X is a
036     * number starting from 1. For event handlers that are indexers of the searcher
037     * package, there is a special syntax
038     * 
039     * MCR.EventHandler.[objType].X.Indexer=[searcherID]
040     * 
041     * where [searcherID] is the ID of the searcher that also is an indexer. Event
042     * handlers are called in the same order as they are registered in the
043     * properties file.
044     * 
045     * @author Frank Lützenkirchen
046     */
047    public interface MCREventHandler {
048        /**
049         * Handles an event. The handler is responsible for filtering the event type
050         * it is interested in and wants to react on.
051         * 
052         * @param evt
053         *            the Event object containing information about the event
054         */
055        public void doHandleEvent(MCREvent evt) throws MCRException;
056    
057        /**
058         * Handles rollback of event handling. The handler should roll back the
059         * changes that previously were made for this event, because a successor in
060         * the event handler list caused an exception.
061         * 
062         * @param evt
063         *            the Event object containing information about the event
064         */
065        public void undoHandleEvent(MCREvent evt) throws MCRException;
066    }