harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ellison <t.p.elli...@gmail.com>
Subject Re: svn commit: r388415 [2/3] - in /incubator/harmony/enhanced/classlib/trunk: modules/archive/src/test/java/tests/api/java/util/zip/ modules/beans/src/main/java/java/beans/beancontext/ modules/luni/src/test/java/tests/api/java/lang/ modules/luni/src/test/...
Date Fri, 24 Mar 2006 07:03:43 GMT
I assume that these large diffs are produced by an EOL difference
between the original and patched files...

Regards,
Tim

tellison@apache.org wrote:
> Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java
> URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java?rev=388415&r1=388414&r2=388415&view=diff
> ==============================================================================
> --- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java (original)
> +++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java Thu Mar 23 22:53:45 2006
> @@ -1,1336 +1,1336 @@
> -/*
> - *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
> - *
> - *  Licensed under the Apache License, Version 2.0 (the "License");
> - *  you may not use this file except in compliance with the License.
> - *  You may obtain a copy of the License at
> - *
> - *     http://www.apache.org/licenses/LICENSE-2.0
> - *
> - *  Unless required by applicable law or agreed to in writing, software
> - *  distributed under the License is distributed on an "AS IS" BASIS,
> - *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> - *  See the License for the specific language governing permissions and
> - *  limitations under the License.
> - */
> -
> -/**
> - * @author Sergei A. Krivenko
> - * @version $Revision: 1.17.2.3 $
> - */
> -package java.beans.beancontext;
> -
> -import java.beans.Beans;
> -import java.beans.PropertyChangeEvent;
> -import java.beans.PropertyChangeListener;
> -import java.beans.PropertyVetoException;
> -import java.beans.VetoableChangeListener;
> -import java.beans.Visibility;
> -
> -import java.io.IOException;
> -import java.io.InputStream;
> -import java.io.ObjectInputStream;
> -import java.io.ObjectOutputStream;
> -import java.io.Serializable;
> -
> -import java.net.URL;
> -
> -import java.util.ArrayList;
> -import java.util.Arrays;
> -import java.util.Collection;
> -import java.util.HashMap;
> -import java.util.Iterator;
> -import java.util.List;
> -import java.util.Locale;
> -import java.util.Set;
> -
> -/**
> - * @author Sergei A. Krivenko
> - * @version $Revision: 1.17.2.3 $
> - */
> -
> -public class BeanContextSupport extends BeanContextChildSupport 
> -        implements BeanContext, Serializable, PropertyChangeListener, 
> -        VetoableChangeListener {
> -    
> -    /**
> -     * Nested class
> -     */        
> -    protected class BCSChild implements Serializable {
> -        
> -        private static final long serialVersionUID = -5815286101609939109L;
> -        
> -        /**
> -         * @serial
> -         */
> -        private Object child;
> -        
> -        /**
> -         * @serial
> -         */
> -        private Object proxyPeer;
> -        
> -        /**
> -         * Construct an object not initially locked for editing 
> -         * with child and its peer
> -         *
> -         * @param child - a child
> -         * @param proxyPeer - a peer for this child
> -         */
> -        BCSChild(Object child, Object proxyPeer) {
> -            this.child = child;
> -            this.proxyPeer = proxyPeer;
> -        }
> -        
> -        /**
> -         * Return a child
> -         *
> -         * @return a child this object was created with
> -         */
> -        Object getChild() {
> -            return this.child;
> -        }
> -    }
> -    
> -    /**
> -     * Nested class
> -     */
> -    protected static final class BCSIterator implements Iterator {
> -        
> -        /**
> -         *
> -         */
> -        private Iterator it;
> -        
> -        /**
> -         * Construct an iterator
> -         *
> -         * @param set - a set to create iterator from
> -         */
> -        BCSIterator(HashMap map) {
> -            this.it = map.values().iterator();
> -        }
> -        
> -        /**
> -         *
> -         */
> -        public boolean hasNext() {            
> -            return it.hasNext();
> -        }
> -        
> -        /**
> -         *
> -         */
> -        public Object next() {
> -            return it.next();
> -        }
> -        
> -        /**
> -         *
> -         */
> -        public void remove() {
> -            it.remove();
> -        }
> -    }
> -
> -    /**
> -     *
> -     */
> -    private static final long serialVersionUID = -4879613978649577204L;
> -    
> -    /**
> -     * 
> -     */
> -    protected transient ArrayList bcmListeners;
> -
> -    /**
> -     * 
> -     */
> -    protected transient HashMap children;
> -
> -    /**
> -     * @serial
> -     */
> -    protected boolean designTime;   
> -
> -    /**
> -     * @serial
> -     */
> -    protected Locale locale;
> -
> -    /**
> -     * @serial
> -     */
> -    protected boolean okToUseGui;
> -    
> -    /**
> -     * @serial
> -     */
> -    private int serializable;
> -    
> -    /**
> -     * A flag to show if this BeanContext is in a process of serializing
> -     */
> -    private transient boolean serializing;
> -    
> -    /**
> -     * PropertyChangeListener of this BeanContext
> -     */
> -    private transient PropertyChangeListener pcl;
> -    
> -    /**
> -     * VetoableChangeListener of this BeanContext
> -     */
> -    private transient VetoableChangeListener vcl;
> -    
> -    /**
> -     * A flag to prevent the infinite roll backs 
> -     * while adding and removing children
> -     */
> -    private boolean rollingBack = false;;
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public BeanContextSupport() {
> -        this(null, null, false, true);
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public BeanContextSupport(BeanContext peer) {
> -        this(peer, null, false, true);
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public BeanContextSupport(BeanContext peer, Locale lcle) {
> -        this(peer, lcle, false, true);
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public BeanContextSupport(BeanContext peer, Locale lcle, boolean dtime) {
> -        this(peer, lcle, dtime, true);
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public BeanContextSupport(BeanContext peer, Locale lcle, boolean dtime, 
> -            boolean visible) {
> -                
> -        super(peer);
> -        
> -        // If locale is null, use default
> -        this.locale = (lcle == null ? Locale.getDefault() : lcle);
> -                       
> -        this.designTime = dtime;
> -        this.okToUseGui = visible;
> -        
> -        // Initialize some values necessary for this class to operate
> -        initialize();
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public boolean add(Object targetChild) {
> -        
> -        // We must synchronize on BeanContext.globalHierarchyLock
> -        synchronized(BeanContext.globalHierarchyLock) {
> -            
> -            // Validate some values and states to check if we can proceed
> -            if (!addChecks(targetChild)) {
> -                return false;
> -            }
> -            
> -            try {
> -                
> -                // If child is an instance of BeanContextChild or 
> -                // BeanContextProxy,
> -                // invoke setBeanContext() method on this child
> -                // and register BeanContext with its child
> -                // on PropertyChangeListener and VetoableChangeListener.
> -                BeanContextChild ch = getChildBeanContextChild(targetChild);
> -                
> -                if (ch != null) {                                     
> -                    ch.setBeanContext(getBeanContextPeer());
> -                    ch.addPropertyChangeListener(BEAN_CONTEXT, this.pcl);
> -                    ch.addVetoableChangeListener(BEAN_CONTEXT, this.vcl);
> -                }           
> -            } catch(PropertyVetoException e) {
> -                
> -                // Throw IllegalStateException, if PropertyVetoException occurs
> -                throw new IllegalStateException(
> -                    "PropertyVetoException was thrown while adding a child: " + 
> -                    targetChild + "; Original error message:" + e.getMessage());
> -            } 
> -            
> -            // If child implements Visibility, 
> -            // set an appropriate type of ability to render GUI
> -            Visibility vis = getChildVisibility(targetChild);
> -                
> -            if (vis != null) {
> -                if (this.okToUseGui) {
> -                    vis.okToUseGui();
> -                } else {
> -                    vis.dontUseGui();
> -                }
> -            }
> -            
> -            // Check if this child implements Serializable and increase 
> -            // the number of serializable children of the BeanContext
> -            if (getChildSerializable(targetChild) != null) {
> -                this.serializable++;
> -            }
> -            
> -            // Finally add child to the collection
> -            addChild(targetChild);
> -        }
> -        
> -        return true;
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public boolean addAll(Collection c) {
> -        
> -        Collection col = new ArrayList();
> -        
> -        // Add children one by one
> -        for (Iterator i = c.iterator(); i.hasNext(); ) {
> -            try {
> -                Object next = i.next();
> -                
> -                if (add(next)) {
> -                    col.add(next);
> -                }
> -            } catch(Exception e) {
> -                
> -                // Roll back changes but first check if it's already rolling 
> -                // back to avoid infinitive action
> -                if (!this.rollingBack) {
> -                    this.rollingBack = true;
> -                    removeAll(col);
> -                } else {
> -                    this.rollingBack = false;
> -                }
> -                
> -                return false;
> -            }
> -        }
> -        
> -        return true;
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public void addBeanContextMembershipListener(
> -            BeanContextMembershipListener bcml) {
> -                
> -        // BeanContextMembershipListener canj not be null
> -        if (bcml == null) {
> -            throw new NullPointerException("Membership listener is null");
> -        }
> -                
> -        synchronized (this.bcmListeners) {
> -            this.bcmListeners.add(bcml);    
> -        }
> -    }
> -    
> -    /**
> -     * Check if we can add this child to BeanContext
> -     *
> -     * @param targetChild - a child to check
> -     *
> -     * @return true if we may continue
> -     */
> -    private boolean addChecks(Object targetChild) {
> -        
> -        // Child can not be null
> -        if (targetChild == null) {
> -            throw new IllegalArgumentException("Target child can not be null");
> -        }
> -        
> -        // Each child should appear only once in a given BeanContext
> -        if (containsKey(targetChild)) {
> -            return false;
> -        }
> -        
> -        return validatePendingAdd(targetChild); 
> -    }
> -    
> -    /**
> -     * Add child to the collection
> -     *
> -     * @param targetChild - the child to be added to the BeanContext
> -     * @param fire - true if BeanContextMembershipEvent should be fired
> -     */
> -    private void addChild(Object targetChild) {
> -        
> -        // Add a new child using targetChild as a key and 
> -        // its BCSChild instance as an entry
> -        synchronized(this.children) {        
> -            BCSChild ch = createBCSChild(targetChild, getBeanContextPeer());
> -            this.children.put(targetChild, ch);                
> -            childJustAddedHook(targetChild, ch);
> -        }
> -        
> -        // Fire memebership event
> -        fireChildrenAdded(getBCME(new Object[] { targetChild }));
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public boolean avoidingGui() {
> -        
> -        // Avoiding GUI means that
> -        // GUI is needed but not allowed to use at this time
> -        return (needsGui() && !this.okToUseGui);
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected Iterator bcsChildren() {
> -        
> -        // Return Iterator containing children 
> -        // that are instances of BCSChild class
> -        synchronized(this.children) {
> -            return new BCSIterator(this.children);
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected void bcsPreDeserializationHook(ObjectInputStream ois) 
> -            throws IOException, ClassNotFoundException {
> -                
> -        // Leave it for subclasses to implement
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected void bcsPreSerializationHook(ObjectOutputStream oos) 
> -            throws IOException {
> -                
> -        // Leave it for subclasses to implement
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected void childDeserializedHook(Object child, 
> -            BeanContextSupport.BCSChild bcsc) {
> -                
> -        synchronized(this.children) {
> -            this.children.put(child, bcsc);
> -        }
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected void childJustAddedHook(Object child, 
> -            BeanContextSupport.BCSChild bcsc) {
> -        
> -        // Leave it for subclasses to implement
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected void childJustRemovedHook(Object child, 
> -            BeanContextSupport.BCSChild bcsc) {
> -        
> -        // Leave it for subclasses to implement
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected static final boolean classEquals(Class first, Class second) {
> -        
> -        // Either classes themselves or their names should be equal
> -        return (first.equals(second) ? 
> -                true : 
> -                    (first.getName().equals(second.getName()) ? 
> -                     true : 
> -                     false));
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public void clear() {
> -        throw new UnsupportedOperationException();
> -        
> -        /*
> -        synchronized(BeanContext.globalHierarchyLock) {        
> -            Collection col = new ArrayList();
> -            
> -            // Remove all children from BeanContext that are in the collection
> -            // one by one. This operation is successfull if all the
> -            // removals succeded
> -            for (Iterator i = iterator(); i.hasNext(); ) {
> -                try {  
> -                    Object next = i.next();
> -                    
> -                    if (remove(next)) {
> -                        col.add(next);
> -                    }
> -                } catch(Exception e) {
> -                    
> -                    // Roll back changes
> -                    this.rollingBack = true;
> -                    addAll(col);
> -                    return;
> -                }
> -            }
> -        }*/
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public boolean contains(Object o) {      
> -                
> -        // See if a given object can be found among 
> -        // the children's collection values
> -        synchronized(BeanContext.globalHierarchyLock) {
> -            synchronized (this.children) {            
> -                return this.children.containsKey(o);
> -            }
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public boolean containsAll(Collection c) {
> -        
> -        // Iterate through the collection provided and find matches 
> -        // in the current BeanContext. If not found return false.
> -        for (Iterator i = c.iterator(); i.hasNext();) {
> -            Object next = i.next();
> -            
> -            if (!contains(next)) {
> -                return false;
> -            }
> -        }
> -        
> -        // If we are here, all the elements of the collection are presented
> -        // in this BeanContext
> -        return true;
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public boolean containsKey(Object o) {
> -        
> -        // See if a given object can be found among 
> -        // the children's collection keys
> -        synchronized(BeanContext.globalHierarchyLock) {
> -            synchronized (this.children) {
> -                return this.children.containsKey(o);
> -            }
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected final Object[] copyChildren() {
> -        
> -        // Make a copy of all children
> -        synchronized (this.children) {    
> -            return this.children.entrySet().toArray();
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected BCSChild createBCSChild(Object targetChild, Object peer) {
> -        
> -        // Create a child object with a reference to its peer
> -        return new BCSChild(targetChild, peer);
> -    }
> -   
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected final void deserialize(ObjectInputStream ois, Collection coll) 
> -            throws IOException, ClassNotFoundException {
> -        
> -        // Read objects from output stream until "EOS" (the end of stream)
> -        // mark is found. Place all the objects into collection provided
> -        while (true) {
> -            Object l = ois.readObject();
> -            
> -            if (l != null && l.equals("EOS")) {
> -                coll.add(l);
> -            } else {
> -                break;
> -            }
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public synchronized void dontUseGui() {
> -        
> -        // Command this BeanContext and its children not to use GUI
> -        this.okToUseGui = false;
> -        
> -        for (Iterator it = iterator(); it.hasNext(); ) {
> -            Object next = it.next();            
> -            Visibility vis = getChildVisibility(next);
> -            
> -            if (vis != null) {
> -                vis.dontUseGui();
> -            }
> -        }
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected final void fireChildrenAdded(BeanContextMembershipEvent bcme) {
> -        
> -        // Notify all registered listenes about the change made
> -        for (Iterator i = bcmListeners.iterator(); i.hasNext(); ) {
> -            BeanContextMembershipListener cur =
> -                (BeanContextMembershipListener) i.next();
> -                
> -            cur.childrenAdded(bcme);
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected final void fireChildrenRemoved(BeanContextMembershipEvent bcme) {
> -        
> -        // Notify all registered listenes about the change made
> -        for (Iterator i = bcmListeners.iterator(); i.hasNext(); ) {
> -            BeanContextMembershipListener cur =
> -                (BeanContextMembershipListener) i.next();
> -                
> -            cur.childrenRemoved(bcme);
> -        }
> -    }
> -    
> -    /**
> -     * Get BeanContextMembershipEvent class instance
> -     *
> -     * @param changes - an array of changes that has been made
> -     *
> -     * @return BeanContextMembershipEvent object
> -     */
> -    private BeanContextMembershipEvent getBCME(Object[] changes) {
> -        return new BeanContextMembershipEvent(getBeanContextPeer(), changes);
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public BeanContext getBeanContextPeer() {
> -        return (BeanContext) getBeanContextChildPeer();
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected static final BeanContextChild getChildBeanContextChild(
> -            Object child) {
> -                
> -        // There's nothing to do here if the child is null
> -        if (child == null) {
> -            return null;
> -        }
> -        
> -        // See if the child implements BeanContextChild or BeanContextProxy. 
> -        // Cast it to appropriate class or simply return null
> -        if (child instanceof BeanContextChild) {
> -            return (BeanContextChild) child;
> -        } else if (child instanceof BeanContextProxy) {
> -            return ((BeanContextProxy) child).getBeanContextProxy();
> -        } else {
> -            return null;
> -        }
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected static final BeanContextMembershipListener 
> -            getChildBeanContextMembershipListener(Object child) {
> -                
> -        // See if child implements BeanContextMembershipListener. 
> -        // Cast it to BeanContextMembershipListener if it does 
> -        // or return null otherwise
> -        if ((child != null) && child instanceof BeanContextMembershipListener) {
> -            return (BeanContextMembershipListener) child;
> -        } else {
> -            return null;
> -        }
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected static final PropertyChangeListener 
> -            getChildPropertyChangeListener(Object child) {
> -                
> -        // See if child implements PropertyChangeListener. 
> -        // Cast it to PropertyChangeListener if it does
> -        // or return null otherwise
> -        if ((child != null) && child instanceof PropertyChangeListener) {
> -            return (PropertyChangeListener) child;
> -        } else {
> -            return null;
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected static final Serializable getChildSerializable(Object child) {
> -        
> -        // See if child implements Serializable. 
> -        // Cast it to Serializable if it does
> -        // or return null otherwise
> -        if ((child != null) && child instanceof Serializable) {
> -            return (Serializable) child;
> -        } else {
> -            return null;
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected static final VetoableChangeListener 
> -            getChildVetoableChangeListener(Object child) {
> -                
> -        // See if child implements VetoableChangeListener. 
> -        // Cast it to VetoableChangeListener if it does
> -        // or return null otherwise
> -        if ((child != null) && child instanceof VetoableChangeListener) {
> -            return (VetoableChangeListener) child;
> -        } else {
> -            return null;
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected static final Visibility getChildVisibility(Object child) {
> -        
> -        // See if child implements Visibility. 
> -        // Cast it to Visibility if it does
> -        // or return null otherwise
> -        if ((child != null) && child instanceof Visibility) {
> -            return (Visibility) child;
> -        } else {
> -            return null;
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public synchronized Locale getLocale() {
> -        return this.locale;
> -    }
> -    
> -    /**
> -     * Construct PropertyChangeEvent object and return
> -     *
> -     * @param prop - property name
> -     * @param o - the old value
> -     * @param n - the new value
> -     * 
> -     * @return PropertyChangeEvent object
> -     */
> -    private PropertyChangeEvent getPCE(String prop, Object o, Object n) {
> -        return new PropertyChangeEvent(getBeanContextPeer(), prop, o, n);
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public URL getResource(String name, BeanContextChild bcc) {
> -        
> -        // The resource name should not be null
> -        if(name == null) {
> -            throw new IllegalArgumentException("Resource name can not be null");
> -        }
> -        
> -        // Load resource using the same ClassLoader as BeanContextChild specified
> -        // If NullPointerException occurs try to load it as system resource
> -        try {
> -            return bcc.getClass().getClassLoader().getResource(name);
> -        } catch(NullPointerException e) {
> -            try {
> -                return ClassLoader.getSystemResource(name);
> -            } catch(Exception ex) {
> -                
> -                // We tried our best but still failed
> -                throw new IllegalArgumentException("Invalid resource");
> -            }
> -        }
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public InputStream getResourceAsStream(String name, BeanContextChild bcc) {
> -        
> -        // The resource name should not be null
> -        if(name == null) {
> -            throw new IllegalArgumentException("Resource name can not be null");
> -        }
> -        
> -        // Load resource using the same ClassLoader as BeanContextChild specified
> -        // If NullPointerException occurs try to load it as system resource
> -        try {
> -            return bcc.getClass().getClassLoader().getResourceAsStream(name);
> -        } catch(NullPointerException e) {
> -            try {
> -                return ClassLoader.getSystemResourceAsStream(name);
> -            } catch(Exception ex) {
> -                
> -                // No success at all
> -                throw new IllegalArgumentException("Invalid resource");
> -            }
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected synchronized void initialize() {
> -        
> -        // Initialize some fields
> -        this.children = new HashMap();
> -        this.bcmListeners = new ArrayList();
> -        
> -        this.serializable = 0;
> -        this.serializing = false;
> -        
> -        // Initialize PropertyChangeListener
> -        this.pcl = new PropertyChangeListener() {
> -            
> -            public void propertyChange(PropertyChangeEvent pce) {
> -                BeanContextSupport.this.propertyChange(pce);
> -            }
> -        };
> -        
> -        // Initialize VetoableChangeListener
> -        this.vcl = new VetoableChangeListener() {
> -            
> -            public void vetoableChange(PropertyChangeEvent pce) 
> -                    throws PropertyVetoException {
> -                       
> -                BeanContextSupport.this.vetoableChange(pce);
> -            }
> -        };
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public Object instantiateChild(String beanName) 
> -            throws IOException, ClassNotFoundException {
> -                
> -        // Use Beans convenience method to instantiate the bean
> -        return Beans.instantiate(getBeanContextPeer().getClass().getClassLoader(), 
> -                                 beanName, 
> -                                 getBeanContextPeer());
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public synchronized boolean isDesignTime() {
> -        return this.designTime;
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public boolean isEmpty() {
> -        
> -        // See if there are any children in this BeanContext
> -        synchronized(BeanContext.globalHierarchyLock) {
> -            synchronized(this.children) {
> -                return this.children.isEmpty();
> -            }
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public boolean isSerializing() {
> -        return this.serializing;
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public Iterator iterator() {
> -        
> -        synchronized(BeanContext.globalHierarchyLock) {
> -            synchronized(this.children) {
> -                return this.children.keySet().iterator();
> -            }
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public synchronized boolean needsGui() {
> -        
> -        // BeanContext needs GUI if at least one its children needs it.
> -        // We may check it by trying to cast each child to Visibility
> -        // and see it needs GUI.
> -        // A child definitely needs GUI if it implements Component
> -        for (Iterator it = iterator(); it.hasNext(); ) {
> -            Object next = it.next();            
> -            Visibility vis = getChildVisibility(next);
> -            
> -            if (vis != null) {
> -                if (vis.needsGui()) {
> -                    return true;
> -                }
> -            } 
> -            
> -            if (next instanceof java.awt.Component) {
> -                return true;
> -            }
> -        }
> -        
> -        return false;
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public synchronized void okToUseGui() {
> -        
> -        // Notify this BeanContext and its children that it's OK now to use GUI
> -        this.okToUseGui = true;
> -        
> -        for (Iterator it = iterator(); it.hasNext(); ) {
> -            Object next = it.next();            
> -            Visibility vis = getChildVisibility(next);
> -            
> -            if (vis != null) {
> -                vis.okToUseGui();
> -            }
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public void propertyChange(PropertyChangeEvent pce) {
> -        
> -        if (!pce.getPropertyName().equals(BEAN_CONTEXT)) {
> -            return;
> -        }
> -        
> -        Object source = pce.getSource();
> -        
> -        if (source instanceof BCSChild) {
> -            BCSChild ch = (BCSChild) source;
> -            Object newValue = pce.getNewValue();            
> -            
> -            if (!newValue.equals(this.getBeanContextPeer())) {
> -                remove(ch.getChild(), false);
> -            }
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public final void readChildren(ObjectInputStream ois) 
> -            throws IOException, ClassNotFoundException {
> -        
> -        // Deserialize children
> -        for (int i = 0; i < this.serializable; i++) {  
> -            BCSChild bChild = (BCSChild) ois.readObject();
> -            childDeserializedHook(bChild.getChild(), bChild);
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    private void readObject(ObjectInputStream ois) 
> -            throws IOException, ClassNotFoundException {
> -                
> -        synchronized(BeanContext.globalHierarchyLock) {           
> -            ois.defaultReadObject();             
> -            initialize();             
> -            bcsPreDeserializationHook(ois);
> -            
> -            // Deserialize children
> -            if (!getBeanContextPeer().equals(this)) {
> -                readChildren(ois);
> -            }
> -            
> -            // Deserialize listeners
> -            synchronized(this.bcmListeners) {
> -                deserialize(ois, this.bcmListeners);
> -            } 
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public boolean remove(Object targetChild) {
> -        return remove(targetChild, true);
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected boolean remove(Object targetChild, boolean callChildSetBC) {
> -        
> -        synchronized(BeanContext.globalHierarchyLock) {
> -            
> -            // Make necessary checks
> -            if (!validatePendingRemove(targetChild)) {
> -                return false;
> -            }
> -            
> -            Object removed = null;
> -            
> -            if (containsKey(targetChild)) {      
> -                
> -                // Remove the reference to the BeanContext from the child 
> -                // if ordered to do so
> -                if (callChildSetBC) {
> -                    removeFromContext(targetChild);
> -                }
> -                
> -                synchronized(this.children) {
> -                    
> -                    // Just before removing save a reference to it for later use
> -                    // in childJustRemovedHook() method
> -                    BCSChild ch = (BCSChild) this.children.get(targetChild);
> -                    removed = this.children.remove(targetChild);
> -                    childJustRemovedHook(targetChild, ch);
> -                }
> -                
> -                // Fire the event
> -                fireChildrenRemoved(getBCME(new Object[] { targetChild }));
> -                
> -                // Check if this child implements Serializable and decrease 
> -                // the number of serializable children of BeanContext
> -                if (getChildSerializable(targetChild) != null) {
> -                    this.serializable--;
> -                }
> -            }
> -            
> -            return (removed != null);
> -        }
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public boolean removeAll(Collection c) {
> -        throw new UnsupportedOperationException();
> -        /*
> -        synchronized(BeanContext.globalHierarchyLock) {        
> -            Collection col = new ArrayList();
> -            
> -            // Remove all children from BeanContext that are in the collection
> -            // one by one. This operation is successfull if all the
> -            // removals succeded
> -            for (Iterator i = c.iterator(); i.hasNext(); ) {
> -                try {
> -                    Object next = i.next();
> -                    
> -                    if (remove(next)) {
> -                        col.add(next);
> -                    }
> -                } catch(Exception e) {
> -                    
> -                    // Roll back changes but first check if it's already rolling 
> -                    // back to avoid infinitive action
> -                    if (!this.rollingBack) {
> -                        this.rollingBack = true;
> -                        addAll(col);
> -                    } else {
> -                        this.rollingBack = false;
> -                    }
> -                    
> -                    return false;
> -                }
> -            }
> -        }
> -        
> -        return true;*/
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public void removeBeanContextMembershipListener(
> -            BeanContextMembershipListener bcml) {
> -                
> -        // BeanContextMembershipListener can not be null
> -        if (bcml == null) {
> -            throw new NullPointerException("Membership listener is null");
> -        }
> -        
> -        synchronized(this.bcmListeners) {
> -            this.bcmListeners.remove(bcml);
> -        }
> -    }
> -    
> -    /**
> -     * Separate BeanContext and its child that had just been removed
> -     * by removing all references to each other
> -     *
> -     * @param targetChild - a BeanContext child that was removed
> -     */
> -    private void removeFromContext(Object targetChild) {
> -        try {
> -                        
> -            // If child is an instance of BeanContextChild or BeanContextProxy,
> -            // invoke setBeanContext() method on this child
> -            // with null parameter
> -            BeanContextChild ch = getChildBeanContextChild(targetChild);
> -                
> -            if (ch != null) {                                     
> -                ch.setBeanContext(null);               
> -                ch.removePropertyChangeListener(BEAN_CONTEXT, this.pcl);
> -                ch.removeVetoableChangeListener(BEAN_CONTEXT, this.vcl);
> -            }   
> -        } catch(PropertyVetoException e) {
> -            
> -            // Required by spec
> -            throw new IllegalStateException(
> -                "PropertyVetoException was thrown while removing " +
> -                " a child: " + targetChild + "; " +
> -                "Original error message:" + e.getMessage());
> -        }
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public boolean retainAll(Collection c) {
> -        throw new UnsupportedOperationException();
> -        
> -        /*
> -        synchronized(BeanContext.globalHierarchyLock) {
> -            synchronized(this.children) {
> -                
> -                Collection col = new ArrayList();
> -                
> -                // Remove all children from BeanContext that are not in the 
> -                // collection
> -                // This operation is successfull if all the removals succeded
> -                for (Iterator i = iterator(); i.hasNext(); ) {   
> -                    Object nextKey = i.next();
> -                    Object nextValue = this.children.get(nextKey);
> -                    
> -                    if (!c.contains(nextKey) && !c.contains(nextValue)) {
> -                        try {                            
> -                            if (remove(nextKey)) {
> -                                col.add(nextKey);
> -                            }
> -                        } catch(Exception e) {
> -                            
> -                            // Roll back changes
> -                            this.rollingBack = true;
> -                            addAll(col);
> -                            return false;
> -                        }
> -                    }
> -                }
> -            }
> -        }
> -        
> -        return true;*/
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected final void serialize(ObjectOutputStream oos, Collection coll) 
> -            throws IOException {
> -        
> -        // Write the collection into ObjectOutputStream
> -        for (Iterator it = coll.iterator(); it.hasNext(); ) {
> -            Object l = it.next();
> -            
> -            if (this.getChildSerializable(l) != null) {
> -                oos.writeObject(l);
> -            }
> -        }
> -        
> -        // Mark the end of stream
> -        oos.writeObject("EOS");
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public synchronized void setDesignTime(boolean dTime) {
> -        
> -        boolean old = this.designTime;
> -        this.designTime = dTime;
> -        
> -        // Notify BeanContext about this change
> -        firePropertyChange("designTime", new Boolean(old), new Boolean(dTime));
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public synchronized void setLocale(Locale newLocale) 
> -            throws PropertyVetoException {
> -        
> -        // Use default locale if a new value is null        
> -        newLocale = (newLocale == null ? Locale.getDefault() : newLocale);   
> -        
> -        // Notify BeanContext about this change
> -        Locale old = (Locale) this.locale.clone();
> -        this.locale = newLocale;
> -        firePropertyChange("locale", old, newLocale);
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public int size() {
> -        
> -        // Return the number of children of this BeanContext
> -        synchronized(BeanContext.globalHierarchyLock) {
> -            synchronized(this.children) {
> -                return this.children.size();
> -            }
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public Object[] toArray() {
> -        
> -        // Convert the collection of children to array
> -        synchronized(BeanContext.globalHierarchyLock) {
> -            synchronized(this.children) {
> -                return this.children.keySet().toArray();
> -            }
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public Object[] toArray(Object[] arry) {
> -        
> -        // Convert the collection of children to array
> -        synchronized(BeanContext.globalHierarchyLock) {
> -            synchronized(this.children) {
> -                return this.children.keySet().toArray(arry);
> -            }
> -        }
> -    }
> -
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected boolean validatePendingAdd(Object targetChild) {
> -        
> -        
> -        return true;
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    protected boolean validatePendingRemove(Object targetChild) {
> -        
> -        if (targetChild == null) {
> -            throw new IllegalArgumentException("Target child is null");
> -        }
> -        
> -        return true;
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public void vetoableChange(PropertyChangeEvent pce) 
> -            throws PropertyVetoException {
> -                
> -        
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    public final void writeChildren(ObjectOutputStream oos) throws IOException {
> -        
> -        // Write serializable children to ObjectOutputStream
> -        synchronized(this.children) {
> -            for (Iterator it = iterator(); it.hasNext(); ) {
> -                Object next = it.next();
> -                
> -                if (getChildSerializable(next) != null) {
> -                    oos.writeObject(this.children.get(next));
> -                }
> -            }
> -        }
> -    }
> -    
> -    /**
> -     * @com.intel.drl.spec_ref
> -     */
> -    private void writeObject(ObjectOutputStream oos)
> -            throws IOException, ClassNotFoundException {
> -                  
> -        synchronized(BeanContext.globalHierarchyLock) {
> -            this.serializing = true;            
> -            oos.defaultWriteObject();     
> -            
> -            bcsPreSerializationHook(oos);          
> -            
> -            if (!this.getBeanContextPeer().equals(this)) {
> -                writeChildren(oos);            
> -            }
> -            
> -            synchronized(this.bcmListeners) {
> -                serialize(oos, this.bcmListeners);
> -            }
> -            
> -            this.serializing = false;
> -        }
> -    }                         
> -}
> +/*
> + *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
> + *
> + *  Licensed under the Apache License, Version 2.0 (the "License");
> + *  you may not use this file except in compliance with the License.
> + *  You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + *  Unless required by applicable law or agreed to in writing, software
> + *  distributed under the License is distributed on an "AS IS" BASIS,
> + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + *  See the License for the specific language governing permissions and
> + *  limitations under the License.
> + */
> +
> +/**
> + * @author Sergei A. Krivenko
> + * @version $Revision: 1.17.2.3 $
> + */
> +package java.beans.beancontext;
> +
> +import java.beans.Beans;
> +import java.beans.PropertyChangeEvent;
> +import java.beans.PropertyChangeListener;
> +import java.beans.PropertyVetoException;
> +import java.beans.VetoableChangeListener;
> +import java.beans.Visibility;
> +
> +import java.io.IOException;
> +import java.io.InputStream;
> +import java.io.ObjectInputStream;
> +import java.io.ObjectOutputStream;
> +import java.io.Serializable;
> +
> +import java.net.URL;
> +
> +import java.util.ArrayList;
> +import java.util.Arrays;
> +import java.util.Collection;
> +import java.util.HashMap;
> +import java.util.Iterator;
> +import java.util.List;
> +import java.util.Locale;
> +import java.util.Set;
> +
> +/**
> + * @author Sergei A. Krivenko
> + * @version $Revision: 1.17.2.3 $
> + */
> +
> +public class BeanContextSupport extends BeanContextChildSupport 
> +        implements BeanContext, Serializable, PropertyChangeListener, 
> +        VetoableChangeListener {
> +    
> +    /**
> +     * Nested class
> +     */        
> +    protected class BCSChild implements Serializable {
> +        
> +        private static final long serialVersionUID = -5815286101609939109L;
> +        
> +        /**
> +         * @serial
> +         */
> +        private Object child;
> +        
> +        /**
> +         * @serial
> +         */
> +        private Object proxyPeer;
> +        
> +        /**
> +         * Construct an object not initially locked for editing 
> +         * with child and its peer
> +         *
> +         * @param child - a child
> +         * @param proxyPeer - a peer for this child
> +         */
> +        BCSChild(Object child, Object proxyPeer) {
> +            this.child = child;
> +            this.proxyPeer = proxyPeer;
> +        }
> +        
> +        /**
> +         * Return a child
> +         *
> +         * @return a child this object was created with
> +         */
> +        Object getChild() {
> +            return this.child;
> +        }
> +    }
> +    
> +    /**
> +     * Nested class
> +     */
> +    protected static final class BCSIterator implements Iterator {
> +        
> +        /**
> +         *
> +         */
> +        private Iterator it;
> +        
> +        /**
> +         * Construct an iterator
> +         *
> +         * @param set - a set to create iterator from
> +         */
> +        BCSIterator(HashMap map) {
> +            this.it = map.values().iterator();
> +        }
> +        
> +        /**
> +         *
> +         */
> +        public boolean hasNext() {            
> +            return it.hasNext();
> +        }
> +        
> +        /**
> +         *
> +         */
> +        public Object next() {
> +            return it.next();
> +        }
> +        
> +        /**
> +         *
> +         */
> +        public void remove() {
> +            it.remove();
> +        }
> +    }
> +
> +    /**
> +     *
> +     */
> +    private static final long serialVersionUID = -4879613978649577204L;
> +    
> +    /**
> +     * 
> +     */
> +    protected transient ArrayList bcmListeners;
> +
> +    /**
> +     * 
> +     */
> +    protected transient HashMap children;
> +
> +    /**
> +     * @serial
> +     */
> +    protected boolean designTime;   
> +
> +    /**
> +     * @serial
> +     */
> +    protected Locale locale;
> +
> +    /**
> +     * @serial
> +     */
> +    protected boolean okToUseGui;
> +    
> +    /**
> +     * @serial
> +     */
> +    private int serializable;
> +    
> +    /**
> +     * A flag to show if this BeanContext is in a process of serializing
> +     */
> +    private transient boolean serializing;
> +    
> +    /**
> +     * PropertyChangeListener of this BeanContext
> +     */
> +    private transient PropertyChangeListener pcl;
> +    
> +    /**
> +     * VetoableChangeListener of this BeanContext
> +     */
> +    private transient VetoableChangeListener vcl;
> +    
> +    /**
> +     * A flag to prevent the infinite roll backs 
> +     * while adding and removing children
> +     */
> +    private boolean rollingBack = false;;
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public BeanContextSupport() {
> +        this(null, null, false, true);
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public BeanContextSupport(BeanContext peer) {
> +        this(peer, null, false, true);
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public BeanContextSupport(BeanContext peer, Locale lcle) {
> +        this(peer, lcle, false, true);
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public BeanContextSupport(BeanContext peer, Locale lcle, boolean dtime) {
> +        this(peer, lcle, dtime, true);
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public BeanContextSupport(BeanContext peer, Locale lcle, boolean dtime, 
> +            boolean visible) {
> +                
> +        super(peer);
> +        
> +        // If locale is null, use default
> +        this.locale = (lcle == null ? Locale.getDefault() : lcle);
> +                       
> +        this.designTime = dtime;
> +        this.okToUseGui = visible;
> +        
> +        // Initialize some values necessary for this class to operate
> +        initialize();
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public boolean add(Object targetChild) {
> +        
> +        // We must synchronize on BeanContext.globalHierarchyLock
> +        synchronized(BeanContext.globalHierarchyLock) {
> +            
> +            // Validate some values and states to check if we can proceed
> +            if (!addChecks(targetChild)) {
> +                return false;
> +            }
> +            
> +            try {
> +                
> +                // If child is an instance of BeanContextChild or 
> +                // BeanContextProxy,
> +                // invoke setBeanContext() method on this child
> +                // and register BeanContext with its child
> +                // on PropertyChangeListener and VetoableChangeListener.
> +                BeanContextChild ch = getChildBeanContextChild(targetChild);
> +                
> +                if (ch != null) {                                     
> +                    ch.setBeanContext(getBeanContextPeer());
> +                    ch.addPropertyChangeListener(BEAN_CONTEXT, this.pcl);
> +                    ch.addVetoableChangeListener(BEAN_CONTEXT, this.vcl);
> +                }           
> +            } catch(PropertyVetoException e) {
> +                
> +                // Throw IllegalStateException, if PropertyVetoException occurs
> +                throw new IllegalStateException(
> +                    "PropertyVetoException was thrown while adding a child: " + 
> +                    targetChild + "; Original error message:" + e.getMessage());
> +            } 
> +            
> +            // If child implements Visibility, 
> +            // set an appropriate type of ability to render GUI
> +            Visibility vis = getChildVisibility(targetChild);
> +                
> +            if (vis != null) {
> +                if (this.okToUseGui) {
> +                    vis.okToUseGui();
> +                } else {
> +                    vis.dontUseGui();
> +                }
> +            }
> +            
> +            // Check if this child implements Serializable and increase 
> +            // the number of serializable children of the BeanContext
> +            if (getChildSerializable(targetChild) != null) {
> +                this.serializable++;
> +            }
> +            
> +            // Finally add child to the collection
> +            addChild(targetChild);
> +        }
> +        
> +        return true;
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public boolean addAll(Collection c) {
> +        
> +        Collection col = new ArrayList();
> +        
> +        // Add children one by one
> +        for (Iterator i = c.iterator(); i.hasNext(); ) {
> +            try {
> +                Object next = i.next();
> +                
> +                if (add(next)) {
> +                    col.add(next);
> +                }
> +            } catch(Exception e) {
> +                
> +                // Roll back changes but first check if it's already rolling 
> +                // back to avoid infinitive action
> +                if (!this.rollingBack) {
> +                    this.rollingBack = true;
> +                    removeAll(col);
> +                } else {
> +                    this.rollingBack = false;
> +                }
> +                
> +                return false;
> +            }
> +        }
> +        
> +        return true;
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public void addBeanContextMembershipListener(
> +            BeanContextMembershipListener bcml) {
> +                
> +        // BeanContextMembershipListener canj not be null
> +        if (bcml == null) {
> +            throw new NullPointerException("Membership listener is null");
> +        }
> +                
> +        synchronized (this.bcmListeners) {
> +            this.bcmListeners.add(bcml);    
> +        }
> +    }
> +    
> +    /**
> +     * Check if we can add this child to BeanContext
> +     *
> +     * @param targetChild - a child to check
> +     *
> +     * @return true if we may continue
> +     */
> +    private boolean addChecks(Object targetChild) {
> +        
> +        // Child can not be null
> +        if (targetChild == null) {
> +            throw new IllegalArgumentException("Target child can not be null");
> +        }
> +        
> +        // Each child should appear only once in a given BeanContext
> +        if (containsKey(targetChild)) {
> +            return false;
> +        }
> +        
> +        return validatePendingAdd(targetChild); 
> +    }
> +    
> +    /**
> +     * Add child to the collection
> +     *
> +     * @param targetChild - the child to be added to the BeanContext
> +     * @param fire - true if BeanContextMembershipEvent should be fired
> +     */
> +    private void addChild(Object targetChild) {
> +        
> +        // Add a new child using targetChild as a key and 
> +        // its BCSChild instance as an entry
> +        synchronized(this.children) {        
> +            BCSChild ch = createBCSChild(targetChild, getBeanContextPeer());
> +            this.children.put(targetChild, ch);                
> +            childJustAddedHook(targetChild, ch);
> +        }
> +        
> +        // Fire memebership event
> +        fireChildrenAdded(getBCME(new Object[] { targetChild }));
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public boolean avoidingGui() {
> +        
> +        // Avoiding GUI means that
> +        // GUI is needed but not allowed to use at this time
> +        return (needsGui() && !this.okToUseGui);
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected Iterator bcsChildren() {
> +        
> +        // Return Iterator containing children 
> +        // that are instances of BCSChild class
> +        synchronized(this.children) {
> +            return new BCSIterator(this.children);
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected void bcsPreDeserializationHook(ObjectInputStream ois) 
> +            throws IOException, ClassNotFoundException {
> +                
> +        // Leave it for subclasses to implement
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected void bcsPreSerializationHook(ObjectOutputStream oos) 
> +            throws IOException {
> +                
> +        // Leave it for subclasses to implement
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected void childDeserializedHook(Object child, 
> +            BeanContextSupport.BCSChild bcsc) {
> +                
> +        synchronized(this.children) {
> +            this.children.put(child, bcsc);
> +        }
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected void childJustAddedHook(Object child, 
> +            BeanContextSupport.BCSChild bcsc) {
> +        
> +        // Leave it for subclasses to implement
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected void childJustRemovedHook(Object child, 
> +            BeanContextSupport.BCSChild bcsc) {
> +        
> +        // Leave it for subclasses to implement
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected static final boolean classEquals(Class first, Class second) {
> +        
> +        // Either classes themselves or their names should be equal
> +        return (first.equals(second) ? 
> +                true : 
> +                    (first.getName().equals(second.getName()) ? 
> +                     true : 
> +                     false));
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public void clear() {
> +        throw new UnsupportedOperationException();
> +        
> +        /*
> +        synchronized(BeanContext.globalHierarchyLock) {        
> +            Collection col = new ArrayList();
> +            
> +            // Remove all children from BeanContext that are in the collection
> +            // one by one. This operation is successfull if all the
> +            // removals succeded
> +            for (Iterator i = iterator(); i.hasNext(); ) {
> +                try {  
> +                    Object next = i.next();
> +                    
> +                    if (remove(next)) {
> +                        col.add(next);
> +                    }
> +                } catch(Exception e) {
> +                    
> +                    // Roll back changes
> +                    this.rollingBack = true;
> +                    addAll(col);
> +                    return;
> +                }
> +            }
> +        }*/
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public boolean contains(Object o) {      
> +                
> +        // See if a given object can be found among 
> +        // the children's collection values
> +        synchronized(BeanContext.globalHierarchyLock) {
> +            synchronized (this.children) {            
> +                return this.children.containsKey(o);
> +            }
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public boolean containsAll(Collection c) {
> +        
> +        // Iterate through the collection provided and find matches 
> +        // in the current BeanContext. If not found return false.
> +        for (Iterator i = c.iterator(); i.hasNext();) {
> +            Object next = i.next();
> +            
> +            if (!contains(next)) {
> +                return false;
> +            }
> +        }
> +        
> +        // If we are here, all the elements of the collection are presented
> +        // in this BeanContext
> +        return true;
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public boolean containsKey(Object o) {
> +        
> +        // See if a given object can be found among 
> +        // the children's collection keys
> +        synchronized(BeanContext.globalHierarchyLock) {
> +            synchronized (this.children) {
> +                return this.children.containsKey(o);
> +            }
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected final Object[] copyChildren() {
> +        
> +        // Make a copy of all children
> +        synchronized (this.children) {    
> +            return this.children.entrySet().toArray();
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected BCSChild createBCSChild(Object targetChild, Object peer) {
> +        
> +        // Create a child object with a reference to its peer
> +        return new BCSChild(targetChild, peer);
> +    }
> +   
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected final void deserialize(ObjectInputStream ois, Collection coll) 
> +            throws IOException, ClassNotFoundException {
> +        
> +        // Read objects from output stream until "EOS" (the end of stream)
> +        // mark is found. Place all the objects into collection provided
> +        while (true) {
> +            Object l = ois.readObject();
> +            
> +            if (l != null && l.equals("EOS")) {
> +                coll.add(l);
> +            } else {
> +                break;
> +            }
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public synchronized void dontUseGui() {
> +        
> +        // Command this BeanContext and its children not to use GUI
> +        this.okToUseGui = false;
> +        
> +        for (Iterator it = iterator(); it.hasNext(); ) {
> +            Object next = it.next();            
> +            Visibility vis = getChildVisibility(next);
> +            
> +            if (vis != null) {
> +                vis.dontUseGui();
> +            }
> +        }
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected final void fireChildrenAdded(BeanContextMembershipEvent bcme) {
> +        
> +        // Notify all registered listenes about the change made
> +        for (Iterator i = bcmListeners.iterator(); i.hasNext(); ) {
> +            BeanContextMembershipListener cur =
> +                (BeanContextMembershipListener) i.next();
> +                
> +            cur.childrenAdded(bcme);
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected final void fireChildrenRemoved(BeanContextMembershipEvent bcme) {
> +        
> +        // Notify all registered listenes about the change made
> +        for (Iterator i = bcmListeners.iterator(); i.hasNext(); ) {
> +            BeanContextMembershipListener cur =
> +                (BeanContextMembershipListener) i.next();
> +                
> +            cur.childrenRemoved(bcme);
> +        }
> +    }
> +    
> +    /**
> +     * Get BeanContextMembershipEvent class instance
> +     *
> +     * @param changes - an array of changes that has been made
> +     *
> +     * @return BeanContextMembershipEvent object
> +     */
> +    private BeanContextMembershipEvent getBCME(Object[] changes) {
> +        return new BeanContextMembershipEvent(getBeanContextPeer(), changes);
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public BeanContext getBeanContextPeer() {
> +        return (BeanContext) getBeanContextChildPeer();
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected static final BeanContextChild getChildBeanContextChild(
> +            Object child) {
> +                
> +        // There's nothing to do here if the child is null
> +        if (child == null) {
> +            return null;
> +        }
> +        
> +        // See if the child implements BeanContextChild or BeanContextProxy. 
> +        // Cast it to appropriate class or simply return null
> +        if (child instanceof BeanContextChild) {
> +            return (BeanContextChild) child;
> +        } else if (child instanceof BeanContextProxy) {
> +            return ((BeanContextProxy) child).getBeanContextProxy();
> +        } else {
> +            return null;
> +        }
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected static final BeanContextMembershipListener 
> +            getChildBeanContextMembershipListener(Object child) {
> +                
> +        // See if child implements BeanContextMembershipListener. 
> +        // Cast it to BeanContextMembershipListener if it does 
> +        // or return null otherwise
> +        if ((child != null) && child instanceof BeanContextMembershipListener) {
> +            return (BeanContextMembershipListener) child;
> +        } else {
> +            return null;
> +        }
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected static final PropertyChangeListener 
> +            getChildPropertyChangeListener(Object child) {
> +                
> +        // See if child implements PropertyChangeListener. 
> +        // Cast it to PropertyChangeListener if it does
> +        // or return null otherwise
> +        if ((child != null) && child instanceof PropertyChangeListener) {
> +            return (PropertyChangeListener) child;
> +        } else {
> +            return null;
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected static final Serializable getChildSerializable(Object child) {
> +        
> +        // See if child implements Serializable. 
> +        // Cast it to Serializable if it does
> +        // or return null otherwise
> +        if ((child != null) && child instanceof Serializable) {
> +            return (Serializable) child;
> +        } else {
> +            return null;
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected static final VetoableChangeListener 
> +            getChildVetoableChangeListener(Object child) {
> +                
> +        // See if child implements VetoableChangeListener. 
> +        // Cast it to VetoableChangeListener if it does
> +        // or return null otherwise
> +        if ((child != null) && child instanceof VetoableChangeListener) {
> +            return (VetoableChangeListener) child;
> +        } else {
> +            return null;
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected static final Visibility getChildVisibility(Object child) {
> +        
> +        // See if child implements Visibility. 
> +        // Cast it to Visibility if it does
> +        // or return null otherwise
> +        if ((child != null) && child instanceof Visibility) {
> +            return (Visibility) child;
> +        } else {
> +            return null;
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public synchronized Locale getLocale() {
> +        return this.locale;
> +    }
> +    
> +    /**
> +     * Construct PropertyChangeEvent object and return
> +     *
> +     * @param prop - property name
> +     * @param o - the old value
> +     * @param n - the new value
> +     * 
> +     * @return PropertyChangeEvent object
> +     */
> +    private PropertyChangeEvent getPCE(String prop, Object o, Object n) {
> +        return new PropertyChangeEvent(getBeanContextPeer(), prop, o, n);
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public URL getResource(String name, BeanContextChild bcc) {
> +        
> +        // The resource name should not be null
> +        if(name == null) {
> +            throw new IllegalArgumentException("Resource name can not be null");
> +        }
> +        
> +        // Load resource using the same ClassLoader as BeanContextChild specified
> +        // If NullPointerException occurs try to load it as system resource
> +        try {
> +            return bcc.getClass().getClassLoader().getResource(name);
> +        } catch(NullPointerException e) {
> +            try {
> +                return ClassLoader.getSystemResource(name);
> +            } catch(Exception ex) {
> +                
> +                // We tried our best but still failed
> +                throw new IllegalArgumentException("Invalid resource");
> +            }
> +        }
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public InputStream getResourceAsStream(String name, BeanContextChild bcc) {
> +        
> +        // The resource name should not be null
> +        if(name == null) {
> +            throw new IllegalArgumentException("Resource name can not be null");
> +        }
> +        
> +        // Load resource using the same ClassLoader as BeanContextChild specified
> +        // If NullPointerException occurs try to load it as system resource
> +        try {
> +            return bcc.getClass().getClassLoader().getResourceAsStream(name);
> +        } catch(NullPointerException e) {
> +            try {
> +                return ClassLoader.getSystemResourceAsStream(name);
> +            } catch(Exception ex) {
> +                
> +                // No success at all
> +                throw new IllegalArgumentException("Invalid resource");
> +            }
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected synchronized void initialize() {
> +        
> +        // Initialize some fields
> +        this.children = new HashMap();
> +        this.bcmListeners = new ArrayList();
> +        
> +        this.serializable = 0;
> +        this.serializing = false;
> +        
> +        // Initialize PropertyChangeListener
> +        this.pcl = new PropertyChangeListener() {
> +            
> +            public void propertyChange(PropertyChangeEvent pce) {
> +                BeanContextSupport.this.propertyChange(pce);
> +            }
> +        };
> +        
> +        // Initialize VetoableChangeListener
> +        this.vcl = new VetoableChangeListener() {
> +            
> +            public void vetoableChange(PropertyChangeEvent pce) 
> +                    throws PropertyVetoException {
> +                       
> +                BeanContextSupport.this.vetoableChange(pce);
> +            }
> +        };
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public Object instantiateChild(String beanName) 
> +            throws IOException, ClassNotFoundException {
> +                
> +        // Use Beans convenience method to instantiate the bean
> +        return Beans.instantiate(getBeanContextPeer().getClass().getClassLoader(), 
> +                                 beanName, 
> +                                 getBeanContextPeer());
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public synchronized boolean isDesignTime() {
> +        return this.designTime;
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public boolean isEmpty() {
> +        
> +        // See if there are any children in this BeanContext
> +        synchronized(BeanContext.globalHierarchyLock) {
> +            synchronized(this.children) {
> +                return this.children.isEmpty();
> +            }
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public boolean isSerializing() {
> +        return this.serializing;
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public Iterator iterator() {
> +        
> +        synchronized(BeanContext.globalHierarchyLock) {
> +            synchronized(this.children) {
> +                return this.children.keySet().iterator();
> +            }
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public synchronized boolean needsGui() {
> +        
> +        // BeanContext needs GUI if at least one its children needs it.
> +        // We may check it by trying to cast each child to Visibility
> +        // and see it needs GUI.
> +        // A child definitely needs GUI if it implements Component
> +        for (Iterator it = iterator(); it.hasNext(); ) {
> +            Object next = it.next();            
> +            Visibility vis = getChildVisibility(next);
> +            
> +            if (vis != null) {
> +                if (vis.needsGui()) {
> +                    return true;
> +                }
> +            } 
> +            
> +            if (next instanceof java.awt.Component) {
> +                return true;
> +            }
> +        }
> +        
> +        return false;
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public synchronized void okToUseGui() {
> +        
> +        // Notify this BeanContext and its children that it's OK now to use GUI
> +        this.okToUseGui = true;
> +        
> +        for (Iterator it = iterator(); it.hasNext(); ) {
> +            Object next = it.next();            
> +            Visibility vis = getChildVisibility(next);
> +            
> +            if (vis != null) {
> +                vis.okToUseGui();
> +            }
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public void propertyChange(PropertyChangeEvent pce) {
> +        
> +        if (!pce.getPropertyName().equals(BEAN_CONTEXT)) {
> +            return;
> +        }
> +        
> +        Object source = pce.getSource();
> +        
> +        if (source instanceof BCSChild) {
> +            BCSChild ch = (BCSChild) source;
> +            Object newValue = pce.getNewValue();            
> +            
> +            if (!newValue.equals(this.getBeanContextPeer())) {
> +                remove(ch.getChild(), false);
> +            }
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public final void readChildren(ObjectInputStream ois) 
> +            throws IOException, ClassNotFoundException {
> +        
> +        // Deserialize children
> +        for (int i = 0; i < this.serializable; i++) {  
> +            BCSChild bChild = (BCSChild) ois.readObject();
> +            childDeserializedHook(bChild.getChild(), bChild);
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    private void readObject(ObjectInputStream ois) 
> +            throws IOException, ClassNotFoundException {
> +                
> +        synchronized(BeanContext.globalHierarchyLock) {           
> +            ois.defaultReadObject();             
> +            initialize();             
> +            bcsPreDeserializationHook(ois);
> +            
> +            // Deserialize children
> +            if (!getBeanContextPeer().equals(this)) {
> +                readChildren(ois);
> +            }
> +            
> +            // Deserialize listeners
> +            synchronized(this.bcmListeners) {
> +                deserialize(ois, this.bcmListeners);
> +            } 
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public boolean remove(Object targetChild) {
> +        return remove(targetChild, true);
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected boolean remove(Object targetChild, boolean callChildSetBC) {
> +        
> +        synchronized(BeanContext.globalHierarchyLock) {
> +            
> +            // Make necessary checks
> +            if (!validatePendingRemove(targetChild)) {
> +                return false;
> +            }
> +            
> +            Object removed = null;
> +            
> +            if (containsKey(targetChild)) {      
> +                
> +                // Remove the reference to the BeanContext from the child 
> +                // if ordered to do so
> +                if (callChildSetBC) {
> +                    removeFromContext(targetChild);
> +                }
> +                
> +                synchronized(this.children) {
> +                    
> +                    // Just before removing save a reference to it for later use
> +                    // in childJustRemovedHook() method
> +                    BCSChild ch = (BCSChild) this.children.get(targetChild);
> +                    removed = this.children.remove(targetChild);
> +                    childJustRemovedHook(targetChild, ch);
> +                }
> +                
> +                // Fire the event
> +                fireChildrenRemoved(getBCME(new Object[] { targetChild }));
> +                
> +                // Check if this child implements Serializable and decrease 
> +                // the number of serializable children of BeanContext
> +                if (getChildSerializable(targetChild) != null) {
> +                    this.serializable--;
> +                }
> +            }
> +            
> +            return (removed != null);
> +        }
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public boolean removeAll(Collection c) {
> +        throw new UnsupportedOperationException();
> +        /*
> +        synchronized(BeanContext.globalHierarchyLock) {        
> +            Collection col = new ArrayList();
> +            
> +            // Remove all children from BeanContext that are in the collection
> +            // one by one. This operation is successfull if all the
> +            // removals succeded
> +            for (Iterator i = c.iterator(); i.hasNext(); ) {
> +                try {
> +                    Object next = i.next();
> +                    
> +                    if (remove(next)) {
> +                        col.add(next);
> +                    }
> +                } catch(Exception e) {
> +                    
> +                    // Roll back changes but first check if it's already rolling 
> +                    // back to avoid infinitive action
> +                    if (!this.rollingBack) {
> +                        this.rollingBack = true;
> +                        addAll(col);
> +                    } else {
> +                        this.rollingBack = false;
> +                    }
> +                    
> +                    return false;
> +                }
> +            }
> +        }
> +        
> +        return true;*/
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public void removeBeanContextMembershipListener(
> +            BeanContextMembershipListener bcml) {
> +                
> +        // BeanContextMembershipListener can not be null
> +        if (bcml == null) {
> +            throw new NullPointerException("Membership listener is null");
> +        }
> +        
> +        synchronized(this.bcmListeners) {
> +            this.bcmListeners.remove(bcml);
> +        }
> +    }
> +    
> +    /**
> +     * Separate BeanContext and its child that had just been removed
> +     * by removing all references to each other
> +     *
> +     * @param targetChild - a BeanContext child that was removed
> +     */
> +    private void removeFromContext(Object targetChild) {
> +        try {
> +                        
> +            // If child is an instance of BeanContextChild or BeanContextProxy,
> +            // invoke setBeanContext() method on this child
> +            // with null parameter
> +            BeanContextChild ch = getChildBeanContextChild(targetChild);
> +                
> +            if (ch != null) {                                     
> +                ch.setBeanContext(null);               
> +                ch.removePropertyChangeListener(BEAN_CONTEXT, this.pcl);
> +                ch.removeVetoableChangeListener(BEAN_CONTEXT, this.vcl);
> +            }   
> +        } catch(PropertyVetoException e) {
> +            
> +            // Required by spec
> +            throw new IllegalStateException(
> +                "PropertyVetoException was thrown while removing " +
> +                " a child: " + targetChild + "; " +
> +                "Original error message:" + e.getMessage());
> +        }
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public boolean retainAll(Collection c) {
> +        throw new UnsupportedOperationException();
> +        
> +        /*
> +        synchronized(BeanContext.globalHierarchyLock) {
> +            synchronized(this.children) {
> +                
> +                Collection col = new ArrayList();
> +                
> +                // Remove all children from BeanContext that are not in the 
> +                // collection
> +                // This operation is successfull if all the removals succeded
> +                for (Iterator i = iterator(); i.hasNext(); ) {   
> +                    Object nextKey = i.next();
> +                    Object nextValue = this.children.get(nextKey);
> +                    
> +                    if (!c.contains(nextKey) && !c.contains(nextValue)) {
> +                        try {                            
> +                            if (remove(nextKey)) {
> +                                col.add(nextKey);
> +                            }
> +                        } catch(Exception e) {
> +                            
> +                            // Roll back changes
> +                            this.rollingBack = true;
> +                            addAll(col);
> +                            return false;
> +                        }
> +                    }
> +                }
> +            }
> +        }
> +        
> +        return true;*/
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected final void serialize(ObjectOutputStream oos, Collection coll) 
> +            throws IOException {
> +        
> +        // Write the collection into ObjectOutputStream
> +        for (Iterator it = coll.iterator(); it.hasNext(); ) {
> +            Object l = it.next();
> +            
> +            if (getChildSerializable(l) != null) {
> +                oos.writeObject(l);
> +            }
> +        }
> +        
> +        // Mark the end of stream
> +        oos.writeObject("EOS");
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public synchronized void setDesignTime(boolean dTime) {
> +        
> +        boolean old = this.designTime;
> +        this.designTime = dTime;
> +        
> +        // Notify BeanContext about this change
> +        firePropertyChange("designTime", new Boolean(old), new Boolean(dTime));
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public synchronized void setLocale(Locale newLocale) 
> +            throws PropertyVetoException {
> +        
> +        // Use default locale if a new value is null        
> +        newLocale = (newLocale == null ? Locale.getDefault() : newLocale);   
> +        
> +        // Notify BeanContext about this change
> +        Locale old = (Locale) this.locale.clone();
> +        this.locale = newLocale;
> +        firePropertyChange("locale", old, newLocale);
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public int size() {
> +        
> +        // Return the number of children of this BeanContext
> +        synchronized(BeanContext.globalHierarchyLock) {
> +            synchronized(this.children) {
> +                return this.children.size();
> +            }
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public Object[] toArray() {
> +        
> +        // Convert the collection of children to array
> +        synchronized(BeanContext.globalHierarchyLock) {
> +            synchronized(this.children) {
> +                return this.children.keySet().toArray();
> +            }
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public Object[] toArray(Object[] arry) {
> +        
> +        // Convert the collection of children to array
> +        synchronized(BeanContext.globalHierarchyLock) {
> +            synchronized(this.children) {
> +                return this.children.keySet().toArray(arry);
> +            }
> +        }
> +    }
> +
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected boolean validatePendingAdd(Object targetChild) {
> +        
> +        
> +        return true;
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    protected boolean validatePendingRemove(Object targetChild) {
> +        
> +        if (targetChild == null) {
> +            throw new IllegalArgumentException("Target child is null");
> +        }
> +        
> +        return true;
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public void vetoableChange(PropertyChangeEvent pce) 
> +            throws PropertyVetoException {
> +                
> +        
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    public final void writeChildren(ObjectOutputStream oos) throws IOException {
> +        
> +        // Write serializable children to ObjectOutputStream
> +        synchronized(this.children) {
> +            for (Iterator it = iterator(); it.hasNext(); ) {
> +                Object next = it.next();
> +                
> +                if (getChildSerializable(next) != null) {
> +                    oos.writeObject(this.children.get(next));
> +                }
> +            }
> +        }
> +    }
> +    
> +    /**
> +     * @com.intel.drl.spec_ref
> +     */
> +    private void writeObject(ObjectOutputStream oos)
> +            throws IOException, ClassNotFoundException {
> +                  
> +        synchronized(BeanContext.globalHierarchyLock) {
> +            this.serializing = true;            
> +            oos.defaultWriteObject();     
> +            
> +            bcsPreSerializationHook(oos);          
> +            
> +            if (!this.getBeanContextPeer().equals(this)) {
> +                writeChildren(oos);            
> +            }
> +            
> +            synchronized(this.bcmListeners) {
> +                serialize(oos, this.bcmListeners);
> +            }
> +            
> +            this.serializing = false;
> +        }
> +    }                         
> +}
> 
> Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/IllegalArgumentExceptionTest.java
> URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/IllegalArgumentExceptionTest.java?rev=388415&r1=388414&r2=388415&view=diff
> ==============================================================================
> --- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/IllegalArgumentExceptionTest.java (original)
> +++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/IllegalArgumentExceptionTest.java Thu Mar 23 22:53:45 2006
> @@ -20,7 +20,7 @@
>  	class TestThread implements Runnable {
>  		public void run() {
>  			try {
> -				Thread.currentThread().sleep(5000);
> +				Thread.sleep(5000);
>  			} catch (Exception e) {
>  				System.out.println("Unable to start thread");
>  			}
> 
> Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/IllegalThreadStateExceptionTest.java
> URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/IllegalThreadStateExceptionTest.java?rev=388415&r1=388414&r2=388415&view=diff
> ==============================================================================
> --- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/IllegalThreadStateExceptionTest.java (original)
> +++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/IllegalThreadStateExceptionTest.java Thu Mar 23 22:53:45 2006
> @@ -20,7 +20,7 @@
>  	class TestThread implements Runnable {
>  		public void run() {
>  			try {
> -				Thread.currentThread().sleep(1000);
> +				Thread.sleep(1000);
>  			} catch (Exception e) {
>  				System.out.println("Unable to start thread");
>  			}
> 
> Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ProcessTest.java
> URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ProcessTest.java?rev=388415&r1=388414&r2=388415&view=diff
> ==============================================================================
> --- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ProcessTest.java (original)
> +++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ProcessTest.java Thu Mar 23 22:53:45 2006
> @@ -81,7 +81,7 @@
>  			String str3 = "Here is some more data.\n";
>  			os.write(str1.getBytes());
>  			try {
> -				Thread.currentThread().sleep(1000);
> +				Thread.sleep(1000);
>  			} catch (InterruptedException e) {
>  				e.printStackTrace();
>  			}
> 
> Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadGroupTest.java
> URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadGroupTest.java?rev=388415&r1=388414&r2=388415&view=diff
> ==============================================================================
> --- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadGroupTest.java (original)
> +++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadGroupTest.java Thu Mar 23 22:53:45 2006
> @@ -1489,7 +1489,7 @@
>  	protected void myassertTrue(String msg, boolean b) {
>  		// This method is defined here just to solve a visibility problem
>  		// of protected methods with inner types
> -		this.assertTrue(msg, b);
> +		assertTrue(msg, b);
>  	}
>  
>  	private ThreadGroup getRootThreadGroup() {
> 
> Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadTest.java
> URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadTest.java?rev=388415&r1=388414&r2=388415&view=diff
> ==============================================================================
> --- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadTest.java (original)
> +++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadTest.java Thu Mar 23 22:53:45 2006
> @@ -245,7 +245,7 @@
>  	public void test_activeCount() {
>  		// Test for method int java.lang.Thread.activeCount()
>  		Thread t = new Thread(new SimpleThread(1));
> -		int active = t.activeCount();
> +		int active = Thread.activeCount();
>  		assertTrue("Incorrect read made: " + active, active > 0);
>  		t.start();
>  		try {
> @@ -840,7 +840,7 @@
>  		long stime = 0, ftime = 0;
>  		try {
>  			stime = System.currentTimeMillis();
> -			Thread.currentThread().sleep(1000);
> +			Thread.sleep(1000);
>  			ftime = System.currentTimeMillis();
>  		} catch (InterruptedException e) {
>  			fail("Unexpected interrupt received");
> @@ -858,7 +858,7 @@
>  		long stime = 0, ftime = 0;
>  		try {
>  			stime = System.currentTimeMillis();
> -			Thread.currentThread().sleep(1000, 999999);
> +			Thread.sleep(1000, 999999);
>  			ftime = System.currentTimeMillis();
>  		} catch (InterruptedException e) {
>  			fail("Unexpected interrupt received");
> 
> Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java
> URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java?rev=388415&r1=388414&r2=388415&view=diff
> ==============================================================================
> --- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java (original)
> +++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java Thu Mar 23 22:53:45 2006
> @@ -734,7 +734,7 @@
>  				InetAddress localHost = null;
>  				try {
>  					localHost = InetAddress.getLocalHost();
> -					Thread.currentThread().sleep(1000);
> +					Thread.sleep(1000);
>  					DatagramSocket sds = new DatagramSocket(Support_PortManager
>  							.getNextPort());
>  					DatagramPacket rdp = new DatagramPacket("Test String"
> @@ -910,7 +910,7 @@
>  			try {
>  				Thread.sleep(500);
>  				ds.send(dp);
> -				Thread.currentThread().sleep(5000);
> +				Thread.sleep(5000);
>  			} catch (InterruptedException e) {
>  				ds.close();
>  				assertTrue("Incorrect data sent: " + retval, retval
> 
> 
> 

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

Mime
View raw message