View Javadoc

1   /*
2    * EL4J, the Extension Library for the J2EE, adds incremental enhancements to
3    * the spring framework, http://el4j.sf.net
4    * Copyright (C) 2006 by ELCA Informatique SA, Av. de la Harpe 22-24,
5    * 1000 Lausanne, Switzerland, http://www.elca.ch
6    *
7    * EL4J is published under the GNU Lesser General Public License (LGPL)
8    * Version 2.1. See http://www.gnu.org/licenses/
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   * GNU Lesser General Public License for more details.
14   *
15   * For alternative licensing, please contact info@elca.ch
16   */
17  package ch.elca.el4j.services.persistence.generic.dao;
18  
19  /**
20   * Notifies registered observers of DAO changes.
21   *
22   * The notifications sent are consistent.
23   *
24   * @svnLink $Revision: 3874 $;$Date: 2009-08-04 14:25:40 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/core/src/main/java/ch/elca/el4j/services/persistence/generic/dao/DaoChangeNotifier.java $
25   *
26   * @author Adrian Moos (AMS)
27   */
28  public interface DaoChangeNotifier {
29  	/** A fuzzy change object so callers do not have to construct their own. */
30  	public static final Change FUZZY_CHANGE = new Change();
31  
32  	/**
33  	 * Sent if something in this DAO view may have changed.
34  	 **/
35  	public static class Change { }
36  	
37  	/**
38  	 * Something about {@link #m_changee} may have changed.
39  	 */
40  	public static class EntityChange extends Change {
41  		/** See class documentation. */
42  		private Object m_changee;
43  
44  		/**
45  		 * @return Returns the changee.
46  		 */
47  		public Object getChangee() {
48  			return m_changee;
49  		}
50  
51  		/**
52  		 * @param changee Is the changee to set.
53  		 */
54  		public void setChangee(Object changee) {
55  			m_changee = changee;
56  		}
57  	}
58  	
59  	/** The {@link #m_changee} has new state. */
60  	public static class NewEntityState extends EntityChange { }
61  	
62  	/** The {@link #m_changee}'s state has changed. */
63  	public static class EntityStateChanged extends NewEntityState { }
64  	
65  	/**
66  	 * The {@link #m_changee} has been inserted.
67  	 */
68  	public static class EntityInserted extends NewEntityState { }
69  	
70  	/**
71  	 * The {@link #m_changee} has been deleted.
72  	 */
73  	public static class EntityDeleted extends EntityChange { }
74  
75  	
76  	/**
77  	 * Causes {@code cl} to receive future change notifications.
78  	 * @param cl The DaoChangeListener to subscribe
79  	 */
80  	public void subscribe(DaoChangeListener cl);
81  	
82  	/**
83  	 * Causes {@code cl} to no longer receive future change notifications.
84  	 * @param cl The DaoChangeListener to unsubscribe
85  	 */
86  	public void unsubscribe(DaoChangeListener cl);
87  	
88  	/**
89  	 * Announces {@code change} to all subscribed observers.
90  	 * @param change The change to announce
91  	 */
92  	public void announce(Change change);
93  }