KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > beans > SynchronizedNestedBeanProperty


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.beans;
8
9
10 import java.util.ArrayList JavaDoc;
11 import java.util.Iterator JavaDoc;
12 import java.util.List JavaDoc;
13
14
15 /**
16  * This class is identical to its parent except that it
17  * is thread safe.
18  * @author Brian Pontarelli
19  */

20 public class SynchronizedNestedBeanProperty extends NestedBeanProperty {
21
22     /**
23      * Constructs a new instance of the thread safe NestedBeanProperty.
24      */

25     protected SynchronizedNestedBeanProperty() throws BeanException {
26         super();
27     }
28
29     /**
30      * Constructs a new instance of the thread safe NestedBeanProperty.
31      */

32     public SynchronizedNestedBeanProperty(String JavaDoc propertyName, Class JavaDoc beanClass)
33     throws BeanException {
34         super(propertyName, beanClass);
35     }
36
37     /**
38      * Constructs a new instance of the thread safe NestedBeanProperty.
39      */

40     public SynchronizedNestedBeanProperty(String JavaDoc propertyName, String JavaDoc beanClass)
41     throws BeanException {
42         super(propertyName, beanClass);
43     }
44
45     /**
46      * Constructs a new instance of the thread safe NestedBeanProperty.
47      */

48     public SynchronizedNestedBeanProperty(String JavaDoc propertyName, Class JavaDoc beanClass,
49             boolean strict) throws BeanException {
50         super(propertyName, beanClass, strict);
51     }
52
53
54     /**
55      * This method is the same as the {@link BaseBeanProperty#addPropertyListener(PropertyListener)
56      * addPropertyListener()} method in the {@link BaseBeanProperty BaseBeanProperty} class,
57      * except that it is thread safe.
58      */

59     public void addPropertyListener(PropertyListener listener) {
60         synchronized (super.propertyListeners) {
61             super.addPropertyListener(listener);
62         }
63     }
64
65     /**
66      * This method is the same as the {@link BaseBeanProperty#removePropertyListener(PropertyListener)
67      * removePropertyListener()} method in the {@link BaseBeanProperty BaseBeanProperty} class,
68      * except that it is thread safe.
69      */

70     public void removePropertyListener(PropertyListener listener) {
71         synchronized (super.propertyListeners) {
72             super.removePropertyListener(listener);
73         }
74     }
75
76     /**
77      * Synchronized get property listeners method. Since this must also safety the
78      * fireEvent method, this makes a clone of the list and returns the iterator for
79      * the clone
80      */

81     public Iterator JavaDoc getPropertyListeners() {
82         synchronized (super.propertyListeners) {
83             List JavaDoc newList = (List JavaDoc) ((ArrayList JavaDoc) super.propertyListeners).clone();
84             return newList.iterator();
85         }
86     }
87
88     /**
89      * This method is the same as the {@link BaseBeanProperty#hasPropertyListeners()
90      * hasPropertyListeners()} method in the {@link BaseBeanProperty BaseBeanProperty} class,
91      * except that it is thread safe.
92      */

93     public boolean hasPropertyListeners() {
94         synchronized (super.propertyListeners) {
95             return super.hasPropertyListeners();
96         }
97     }
98
99     /**
100      * This method is the same as the {@link BaseBeanProperty#addConversionListener(ConversionListener)
101      * addConversionListener()} method in the {@link BaseBeanProperty BaseBeanProperty} class,
102      * except that it is thread safe.
103      */

104     public void addConversionListener(ConversionListener listener) {
105         synchronized (super.conversionListeners) {
106             super.addConversionListener(listener);
107         }
108     }
109
110     /**
111      * This method is the same as the {@link BaseBeanProperty#removeConversionListener(ConversionListener)
112      * removeConversionListener()} method in the {@link BaseBeanProperty BaseBeanProperty} class,
113      * except that it is thread safe.
114      */

115     public void removeConversionListener(ConversionListener listener) {
116         synchronized (super.conversionListeners) {
117             super.removeConversionListener(listener);
118         }
119     }
120
121     /**
122      * Synchronized get conversion listeners method. Since this must also safety the
123      * fireEvent method, this makes a clone of the list and returns the iterator for
124      * the clone
125      */

126     public Iterator JavaDoc getConversionListeners() {
127         synchronized (super.conversionListeners) {
128             List JavaDoc newList = (List JavaDoc) ((ArrayList JavaDoc) super.conversionListeners).clone();
129             return newList.iterator();
130         }
131     }
132
133     /**
134      * This method is the same as the {@link BaseBeanProperty#hasConversionListeners()
135      * hasConversionListeners()} method in the {@link BaseBeanProperty BaseBeanProperty} class,
136      * except that it is thread safe.
137      */

138     public boolean hasConversionListeners() {
139         synchronized (super.conversionListeners) {
140             return super.hasConversionListeners();
141         }
142     }
143 }
144
Popular Tags