1 /* 2 * Copyright (c) 1997, 2009, Oracle and/or its affiliates. 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * 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} is the abstract root event class 35 * for all events emitted 36 * from, and pertaining to the semantics of, a {@code BeanContext}. 37 * This class introduces a mechanism to allow the propagation of 38 * {@code BeanContextEvent} subclasses through a hierarchy of 39 * {@code BeanContext}s. The {@code setPropagatedFrom()} 40 * and {@code getPropagatedFrom()} methods allow a 41 * {@code BeanContext} 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 private static final long serialVersionUID = 7267998073569045052L; 52 53 /** 54 * Contruct a BeanContextEvent 55 * 56 * @param bc The BeanContext source 57 */ 58 protected BeanContextEvent(BeanContext bc) { 59 super(bc); 60 } 61 62 /** 63 * Gets the {@code BeanContext} associated with this event. 64 * @return the {@code BeanContext} associated with this event. 65 */ 66 public BeanContext getBeanContext() { return (BeanContext)getSource(); } 67 68 /** 69 * Sets the {@code BeanContext} from which this event was propagated. 70 * @param bc the {@code BeanContext} from which this event 71 * was propagated 72 */ 73 public synchronized void setPropagatedFrom(BeanContext bc) { 74 propagatedFrom = bc; 75 } 76 77 /** 78 * Gets the {@code BeanContext} from which this event was propagated. 79 * @return the {@code BeanContext} from which this 80 * event was propagated 81 */ 82 public synchronized BeanContext getPropagatedFrom() { 83 return propagatedFrom; 84 } 85 86 /** 87 * Reports whether or not this event is 88 * propagated from some other {@code BeanContext}. 89 * @return {@code true} if propagated, {@code false} 90 * if not 91 */ 92 public synchronized boolean isPropagated() { 93 return propagatedFrom != null; 94 } 95 96 /* 97 * fields 98 */ 99 100 /** 101 * The {@code BeanContext} from which this event was propagated 102 */ 103 protected BeanContext propagatedFrom; 104 }