KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > nava > informa > utils > cleaner > PersistenceObserver


1 //
2
// Informa -- RSS Library for Java
3
// Copyright (c) 2002 by Niko Schmuck
4
//
5
// Niko Schmuck
6
// http://sourceforge.net/projects/informa
7
// mailto:niko_schmuck@users.sourceforge.net
8
//
9
// This library is free software.
10
//
11
// You may redistribute it and/or modify it under the terms of the GNU
12
// Lesser General Public License as published by the Free Software Foundation.
13
//
14
// Version 2.1 of the license should be included with this distribution in
15
// the file LICENSE. If the license is not included with this distribution,
16
// you may find a copy at the FSF web site at 'www.gnu.org' or 'www.fsf.org',
17
// or you may write to the Free Software Foundation, 675 Mass Ave, Cambridge,
18
// MA 02139 USA.
19
//
20
// This library is distributed in the hope that it will be useful,
21
// but WITHOUT ANY WARRANTY; without even the implied waranty of
22
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23
// Lesser General Public License for more details.
24
//
25
// $Id: PersistenceObserver.java,v 1.2 2004/09/02 09:08:34 spyromus Exp $
26
//
27

28 package de.nava.informa.utils.cleaner;
29
30 import de.nava.informa.core.ChannelIF;
31 import de.nava.informa.core.ItemIF;
32 import de.nava.informa.utils.manager.PersistenceManagerIF;
33 import de.nava.informa.utils.manager.PersistenceManagerException;
34
35 /**
36  * Watches for events about unwanted items and removes them from channel using given manager.
37  *
38  * @author Aleksey Gureev (spyromus@noizeramp.com)
39  */

40 public class PersistenceObserver implements CleanerObserverIF {
41   private PersistenceManagerIF manager;
42
43   /**
44    * Creates observer.
45    *
46    * @param manager manager to use for persistent changes.
47    *
48    * @throws IllegalArgumentException if manager isn't specified.
49    */

50   public PersistenceObserver(PersistenceManagerIF manager) {
51     if (manager == null) {
52       throw new IllegalArgumentException JavaDoc("Manager should be specified.");
53     }
54
55     this.manager = manager;
56   }
57
58   /**
59    * Invoked when cleanup engine finds unwanted item.
60    *
61    * @param item unwanted item.
62    * @param channel channel this item resides in.
63    */

64   public final void unwantedItem(ItemIF item, ChannelIF channel) {
65     try {
66       manager.deleteItem(item);
67     } catch (PersistenceManagerException e) {
68       // We can do nothing here.
69
}
70   }
71
72   /**
73    * Invoked by cleanup engine when cleaning of the channel has started.
74    *
75    * @param channel channel being cleaned.
76    */

77   public void cleaningStarted(ChannelIF channel) {
78   }
79
80   /**
81    * Invoked by cleanup engine when cleaning of the channel has finished.
82    *
83    * @param channel channel being cleaned.
84    */

85   public void cleaningFinished(ChannelIF channel) {
86   }
87 }
88
Popular Tags