blob: 9b5ee1bdbcff1e158a8a6dd1b959275e9c471376 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
package net.java.sip.communicator.service.protocol;
import java.util.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*;
/**
* Represents a default implementation of
* {@link OperationSetServerStoredAccountInfo} in order to make it easier for
* implementers to provide complete solutions while focusing on
* implementation-specific details.
*
* @author Damian Minkov
*/
public abstract class AbstractOperationSetServerStoredAccountInfo
implements OperationSetServerStoredAccountInfo
{
/**
* The <tt>Logger</tt> used by the
* <tt>AbstractOperationSetPersistentPresence</tt> class and its instances
* for logging output.
*/
private static final Logger logger =
Logger.getLogger(AbstractOperationSetServerStoredAccountInfo.class);
/**
* A list of listeners registered for
* <tt>ServerStoredDetailsChangeListener</tt>s.
*/
private final List<ServerStoredDetailsChangeListener>
serverStoredDetailsListeners
= new ArrayList<ServerStoredDetailsChangeListener>();
/**
* Registers a ServerStoredDetailsChangeListener with this operation set so
* that it gets notifications of details change.
*
* @param listener the <tt>ServerStoredDetailsChangeListener</tt>
* to register.
*/
public void addServerStoredDetailsChangeListener(
ServerStoredDetailsChangeListener listener)
{
synchronized (serverStoredDetailsListeners)
{
if (!serverStoredDetailsListeners.contains(listener))
serverStoredDetailsListeners.add(listener);
}
}
/**
* Unregisters <tt>listener</tt> so that it won't receive any further
* notifications upon details change.
*
* @param listener the <tt>ServerStoredDetailsChangeListener</tt>
* to unregister.
*/
public void removeServerStoredDetailsChangeListener(
ServerStoredDetailsChangeListener listener)
{
synchronized (serverStoredDetailsListeners)
{
serverStoredDetailsListeners.remove(listener);
}
}
/**
* Notify all listeners of the corresponding account detail
* change event.
*
* @param source the protocol provider service source
* @param eventID the int ID of the event to dispatch
* @param oldValue the value that the changed property had before the change
* occurred.
* @param newValue the value that the changed property currently has (after
* the change has occurred).
*/
public void fireServerStoredDetailsChangeEvent(
ProtocolProviderService source,
int eventID, Object oldValue, Object newValue)
{
ServerStoredDetailsChangeEvent evt
= new ServerStoredDetailsChangeEvent(
source,
eventID,
oldValue,
newValue);
Collection<ServerStoredDetailsChangeListener> listeners;
synchronized (serverStoredDetailsListeners)
{
listeners = new ArrayList<ServerStoredDetailsChangeListener>(
serverStoredDetailsListeners);
}
if (logger.isDebugEnabled())
logger.debug("Dispatching a Contact Property Change Event to"
+ listeners.size() + " listeners. Evt=" + evt);
for (ServerStoredDetailsChangeListener listener : listeners)
listener.serverStoredDetailsChanged(evt);
}
}
|