Path: blob/master/src/java.desktop/share/classes/java/beans/beancontext/BeanContextChild.java
41159 views
/*1* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.beans.beancontext;2627import java.beans.PropertyChangeListener;28import java.beans.VetoableChangeListener;29import java.beans.PropertyVetoException;3031import java.beans.beancontext.BeanContext;3233/**34* <p>35* JavaBeans wishing to be nested within, and obtain a reference to their36* execution environment, or context, as defined by the BeanContext37* sub-interface shall implement this interface.38* </p>39* <p>40* Conformant BeanContexts shall as a side effect of adding a BeanContextChild41* object shall pass a reference to itself via the setBeanContext() method of42* this interface.43* </p>44* <p>45* Note that a BeanContextChild may refuse a change in state by throwing46* PropertyVetoedException in response.47* </p>48* <p>49* In order for persistence mechanisms to function properly on BeanContextChild50* instances across a broad variety of scenarios, implementing classes of this51* interface are required to define as transient, any or all fields, or52* instance variables, that may contain, or represent, references to the53* nesting BeanContext instance or other resources obtained54* from the BeanContext via any unspecified mechanisms.55* </p>56*57* @author Laurence P. G. Cable58* @since 1.259*60* @see java.beans.beancontext.BeanContext61* @see java.beans.PropertyChangeEvent62* @see java.beans.PropertyChangeListener63* @see java.beans.PropertyVetoException64* @see java.beans.VetoableChangeListener65*/6667public interface BeanContextChild {6869/**70* <p>71* Objects that implement this interface,72* shall fire a java.beans.PropertyChangeEvent, with parameters:73*74* propertyName "beanContext", oldValue (the previous nesting75* {@code BeanContext} instance, or {@code null}),76* newValue (the current nesting77* {@code BeanContext} instance, or {@code null}).78* <p>79* A change in the value of the nesting BeanContext property of this80* BeanContextChild may be vetoed by throwing the appropriate exception.81* </p>82* @param bc The {@code BeanContext} with which83* to associate this {@code BeanContextChild}.84* @throws PropertyVetoException if the85* addition of the specified {@code BeanContext} is refused.86*/87void setBeanContext(BeanContext bc) throws PropertyVetoException;8889/**90* Gets the {@code BeanContext} associated91* with this {@code BeanContextChild}.92* @return the {@code BeanContext} associated93* with this {@code BeanContextChild}.94*/95BeanContext getBeanContext();9697/**98* Adds a {@code PropertyChangeListener}99* to this {@code BeanContextChild}100* in order to receive a {@code PropertyChangeEvent}101* whenever the specified property has changed.102* @param name the name of the property to listen on103* @param pcl the {@code PropertyChangeListener} to add104*/105void addPropertyChangeListener(String name, PropertyChangeListener pcl);106107/**108* Removes a {@code PropertyChangeListener} from this109* {@code BeanContextChild} so that it no longer110* receives {@code PropertyChangeEvents} when the111* specified property is changed.112*113* @param name the name of the property that was listened on114* @param pcl the {@code PropertyChangeListener} to remove115*/116void removePropertyChangeListener(String name, PropertyChangeListener pcl);117118/**119* Adds a {@code VetoableChangeListener} to120* this {@code BeanContextChild}121* to receive events whenever the specified property changes.122* @param name the name of the property to listen on123* @param vcl the {@code VetoableChangeListener} to add124*/125void addVetoableChangeListener(String name, VetoableChangeListener vcl);126127/**128* Removes a {@code VetoableChangeListener} from this129* {@code BeanContextChild} so that it no longer receives130* events when the specified property changes.131* @param name the name of the property that was listened on.132* @param vcl the {@code VetoableChangeListener} to remove.133*/134void removeVetoableChangeListener(String name, VetoableChangeListener vcl);135136}137138139