src/share/classes/java/beans/Beans.java

Print this page
rev 10053 : 8044855: Add missing @since tag under java.beans.*
Reviewed-by:


  39 import java.io.IOException;
  40 import java.io.InputStream;
  41 import java.io.ObjectInputStream;
  42 import java.io.ObjectStreamClass;
  43 import java.io.StreamCorruptedException;
  44 
  45 import java.lang.reflect.Modifier;
  46 
  47 import java.net.URL;
  48 
  49 import java.security.AccessController;
  50 import java.security.PrivilegedAction;
  51 
  52 import java.util.Enumeration;
  53 import java.util.Hashtable;
  54 import java.util.Iterator;
  55 import java.util.Vector;
  56 
  57 /**
  58  * This class provides some general purpose beans control methods.


  59  */
  60 
  61 public class Beans {
  62 
  63     /**
  64      * <p>
  65      * Instantiate a JavaBean.
  66      * </p>
  67      * @return a JavaBean
  68      * @param     cls         the class-loader from which we should create
  69      *                        the bean.  If this is null, then the system
  70      *                        class-loader is used.
  71      * @param     beanName    the name of the bean within the class-loader.
  72      *                        For example "sun.beanbox.foobah"
  73      *
  74      * @exception ClassNotFoundException if the class of a serialized
  75      *              object could not be found.
  76      * @exception IOException if an I/O error occurs.
  77      */
  78 
  79     public static Object instantiate(ClassLoader cls, String beanName) throws IOException, ClassNotFoundException {
  80         return Beans.instantiate(cls, beanName, null, null);
  81     }
  82 
  83     /**
  84      * <p>
  85      * Instantiate a JavaBean.
  86      * </p>
  87      * @return a JavaBean
  88      *
  89      * @param     cls         the class-loader from which we should create
  90      *                        the bean.  If this is null, then the system
  91      *                        class-loader is used.
  92      * @param     beanName    the name of the bean within the class-loader.
  93      *                        For example "sun.beanbox.foobah"
  94      * @param     beanContext The BeanContext in which to nest the new bean
  95      *
  96      * @exception ClassNotFoundException if the class of a serialized
  97      *              object could not be found.
  98      * @exception IOException if an I/O error occurs.

  99      */
 100 
 101     public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext) throws IOException, ClassNotFoundException {
 102         return Beans.instantiate(cls, beanName, beanContext, null);
 103     }
 104 
 105     /**
 106      * Instantiate a bean.
 107      * <p>
 108      * The bean is created based on a name relative to a class-loader.
 109      * This name should be a dot-separated name such as "a.b.c".
 110      * <p>
 111      * In Beans 1.0 the given name can indicate either a serialized object
 112      * or a class.  Other mechanisms may be added in the future.  In
 113      * beans 1.0 we first try to treat the beanName as a serialized object
 114      * name then as a class name.
 115      * <p>
 116      * When using the beanName as a serialized object name we convert the
 117      * given beanName to a resource pathname and add a trailing ".ser" suffix.
 118      * We then try to load a serialized object from that resource.


 135      * Note that applets created via beans.instantiate run in a slightly
 136      * different environment than applets running inside browsers.  In
 137      * particular, bean applets have no access to "parameters", so they may
 138      * wish to provide property get/set methods to set parameter values.  We
 139      * advise bean-applet developers to test their bean-applets against both
 140      * the JDK appletviewer (for a reference browser environment) and the
 141      * BDK BeanBox (for a reference bean container).
 142      *
 143      * @return a JavaBean
 144      * @param     cls         the class-loader from which we should create
 145      *                        the bean.  If this is null, then the system
 146      *                        class-loader is used.
 147      * @param     beanName    the name of the bean within the class-loader.
 148      *                        For example "sun.beanbox.foobah"
 149      * @param     beanContext The BeanContext in which to nest the new bean
 150      * @param     initializer The AppletInitializer for the new bean
 151      *
 152      * @exception ClassNotFoundException if the class of a serialized
 153      *              object could not be found.
 154      * @exception IOException if an I/O error occurs.

 155      */
 156 
 157     public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext, AppletInitializer initializer)
 158                         throws IOException, ClassNotFoundException {
 159 
 160         InputStream ins;
 161         ObjectInputStream oins = null;
 162         Object result = null;
 163         boolean serialized = false;
 164         IOException serex = null;
 165 
 166         // If the given classloader is null, we check if an
 167         // system classloader is available and (if so)
 168         // use that instead.
 169         // Note that calls on the system class loader will
 170         // look in the bootstrap class loader first.
 171         if (cls == null) {
 172             try {
 173                 cls = ClassLoader.getSystemClassLoader();
 174             } catch (SecurityException ex) {




  39 import java.io.IOException;
  40 import java.io.InputStream;
  41 import java.io.ObjectInputStream;
  42 import java.io.ObjectStreamClass;
  43 import java.io.StreamCorruptedException;
  44 
  45 import java.lang.reflect.Modifier;
  46 
  47 import java.net.URL;
  48 
  49 import java.security.AccessController;
  50 import java.security.PrivilegedAction;
  51 
  52 import java.util.Enumeration;
  53 import java.util.Hashtable;
  54 import java.util.Iterator;
  55 import java.util.Vector;
  56 
  57 /**
  58  * This class provides some general purpose beans control methods.
  59  *
  60  * @since 1.1
  61  */
  62 
  63 public class Beans {
  64 
  65     /**
  66      * <p>
  67      * Instantiate a JavaBean.
  68      * </p>
  69      * @return a JavaBean
  70      * @param     cls         the class-loader from which we should create
  71      *                        the bean.  If this is null, then the system
  72      *                        class-loader is used.
  73      * @param     beanName    the name of the bean within the class-loader.
  74      *                        For example "sun.beanbox.foobah"
  75      *
  76      * @exception ClassNotFoundException if the class of a serialized
  77      *              object could not be found.
  78      * @exception IOException if an I/O error occurs.
  79      */
  80 
  81     public static Object instantiate(ClassLoader cls, String beanName) throws IOException, ClassNotFoundException {
  82         return Beans.instantiate(cls, beanName, null, null);
  83     }
  84 
  85     /**
  86      * <p>
  87      * Instantiate a JavaBean.
  88      * </p>
  89      * @return a JavaBean
  90      *
  91      * @param     cls         the class-loader from which we should create
  92      *                        the bean.  If this is null, then the system
  93      *                        class-loader is used.
  94      * @param     beanName    the name of the bean within the class-loader.
  95      *                        For example "sun.beanbox.foobah"
  96      * @param     beanContext The BeanContext in which to nest the new bean
  97      *
  98      * @exception ClassNotFoundException if the class of a serialized
  99      *              object could not be found.
 100      * @exception IOException if an I/O error occurs.
 101      * @since 1.2
 102      */
 103 
 104     public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext) throws IOException, ClassNotFoundException {
 105         return Beans.instantiate(cls, beanName, beanContext, null);
 106     }
 107 
 108     /**
 109      * Instantiate a bean.
 110      * <p>
 111      * The bean is created based on a name relative to a class-loader.
 112      * This name should be a dot-separated name such as "a.b.c".
 113      * <p>
 114      * In Beans 1.0 the given name can indicate either a serialized object
 115      * or a class.  Other mechanisms may be added in the future.  In
 116      * beans 1.0 we first try to treat the beanName as a serialized object
 117      * name then as a class name.
 118      * <p>
 119      * When using the beanName as a serialized object name we convert the
 120      * given beanName to a resource pathname and add a trailing ".ser" suffix.
 121      * We then try to load a serialized object from that resource.


 138      * Note that applets created via beans.instantiate run in a slightly
 139      * different environment than applets running inside browsers.  In
 140      * particular, bean applets have no access to "parameters", so they may
 141      * wish to provide property get/set methods to set parameter values.  We
 142      * advise bean-applet developers to test their bean-applets against both
 143      * the JDK appletviewer (for a reference browser environment) and the
 144      * BDK BeanBox (for a reference bean container).
 145      *
 146      * @return a JavaBean
 147      * @param     cls         the class-loader from which we should create
 148      *                        the bean.  If this is null, then the system
 149      *                        class-loader is used.
 150      * @param     beanName    the name of the bean within the class-loader.
 151      *                        For example "sun.beanbox.foobah"
 152      * @param     beanContext The BeanContext in which to nest the new bean
 153      * @param     initializer The AppletInitializer for the new bean
 154      *
 155      * @exception ClassNotFoundException if the class of a serialized
 156      *              object could not be found.
 157      * @exception IOException if an I/O error occurs.
 158      * @since 1.2
 159      */
 160 
 161     public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext, AppletInitializer initializer)
 162                         throws IOException, ClassNotFoundException {
 163 
 164         InputStream ins;
 165         ObjectInputStream oins = null;
 166         Object result = null;
 167         boolean serialized = false;
 168         IOException serex = null;
 169 
 170         // If the given classloader is null, we check if an
 171         // system classloader is available and (if so)
 172         // use that instead.
 173         // Note that calls on the system class loader will
 174         // look in the bootstrap class loader first.
 175         if (cls == null) {
 176             try {
 177                 cls = ClassLoader.getSystemClassLoader();
 178             } catch (SecurityException ex) {