KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > rcp > notification > ChangeManager


1 /*
2  * Created on Apr 15, 2005
3  */

4 package com.nightlabs.rcp.notification;
5
6 /**
7  * Use the shared instance of this manager to get notified
8  * about changes on JDO object or similar objects where
9  * you can't register a change listener directly.
10  * <p>
11  * For many objects which are obtained from the server, there exist
12  * multiple instances in the client. Often, these instances even are
13  * replaced with every change (because a new copy is loaded from the server).
14  * Hence, you can't use a property change support within these objects or
15  * similar mechanisms.
16  * <p>
17  * To handle JDO object changes with this manager works as follows:
18  * <ul>
19  * <li>
20  * Register a listener on the object-id-class of the JDO object that interests
21  * you.
22  * </li>
23  * <li>
24  * Whenever you manipulate a JDO object, notify the <tt>ChangeManager</tt>
25  * with the object-id-instance.
26  * </li>
27  * <li>
28  * In your listener, you check, whether you currently display the object which is
29  * referenced by the given ID. If so, reload it from the server.
30  * </li>
31  * </ul>
32  * When registering a listener, you can define, how the listener should be called
33  * (<tt>notificationMode</tt>): This means on which thread and whether to wait or not.
34  * In most cases, it makes sense to use a worker thread, because then you don't need to
35  * manually handle the reload-process asnychronously (and you shouldn't do it on the GUI
36  * thread, because it's expensive).
37  *
38  * @author Marco Schulze - marco at nightlabs dot de
39  */

40 public class ChangeManager extends NotificationManager
41 {
42     private static ChangeManager _sharedInstance = null;
43
44     public static ChangeManager sharedInstance()
45     {
46         if (_sharedInstance == null)
47             _sharedInstance = new ChangeManager();
48
49         return _sharedInstance;
50     }
51
52     protected ChangeManager()
53     {
54     }
55
56 }
57
Popular Tags