KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hivemind > test > services > EventProducer


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package hivemind.test.services;
16
17 import java.beans.PropertyChangeEvent JavaDoc;
18 import java.beans.PropertyChangeListener JavaDoc;
19 import java.beans.PropertyChangeSupport JavaDoc;
20
21 /**
22  * Class used by {@link hivemind.test.services.TestEventLinker}.
23  *
24  * @author Howard M. Lewis Ship
25  */

26 public class EventProducer
27 {
28     private PropertyChangeSupport JavaDoc _support = new PropertyChangeSupport JavaDoc(this);
29     private int _count = 0;
30
31     public void addPropertyChangeListener(PropertyChangeListener JavaDoc listener)
32     {
33         _support.addPropertyChangeListener(listener);
34
35         _count++;
36     }
37
38     public void removePropertyChangeListener(PropertyChangeListener JavaDoc listener)
39     {
40         _support.removePropertyChangeListener(listener);
41
42         _count--;
43     }
44
45     public void fire(PropertyChangeEvent JavaDoc event)
46     {
47         _support.firePropertyChange(event);
48     }
49
50     public int getListenerCount()
51     {
52         return _count;
53     }
54
55     public String JavaDoc toString()
56     {
57         return "EventProducer";
58     }
59 }
60
Popular Tags