2 * FreenetSone - SoneInserter.java - Copyright © 2010 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.sone.core;
20 import java.util.logging.Level;
21 import java.util.logging.Logger;
23 import net.pterodactylus.sone.data.Sone;
24 import net.pterodactylus.util.logging.Logging;
25 import net.pterodactylus.util.service.AbstractService;
28 * A Sone inserter is responsible for inserting a Sone if it has changed.
30 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
32 public class SoneInserter extends AbstractService {
35 private static final Logger logger = Logging.getLogger(SoneInserter.class);
37 /** The Sone to insert. */
38 private final Sone sone;
41 * Creates a new Sone inserter.
43 * @param freenetInterface
44 * The freenet interface
48 public SoneInserter(FreenetInterface freenetInterface, Sone sone) {
49 super("Sone Inserter for “" + sone.getName() + "”");
61 protected void serviceRun() {
62 while (!shouldStop()) {
64 if (sone.getModificationCounter() > 0) {
65 sone.setModificationCounter(0);
68 logger.log(Level.FINEST, "Waiting 60 seconds before checking Sone “" + sone.getName() + "” again.");