2
|
1 |
/*
|
|
2 |
* Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Sun in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
* have any questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package java.beans.beancontext;
|
|
27 |
|
|
28 |
import java.util.EventObject;
|
|
29 |
|
|
30 |
import java.beans.beancontext.BeanContext;
|
|
31 |
|
|
32 |
/**
|
|
33 |
* <p>
|
|
34 |
* <code>BeanContextEvent</code> is the abstract root event class
|
|
35 |
* for all events emitted
|
|
36 |
* from, and pertaining to the semantics of, a <code>BeanContext</code>.
|
|
37 |
* This class introduces a mechanism to allow the propagation of
|
|
38 |
* <code>BeanContextEvent</code> subclasses through a hierarchy of
|
|
39 |
* <code>BeanContext</code>s. The <code>setPropagatedFrom()</code>
|
|
40 |
* and <code>getPropagatedFrom()</code> methods allow a
|
|
41 |
* <code>BeanContext</code> to identify itself as the source
|
|
42 |
* of a propagated event.
|
|
43 |
* </p>
|
|
44 |
*
|
|
45 |
* @author Laurence P. G. Cable
|
|
46 |
* @since 1.2
|
|
47 |
* @see java.beans.beancontext.BeanContext
|
|
48 |
*/
|
|
49 |
|
|
50 |
public abstract class BeanContextEvent extends EventObject {
|
|
51 |
|
|
52 |
/**
|
|
53 |
* Contruct a BeanContextEvent
|
|
54 |
*
|
|
55 |
* @param bc The BeanContext source
|
|
56 |
*/
|
|
57 |
protected BeanContextEvent(BeanContext bc) {
|
|
58 |
super(bc);
|
|
59 |
}
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Gets the <code>BeanContext</code> associated with this event.
|
|
63 |
* @return the <code>BeanContext</code> associated with this event.
|
|
64 |
*/
|
|
65 |
public BeanContext getBeanContext() { return (BeanContext)getSource(); }
|
|
66 |
|
|
67 |
/**
|
|
68 |
* Sets the <code>BeanContext</code> from which this event was propagated.
|
|
69 |
* @param bc the <code>BeanContext</code> from which this event
|
|
70 |
* was propagated
|
|
71 |
*/
|
|
72 |
public synchronized void setPropagatedFrom(BeanContext bc) {
|
|
73 |
propagatedFrom = bc;
|
|
74 |
}
|
|
75 |
|
|
76 |
/**
|
|
77 |
* Gets the <code>BeanContext</code> from which this event was propagated.
|
|
78 |
* @return the <code>BeanContext</code> from which this
|
|
79 |
* event was propagated
|
|
80 |
*/
|
|
81 |
public synchronized BeanContext getPropagatedFrom() {
|
|
82 |
return propagatedFrom;
|
|
83 |
}
|
|
84 |
|
|
85 |
/**
|
|
86 |
* Reports whether or not this event is
|
|
87 |
* propagated from some other <code>BeanContext</code>.
|
|
88 |
* @return <code>true</code> if propagated, <code>false</code>
|
|
89 |
* if not
|
|
90 |
*/
|
|
91 |
public synchronized boolean isPropagated() {
|
|
92 |
return propagatedFrom != null;
|
|
93 |
}
|
|
94 |
|
|
95 |
/*
|
|
96 |
* fields
|
|
97 |
*/
|
|
98 |
|
|
99 |
/**
|
|
100 |
* The <code>BeanContext</code> from which this event was propagated
|
|
101 |
*/
|
|
102 |
protected BeanContext propagatedFrom;
|
|
103 |
}
|