jdk/src/share/classes/java/beans/beancontext/BeanContextChildSupport.java
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 19213 c360667a0da2
child 23010 6dadb192ad81
permissions -rw-r--r--
8022746: List of spelling errors in API doc Reviewed-by: alexsch, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.beans.beancontext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.beans.PropertyChangeEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.beans.PropertyChangeListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.beans.PropertyChangeSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.beans.VetoableChangeListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.beans.VetoableChangeSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.beans.PropertyVetoException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * This is a general support class to provide support for implementing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * BeanContextChild protocol.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * This class may either be directly subclassed, or encapsulated and delegated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * to in order to implement this interface for a given component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * @author      Laurence P. G. Cable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * @since       1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * @see java.beans.beancontext.BeanContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * @see java.beans.beancontext.BeanContextServices
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * @see java.beans.beancontext.BeanContextChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
public class BeanContextChildSupport implements BeanContextChild, BeanContextServicesListener, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    static final long serialVersionUID = 6328947014421475877L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * construct a BeanContextChildSupport where this class has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * subclassed in order to implement the JavaBean component itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    public BeanContextChildSupport() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        beanContextChildPeer = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        pcSupport = new PropertyChangeSupport(beanContextChildPeer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        vcSupport = new VetoableChangeSupport(beanContextChildPeer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * construct a BeanContextChildSupport where the JavaBean component
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * itself implements BeanContextChild, and encapsulates this, delegating
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * that interface to this implementation
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
    81
     * @param bcc the underlying bean context child
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    public BeanContextChildSupport(BeanContextChild bcc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        beanContextChildPeer = (bcc != null) ? bcc : this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        pcSupport = new PropertyChangeSupport(beanContextChildPeer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        vcSupport = new VetoableChangeSupport(beanContextChildPeer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * Sets the <code>BeanContext</code> for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * this <code>BeanContextChildSupport</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @param bc the new value to be assigned to the <code>BeanContext</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * property
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
    98
     * @throws PropertyVetoException if the change is rejected
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public synchronized void setBeanContext(BeanContext bc) throws PropertyVetoException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        if (bc == beanContext) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        BeanContext oldValue = beanContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        BeanContext newValue = bc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        if (!rejectedSetBCOnce) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            if (rejectedSetBCOnce = !validatePendingSetBeanContext(bc)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                throw new PropertyVetoException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                    "setBeanContext() change rejected:",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                    new PropertyChangeEvent(beanContextChildPeer, "beanContext", oldValue, newValue)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                fireVetoableChange("beanContext",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                                   oldValue,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                                   newValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            } catch (PropertyVetoException pve) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                rejectedSetBCOnce = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                throw pve; // re-throw
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        if (beanContext != null) releaseBeanContextResources();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        beanContext       = newValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        rejectedSetBCOnce = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        firePropertyChange("beanContext",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                           oldValue,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                           newValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        if (beanContext != null) initializeBeanContextResources();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * Gets the nesting <code>BeanContext</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * for this <code>BeanContextChildSupport</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * @return the nesting <code>BeanContext</code> for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * this <code>BeanContextChildSupport</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    public synchronized BeanContext getBeanContext() { return beanContext; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * Add a PropertyChangeListener for a specific property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * The same listener object may be added more than once.  For each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * property,  the listener will be invoked the number of times it was added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * for that property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * If <code>name</code> or <code>pcl</code> is null, no exception is thrown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * and no action is taken.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @param name The name of the property to listen on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * @param pcl The <code>PropertyChangeListener</code> to be added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    public void addPropertyChangeListener(String name, PropertyChangeListener pcl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        pcSupport.addPropertyChangeListener(name, pcl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * Remove a PropertyChangeListener for a specific property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * If <code>pcl</code> was added more than once to the same event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * source for the specified property, it will be notified one less time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * after being removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * If <code>name</code> is null, no exception is thrown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * and no action is taken.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * If <code>pcl</code> is null, or was never added for the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * property, no exception is thrown and no action is taken.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * @param name The name of the property that was listened on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * @param pcl The PropertyChangeListener to be removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    public void removePropertyChangeListener(String name, PropertyChangeListener pcl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        pcSupport.removePropertyChangeListener(name, pcl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * Add a VetoableChangeListener for a specific property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * The same listener object may be added more than once.  For each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * property,  the listener will be invoked the number of times it was added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * for that property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * If <code>name</code> or <code>vcl</code> is null, no exception is thrown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * and no action is taken.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @param name The name of the property to listen on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @param vcl The <code>VetoableChangeListener</code> to be added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public void addVetoableChangeListener(String name, VetoableChangeListener vcl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        vcSupport.addVetoableChangeListener(name, vcl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * Removes a <code>VetoableChangeListener</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * If <code>pcl</code> was added more than once to the same event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * source for the specified property, it will be notified one less time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * after being removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * If <code>name</code> is null, no exception is thrown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * and no action is taken.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * If <code>vcl</code> is null, or was never added for the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * property, no exception is thrown and no action is taken.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * @param name The name of the property that was listened on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * @param vcl The <code>VetoableChangeListener</code> to be removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    public void removeVetoableChangeListener(String name, VetoableChangeListener vcl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        vcSupport.removeVetoableChangeListener(name, vcl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * A service provided by the nesting BeanContext has been revoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * Subclasses may override this method in order to implement their own
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * behaviors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * @param bcsre The <code>BeanContextServiceRevokedEvent</code> fired as a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * result of a service being revoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    public void serviceRevoked(BeanContextServiceRevokedEvent bcsre) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * A new service is available from the nesting BeanContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * Subclasses may override this method in order to implement their own
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * behaviors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * @param bcsae The BeanContextServiceAvailableEvent fired as a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * result of a service becoming available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    public void serviceAvailable(BeanContextServiceAvailableEvent bcsae) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * Gets the <tt>BeanContextChild</tt> associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * <tt>BeanContextChildSupport</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * @return the <tt>BeanContextChild</tt> peer of this class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    public BeanContextChild getBeanContextChildPeer() { return beanContextChildPeer; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * Reports whether or not this class is a delegate of another.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * @return true if this class is a delegate of another
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    public boolean isDelegated() { return !this.equals(beanContextChildPeer); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * Report a bound property update to any registered listeners. No event is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * fired if old and new are equal and non-null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * @param name The programmatic name of the property that was changed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * @param oldValue  The old value of the property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * @param newValue  The new value of the property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    public void firePropertyChange(String name, Object oldValue, Object newValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        pcSupport.firePropertyChange(name, oldValue, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * Report a vetoable property update to any registered listeners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * If anyone vetos the change, then fire a new event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * reverting everyone to the old value and then rethrow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * the PropertyVetoException. <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * No event is fired if old and new are equal and non-null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * @param name The programmatic name of the property that is about to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * change
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * @param oldValue The old value of the property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * @param newValue - The new value of the property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * @throws PropertyVetoException if the recipient wishes the property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * change to be rolled back.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    public void fireVetoableChange(String name, Object oldValue, Object newValue) throws PropertyVetoException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        vcSupport.fireVetoableChange(name, oldValue, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * Called from setBeanContext to validate (or otherwise) the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * pending change in the nesting BeanContext property value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * Returning false will cause setBeanContext to throw
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * PropertyVetoException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * @param newValue the new value that has been requested for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     *  the BeanContext property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * @return <code>true</code> if the change operation is to be vetoed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    public boolean validatePendingSetBeanContext(BeanContext newValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * This method may be overridden by subclasses to provide their own
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * release behaviors. When invoked any resources held by this instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * obtained from its current BeanContext property should be released
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * since the object is no longer nested within that BeanContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    protected  void releaseBeanContextResources() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        // do nothing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * This method may be overridden by subclasses to provide their own
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 19213
diff changeset
   305
     * initialization behaviors. When invoked any resources required by the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * BeanContextChild should be obtained from the current BeanContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    protected void initializeBeanContextResources() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        // do nothing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * Write the persistence state of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    private void writeObject(ObjectOutputStream oos) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        /*
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 19213
diff changeset
   320
         * don't serialize if we are delegated and the delegator is not also
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
         * serializable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        if (!equals(beanContextChildPeer) && !(beanContextChildPeer instanceof Serializable))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            throw new IOException("BeanContextChildSupport beanContextChildPeer not Serializable");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            oos.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * Restore a persistent object, must wait for subsequent setBeanContext()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * to fully restore any resources obtained from the new nesting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * BeanContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        ois.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * The <code>BeanContext</code> in which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * this <code>BeanContextChild</code> is nested.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    public    BeanContextChild      beanContextChildPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    * The <tt>PropertyChangeSupport</tt> associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    * <tt>BeanContextChildSupport</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    protected PropertyChangeSupport pcSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    * The <tt>VetoableChangeSupport</tt> associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    * <tt>BeanContextChildSupport</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    protected VetoableChangeSupport vcSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   365
    /**
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   366
     * The bean context.
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   367
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    protected transient BeanContext           beanContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    * A flag indicating that there has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    * at least one <code>PropertyChangeVetoException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    * thrown for the attempted setBeanContext operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    protected transient boolean               rejectedSetBCOnce;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
}