001/*
002 * #%L
003 * Netarchivesuite - harvester
004 * %%
005 * Copyright (C) 2005 - 2014 The Royal Danish Library, the Danish State and University Library,
006 *             the National Library of France and the Austrian National Library.
007 * %%
008 * This program is free software: you can redistribute it and/or modify
009 * it under the terms of the GNU Lesser General Public License as
010 * published by the Free Software Foundation, either version 2.1 of the
011 * License, or (at your option) any later version.
012 * 
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Lesser Public License for more details.
017 * 
018 * You should have received a copy of the GNU General Lesser Public
019 * License along with this program.  If not, see
020 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
021 * #L%
022 */
023
024package dk.netarkivet.harvester.distribute;
025
026import dk.netarkivet.harvester.harvesting.distribute.CrawlProgressMessage;
027import dk.netarkivet.harvester.harvesting.distribute.CrawlStatusMessage;
028import dk.netarkivet.harvester.harvesting.distribute.DoOneCrawlMessage;
029import dk.netarkivet.harvester.harvesting.distribute.FrontierReportMessage;
030import dk.netarkivet.harvester.harvesting.distribute.HarvesterReadyMessage;
031import dk.netarkivet.harvester.harvesting.distribute.HarvesterRegistrationRequest;
032import dk.netarkivet.harvester.harvesting.distribute.HarvesterRegistrationResponse;
033import dk.netarkivet.harvester.harvesting.distribute.JobEndedMessage;
034import dk.netarkivet.harvester.indexserver.distribute.IndexRequestMessage;
035
036/**
037 * Interface for all classes which handles harvester-related messages received from a JMS server. This is implemented
038 * with a visitor pattern: Upon receipt, the HarvesterMessageHandler.onMessage() method invokes the
039 * Harvesteressage.accept() method on the message with itself as argument. The accept() method in turn invokes the
040 * HarvesterMessageVisitorvisit() method, using method overloading to invoke the visit method for the message received.
041 * <p>
042 * Thus to handle a message, you should subclass HarvesterMessageHandler and override the visit() method for that kind
043 * of message. You should not implement this interface in any other way.
044 */
045public interface HarvesterMessageVisitor {
046    /**
047     * This method should be overridden to handle the receipt of a message.
048     *
049     * @param msg A received message.
050     */
051    void visit(CrawlStatusMessage msg);
052
053    /**
054     * This method should be overridden to handle the receipt of a message.
055     *
056     * @param msg A received message.
057     */
058    void visit(DoOneCrawlMessage msg);
059
060    /**
061     * This method should be overridden to handle the receipt of a message.
062     *
063     * @param msg A received message.
064     */
065    void visit(CrawlProgressMessage msg);
066
067    /**
068     * This method should be overridden to handle the receipt of a message.
069     *
070     * @param msg A received message.
071     */
072    void visit(FrontierReportMessage msg);
073
074    /**
075     * This method should be overridden to handle the receipt of a message.
076     *
077     * @param msg A received message.
078     */
079    void visit(JobEndedMessage msg);
080
081    /**
082     * This method should be overridden to handle the receipt of a message.
083     *
084     * @param msg A received message.
085     */
086    void visit(HarvesterReadyMessage msg);
087
088    /**
089     * This method should be overridden to handle the receipt of a message.
090     *
091     * @param msg A received message.
092     */
093    void visit(IndexReadyMessage msg);
094
095    /**
096     * This method should be overridden to handle the receipt of a message.
097     *
098     * @param msg A received message.
099     */
100    void visit(IndexRequestMessage msg);
101
102    /**
103     * This method should be overridden to handle the receipt of a message.
104     *
105     * @param msg A received message.
106     */
107    void visit(HarvesterRegistrationRequest msg);
108
109    /**
110     * This method should be overridden to handle the receipt of a message.
111     *
112     * @param msg A received message.
113     */
114    void visit(HarvesterRegistrationResponse msg);
115
116}