1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.log4j.rule;
19
20 import java.beans.PropertyChangeEvent;
21 import java.beans.PropertyChangeListener;
22 import java.beans.PropertyChangeSupport;
23 import java.io.Serializable;
24
25
26 /***
27 * An abstract Rule class that provides the PropertyChange support plumbing.
28 *
29 * @author Paul Smith (psmith@apache.org)
30 * @author Scott Deboy (sdeboy@apache.org)
31 */
32 public abstract class AbstractRule implements Rule, Serializable {
33 /***
34 * Serialization id.
35 */
36 static final long serialVersionUID = -2844288145563025172L;
37
38 /***
39 * PropertySupport instance.
40 */
41 private PropertyChangeSupport propertySupport =
42 new PropertyChangeSupport(this);
43
44 /***
45 * Add property change listener.
46 * @param l listener.
47 */
48 public void addPropertyChangeListener(final PropertyChangeListener l) {
49 propertySupport.addPropertyChangeListener(l);
50 }
51
52 /***
53 * Remove property change listener.
54 * @param l listener.
55 */
56 public void removePropertyChangeListener(final PropertyChangeListener l) {
57 propertySupport.removePropertyChangeListener(l);
58 }
59
60 /***
61 * Send property change notification to attached listeners.
62 * @param propertyName property name.
63 * @param oldVal old value.
64 * @param newVal new value.
65 */
66 protected void firePropertyChange(
67 final String propertyName,
68 final Object oldVal,
69 final Object newVal) {
70 propertySupport.firePropertyChange(propertyName, oldVal, newVal);
71 }
72
73 /***
74 * Send property change notification to attached listeners.
75 * @param evt property change event.
76 */
77 public void firePropertyChange(final PropertyChangeEvent evt) {
78 propertySupport.firePropertyChange(evt);
79 }
80 }