J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun in the LICENSE file that accompanied this code. |
| 10 | * |
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | * version 2 for more details (a copy is included in the LICENSE file that |
| 15 | * accompanied this code). |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License version |
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | |
| 26 | package java.beans.beancontext; |
| 27 | |
| 28 | import java.beans.DesignMode; |
| 29 | import java.beans.Visibility; |
| 30 | |
| 31 | import java.io.InputStream; |
| 32 | import java.io.IOException; |
| 33 | |
| 34 | import java.net.URL; |
| 35 | |
| 36 | import java.util.Collection; |
| 37 | import java.util.Locale; |
| 38 | |
| 39 | /** |
| 40 | * <p> |
| 41 | * The BeanContext acts a logical hierarchical container for JavaBeans. |
| 42 | * </p> |
| 43 | * |
| 44 | * @author Laurence P. G. Cable |
| 45 | * @since 1.2 |
| 46 | * |
| 47 | * @see java.beans.Beans |
| 48 | * @see java.beans.beancontext.BeanContextChild |
| 49 | * @see java.beans.beancontext.BeanContextMembershipListener |
| 50 | * @see java.beans.PropertyChangeEvent |
| 51 | * @see java.beans.DesignMode |
| 52 | * @see java.beans.Visibility |
| 53 | * @see java.util.Collection |
| 54 | */ |
| 55 | |
| 56 | public interface BeanContext extends BeanContextChild, Collection, DesignMode, Visibility { |
| 57 | |
| 58 | /** |
| 59 | * Instantiate the javaBean named as a |
| 60 | * child of this <code>BeanContext</code>. |
| 61 | * The implementation of the JavaBean is |
| 62 | * derived from the value of the beanName parameter, |
| 63 | * and is defined by the |
| 64 | * <code>java.beans.Beans.instantiate()</code> method. |
| 65 | * |
| 66 | * @param beanName The name of the JavaBean to instantiate |
| 67 | * as a child of this <code>BeanContext</code> |
| 68 | * @throws <code>IOException</code> |
| 69 | * @throws <code>ClassNotFoundException</code> if the class identified |
| 70 | * by the beanName parameter is not found |
| 71 | */ |
| 72 | Object instantiateChild(String beanName) throws IOException, ClassNotFoundException; |
| 73 | |
| 74 | /** |
| 75 | * Analagous to <code>java.lang.ClassLoader.getResourceAsStream()</code>, |
| 76 | * this method allows a <code>BeanContext</code> implementation |
| 77 | * to interpose behavior between the child <code>Component</code> |
| 78 | * and underlying <code>ClassLoader</code>. |
| 79 | * |
| 80 | * @param name the resource name |
| 81 | * @param bcc the specified child |
| 82 | * @return an <code>InputStream</code> for reading the resource, |
| 83 | * or <code>null</code> if the resource could not |
| 84 | * be found. |
| 85 | * @throws <code>IllegalArgumentException</code> if |
| 86 | * the resource is not valid |
| 87 | */ |
| 88 | InputStream getResourceAsStream(String name, BeanContextChild bcc) throws IllegalArgumentException; |
| 89 | |
| 90 | /** |
| 91 | * Analagous to <code>java.lang.ClassLoader.getResource()</code>, this |
| 92 | * method allows a <code>BeanContext</code> implementation to interpose |
| 93 | * behavior between the child <code>Component</code> |
| 94 | * and underlying <code>ClassLoader</code>. |
| 95 | * |
| 96 | * @param name the resource name |
| 97 | * @param bcc the specified child |
| 98 | * @return a <code>URL</code> for the named |
| 99 | * resource for the specified child |
| 100 | * @throws <code>IllegalArgumentException</code> |
| 101 | * if the resource is not valid |
| 102 | */ |
| 103 | URL getResource(String name, BeanContextChild bcc) throws IllegalArgumentException; |
| 104 | |
| 105 | /** |
| 106 | * Adds the specified <code>BeanContextMembershipListener</code> |
| 107 | * to receive <code>BeanContextMembershipEvents</code> from |
| 108 | * this <code>BeanContext</code> whenever it adds |
| 109 | * or removes a child <code>Component</code>(s). |
| 110 | * |
| 111 | * @param bcml the <code>BeanContextMembershipListener</code> to be added |
| 112 | */ |
| 113 | void addBeanContextMembershipListener(BeanContextMembershipListener bcml); |
| 114 | |
| 115 | /** |
| 116 | * Removes the specified <code>BeanContextMembershipListener</code> |
| 117 | * so that it no longer receives <code>BeanContextMembershipEvent</code>s |
| 118 | * when the child <code>Component</code>(s) are added or removed. |
| 119 | * |
| 120 | * @param bcml the <code>BeanContextMembershipListener</code> |
| 121 | * to be removed |
| 122 | */ |
| 123 | void removeBeanContextMembershipListener(BeanContextMembershipListener bcml); |
| 124 | |
| 125 | /** |
| 126 | * This global lock is used by both <code>BeanContext</code> |
| 127 | * and <code>BeanContextServices</code> implementors |
| 128 | * to serialize changes in a <code>BeanContext</code> |
| 129 | * hierarchy and any service requests etc. |
| 130 | */ |
| 131 | public static final Object globalHierarchyLock = new Object(); |
| 132 | } |