In order to make javabeans module independent on applet and yet allow Beans class to have a method which references AppletInitializer, I am creating new module: deprecated7. This one shall consist of all the garbage identified in JDK7 development which has so many dependencies that it does not fit anywhere else. Beans class is moved there and instead of it, there is new BeanFactory class with the same methods (expect the one with AppletInitializer parameter).
authorJaroslav Tulach <jtulach@netbeans.org>
Wed, 17 Jun 2009 15:11:07 +0200
changeset 12404b353465cd30
parent 1239 0b5692417910
child 1241 e38683764572
In order to make javabeans module independent on applet and yet allow Beans class to have a method which references AppletInitializer, I am creating new module: deprecated7. This one shall consist of all the garbage identified in JDK7 development which has so many dependencies that it does not fit anywhere else. Beans class is moved there and instead of it, there is new BeanFactory class with the same methods (expect the one with AppletInitializer parameter).
build.xml
src/share/classes/java/beans/BeanFactory.java
src/share/classes/java/beans/Beans.java
src/share/classes/java/beans/beancontext/BeanContextSupport.java
     1.1 --- a/build.xml	Wed Jun 17 14:45:59 2009 +0200
     1.2 +++ b/build.xml	Wed Jun 17 15:11:07 2009 +0200
     1.3 @@ -6,6 +6,7 @@
     1.4          <antcall target="base"/>
     1.5          <antcall target="beans"/>
     1.6          <antcall target="applet"/>
     1.7 +        <antcall target="deprecated7"/>
     1.8      </target>
     1.9      <!-- basic parameters -->
    1.10      <path id="src.path">
    1.11 @@ -35,10 +36,17 @@
    1.12              </or>
    1.13              <none>
    1.14                  <selector refid="applet"/>
    1.15 +                <selector refid="deprecated7"/>
    1.16              </none>
    1.17          </and>
    1.18      </selector>
    1.19  
    1.20 +    <selector id="deprecated7">
    1.21 +        <or>
    1.22 +            <filename name="java/beans/Beans*"/>
    1.23 +        </or>
    1.24 +    </selector>
    1.25 +
    1.26      <selector id="corba">
    1.27          <or>
    1.28              <filename name="org/omg/**"/>
    1.29 @@ -51,11 +59,18 @@
    1.30              <selector refid="applet"/>
    1.31              <selector refid="beans"/>
    1.32              <selector refid="corba"/>
    1.33 +            <selector refid="deprecated7"/>
    1.34          </none>
    1.35      </selector>
    1.36  
    1.37      <!-- individual compilation tasks -->
    1.38  
    1.39 +    <target name="deprecated7">
    1.40 +        <antcall target="-compile-one-module">
    1.41 +            <param name="module" value="deprecated7"/>
    1.42 +            <param name="depends" value="beans:applet"/>
    1.43 +        </antcall>
    1.44 +    </target>
    1.45      <target name="applet">
    1.46          <antcall target="-compile-one-module">
    1.47              <param name="module" value="applet"/>
    1.48 @@ -91,7 +106,7 @@
    1.49      <!-- shared routine to compile one of the modules -->
    1.50      <target name="-compile-one-module">
    1.51          <mkdir dir="${build.dir}/classes/${module}"/>
    1.52 -        <pathconvert pathsep="," property="module.cp">
    1.53 +        <pathconvert pathsep=":"  property="module.cp">
    1.54              <path path="${depends}"/>
    1.55              <mapper type="regexp" from=".*[/\\]([^/\\]*)" to="${build.dir}/\1.jar"/>
    1.56          </pathconvert>
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/share/classes/java/beans/BeanFactory.java	Wed Jun 17 15:11:07 2009 +0200
     2.3 @@ -0,0 +1,402 @@
     2.4 +/*
     2.5 + * Copyright 1996-2009 Sun Microsystems, Inc.  All Rights Reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.  Sun designates this
    2.11 + * particular file as subject to the "Classpath" exception as provided
    2.12 + * by Sun in the LICENSE file that accompanied this code.
    2.13 + *
    2.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.17 + * version 2 for more details (a copy is included in the LICENSE file that
    2.18 + * accompanied this code).
    2.19 + *
    2.20 + * You should have received a copy of the GNU General Public License version
    2.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.23 + *
    2.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    2.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    2.26 + * have any questions.
    2.27 + */
    2.28 +
    2.29 +package java.beans;
    2.30 +
    2.31 +import com.sun.beans.finder.ClassFinder;
    2.32 +
    2.33 +import java.awt.GraphicsEnvironment;
    2.34 +
    2.35 +import java.beans.beancontext.BeanContext;
    2.36 +
    2.37 +import java.io.IOException;
    2.38 +import java.io.InputStream;
    2.39 +import java.io.ObjectInputStream;
    2.40 +import java.io.ObjectStreamClass;
    2.41 +import java.io.StreamCorruptedException;
    2.42 +
    2.43 +
    2.44 +import java.security.AccessController;
    2.45 +import java.security.PrivilegedAction;
    2.46 +
    2.47 +import java.util.Iterator;
    2.48 +import java.util.ServiceLoader;
    2.49 +
    2.50 +import sun.awt.AppContext;
    2.51 +import sun.beans.AppletProxy;
    2.52 +
    2.53 +/**
    2.54 + * This class provides some general purpose beans control methods.
    2.55 + * @since 1.7
    2.56 + */
    2.57 +public class BeanFactory {
    2.58 +    private static final Object DESIGN_TIME = new Object();
    2.59 +    private static final Object GUI_AVAILABLE = new Object();
    2.60 +
    2.61 +    /**
    2.62 +     * <p>
    2.63 +     * Instantiate a JavaBean.
    2.64 +     * </p>
    2.65 +     *
    2.66 +     * @param     cls         the class-loader from which we should create
    2.67 +     *                        the bean.  If this is null, then the system
    2.68 +     *                        class-loader is used.
    2.69 +     * @param     beanName    the name of the bean within the class-loader.
    2.70 +     *                        For example "sun.beanbox.foobah"
    2.71 +     *
    2.72 +     * @exception ClassNotFoundException if the class of a serialized
    2.73 +     *              object could not be found.
    2.74 +     * @exception IOException if an I/O error occurs.
    2.75 +     */
    2.76 +
    2.77 +    public static Object instantiate(ClassLoader cls, String beanName) throws IOException, ClassNotFoundException {
    2.78 +        return BeanFactory.instantiate(cls, beanName, null, null);
    2.79 +    }
    2.80 +
    2.81 +    /**
    2.82 +     * <p>
    2.83 +     * Instantiate a JavaBean.
    2.84 +     * </p>
    2.85 +     *
    2.86 +     * @param     cls         the class-loader from which we should create
    2.87 +     *                        the bean.  If this is null, then the system
    2.88 +     *                        class-loader is used.
    2.89 +     * @param     beanName    the name of the bean within the class-loader.
    2.90 +     *                        For example "sun.beanbox.foobah"
    2.91 +     * @param     beanContext The BeanContext in which to nest the new bean
    2.92 +     *
    2.93 +     * @exception ClassNotFoundException if the class of a serialized
    2.94 +     *              object could not be found.
    2.95 +     * @exception IOException if an I/O error occurs.
    2.96 +     */
    2.97 +
    2.98 +    public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext) throws IOException, ClassNotFoundException {
    2.99 +        return BeanFactory.instantiate(cls, beanName, beanContext, null);
   2.100 +    }
   2.101 +
   2.102 +    /**
   2.103 +     * Instantiate a bean.
   2.104 +     * <p>
   2.105 +     * The bean is created based on a name relative to a class-loader.
   2.106 +     * This name should be a dot-separated name such as "a.b.c".
   2.107 +     * <p>
   2.108 +     * In Beans 1.0 the given name can indicate either a serialized object
   2.109 +     * or a class.  Other mechanisms may be added in the future.  In
   2.110 +     * beans 1.0 we first try to treat the beanName as a serialized object
   2.111 +     * name then as a class name.
   2.112 +     * <p>
   2.113 +     * When using the beanName as a serialized object name we convert the
   2.114 +     * given beanName to a resource pathname and add a trailing ".ser" suffix.
   2.115 +     * We then try to load a serialized object from that resource.
   2.116 +     * <p>
   2.117 +     * For example, given a beanName of "x.y", Beans.instantiate would first
   2.118 +     * try to read a serialized object from the resource "x/y.ser" and if
   2.119 +     * that failed it would try to load the class "x.y" and create an
   2.120 +     * instance of that class.
   2.121 +     * <p>
   2.122 +     * If the bean is a subtype of java.applet.Applet, then it is given
   2.123 +     * some special initialization.  First, it is supplied with a default
   2.124 +     * AppletStub and AppletContext.  Second, if it was instantiated from
   2.125 +     * a classname the applet's "init" method is called.  (If the bean was
   2.126 +     * deserialized this step is skipped.)
   2.127 +     * <p>
   2.128 +     * Note that for beans which are applets, it is the caller's responsiblity
   2.129 +     * to call "start" on the applet.  For correct behaviour, this should be done
   2.130 +     * after the applet has been added into a visible AWT container.
   2.131 +     * <p>
   2.132 +     * Note that applets created via beans.instantiate run in a slightly
   2.133 +     * different environment than applets running inside browsers.  In
   2.134 +     * particular, bean applets have no access to "parameters", so they may
   2.135 +     * wish to provide property get/set methods to set parameter values.  We
   2.136 +     * advise bean-applet developers to test their bean-applets against both
   2.137 +     * the JDK appletviewer (for a reference browser environment) and the
   2.138 +     * BDK BeanBox (for a reference bean container).
   2.139 +     *
   2.140 +     * @param     cls         the class-loader from which we should create
   2.141 +     *                        the bean.  If this is null, then the system
   2.142 +     *                        class-loader is used.
   2.143 +     * @param     beanName    the name of the bean within the class-loader.
   2.144 +     *                        For example "sun.beanbox.foobah"
   2.145 +     * @param     beanContext The BeanContext in which to nest the new bean
   2.146 +     * @param     initializer The AppletInitializer for the new bean
   2.147 +     *
   2.148 +     * @exception ClassNotFoundException if the class of a serialized
   2.149 +     *              object could not be found.
   2.150 +     * @exception IOException if an I/O error occurs.
   2.151 +     */
   2.152 +    static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext, Object initializer)
   2.153 +                        throws IOException, ClassNotFoundException {
   2.154 +
   2.155 +        InputStream ins;
   2.156 +        ObjectInputStream oins = null;
   2.157 +        Object result = null;
   2.158 +        boolean serialized = false;
   2.159 +        IOException serex = null;
   2.160 +
   2.161 +        // If the given classloader is null, we check if an
   2.162 +        // system classloader is available and (if so)
   2.163 +        // use that instead.
   2.164 +        // Note that calls on the system class loader will
   2.165 +        // look in the bootstrap class loader first.
   2.166 +        if (cls == null) {
   2.167 +            try {
   2.168 +                cls = ClassLoader.getSystemClassLoader();
   2.169 +            } catch (SecurityException ex) {
   2.170 +                // We're not allowed to access the system class loader.
   2.171 +                // Drop through.
   2.172 +            }
   2.173 +        }
   2.174 +
   2.175 +        // Try to find a serialized object with this name
   2.176 +        final String serName = beanName.replace('.','/').concat(".ser");
   2.177 +        final ClassLoader loader = cls;
   2.178 +        ins = (InputStream)AccessController.doPrivileged
   2.179 +            (new PrivilegedAction() {
   2.180 +                public Object run() {
   2.181 +                    if (loader == null)
   2.182 +                        return ClassLoader.getSystemResourceAsStream(serName);
   2.183 +                    else
   2.184 +                        return loader.getResourceAsStream(serName);
   2.185 +                }
   2.186 +        });
   2.187 +        if (ins != null) {
   2.188 +            try {
   2.189 +                if (cls == null) {
   2.190 +                    oins = new ObjectInputStream(ins);
   2.191 +                } else {
   2.192 +                    oins = new ObjectInputStreamWithLoader(ins, cls);
   2.193 +                }
   2.194 +                result = oins.readObject();
   2.195 +                serialized = true;
   2.196 +                oins.close();
   2.197 +            } catch (IOException ex) {
   2.198 +                ins.close();
   2.199 +                // Drop through and try opening the class.  But remember
   2.200 +                // the exception in case we can't find the class either.
   2.201 +                serex = ex;
   2.202 +            } catch (ClassNotFoundException ex) {
   2.203 +                ins.close();
   2.204 +                throw ex;
   2.205 +            }
   2.206 +        }
   2.207 +
   2.208 +        if (result == null) {
   2.209 +            // No serialized object, try just instantiating the class
   2.210 +            Class cl;
   2.211 +
   2.212 +            try {
   2.213 +                cl = ClassFinder.findClass(beanName, cls);
   2.214 +            } catch (ClassNotFoundException ex) {
   2.215 +                // There is no appropriate class.  If we earlier tried to
   2.216 +                // deserialize an object and got an IO exception, throw that,
   2.217 +                // otherwise rethrow the ClassNotFoundException.
   2.218 +                if (serex != null) {
   2.219 +                    throw serex;
   2.220 +                }
   2.221 +                throw ex;
   2.222 +            }
   2.223 +
   2.224 +            /*
   2.225 +             * Try to instantiate the class.
   2.226 +             */
   2.227 +
   2.228 +                try {
   2.229 +                result = cl.newInstance();
   2.230 +            } catch (Exception ex) {
   2.231 +                // We have to remap the exception to one in our signature.
   2.232 +                // But we pass extra information in the detail message.
   2.233 +                throw new ClassNotFoundException("" + cl + " : " + ex, ex);
   2.234 +            }
   2.235 +        }
   2.236 +
   2.237 +        if (result != null) {
   2.238 +
   2.239 +            // Ok, if the result is an applet initialize it.
   2.240 +            Iterator<AppletProxy> it = ServiceLoader.load(AppletProxy.class).iterator();
   2.241 +            AppletProxy ap = it.hasNext() ? it.next() : null;
   2.242 +            if (ap != null || !ap.initialize(
   2.243 +                result, initializer, serialized, beanName, beanContext, cls
   2.244 +            )) {
   2.245 +                if (beanContext != null) beanContext.add(result);
   2.246 +            }
   2.247 +        }
   2.248 +
   2.249 +        return result;
   2.250 +    }
   2.251 +
   2.252 +
   2.253 +    /**
   2.254 +     * From a given bean, obtain an object representing a specified
   2.255 +     * type view of that source object.
   2.256 +     * <p>
   2.257 +     * The result may be the same object or a different object.  If
   2.258 +     * the requested target view isn't available then the given
   2.259 +     * bean is returned.
   2.260 +     * <p>
   2.261 +     * This method is provided in Beans 1.0 as a hook to allow the
   2.262 +     * addition of more flexible bean behaviour in the future.
   2.263 +     *
   2.264 +     * @param bean        Object from which we want to obtain a view.
   2.265 +     * @param targetType  The type of view we'd like to get.
   2.266 +     *
   2.267 +     */
   2.268 +    public static Object getInstanceOf(Object bean, Class<?> targetType) {
   2.269 +        return bean;
   2.270 +    }
   2.271 +
   2.272 +    /**
   2.273 +     * Check if a bean can be viewed as a given target type.
   2.274 +     * The result will be true if the Beans.getInstanceof method
   2.275 +     * can be used on the given bean to obtain an object that
   2.276 +     * represents the specified targetType type view.
   2.277 +     *
   2.278 +     * @param bean  Bean from which we want to obtain a view.
   2.279 +     * @param targetType  The type of view we'd like to get.
   2.280 +     * @return "true" if the given bean supports the given targetType.
   2.281 +     *
   2.282 +     */
   2.283 +    public static boolean isInstanceOf(Object bean, Class<?> targetType) {
   2.284 +        return Introspector.isSubclass(bean.getClass(), targetType);
   2.285 +    }
   2.286 +
   2.287 +
   2.288 +    /**
   2.289 +     * Test if we are in design-mode.
   2.290 +     *
   2.291 +     * @return  True if we are running in an application construction
   2.292 +     *          environment.
   2.293 +     *
   2.294 +     * @see DesignMode
   2.295 +     */
   2.296 +    public static boolean isDesignTime() {
   2.297 +        Object value = AppContext.getAppContext().get(DESIGN_TIME);
   2.298 +        return (value instanceof Boolean) && (Boolean) value;
   2.299 +    }
   2.300 +
   2.301 +    /**
   2.302 +     * Determines whether beans can assume a GUI is available.
   2.303 +     *
   2.304 +     * @return  True if we are running in an environment where beans
   2.305 +     *     can assume that an interactive GUI is available, so they
   2.306 +     *     can pop up dialog boxes, etc.  This will normally return
   2.307 +     *     true in a windowing environment, and will normally return
   2.308 +     *     false in a server environment or if an application is
   2.309 +     *     running as part of a batch job.
   2.310 +     *
   2.311 +     * @see Visibility
   2.312 +     *
   2.313 +     */
   2.314 +    public static boolean isGuiAvailable() {
   2.315 +        Object value = AppContext.getAppContext().get(GUI_AVAILABLE);
   2.316 +        return (value instanceof Boolean) ? (Boolean) value : !GraphicsEnvironment.isHeadless();
   2.317 +    }
   2.318 +
   2.319 +    /**
   2.320 +     * Used to indicate whether of not we are running in an application
   2.321 +     * builder environment.
   2.322 +     *
   2.323 +     * <p>Note that this method is security checked
   2.324 +     * and is not available to (for example) untrusted applets.
   2.325 +     * More specifically, if there is a security manager,
   2.326 +     * its <code>checkPropertiesAccess</code>
   2.327 +     * method is called. This could result in a SecurityException.
   2.328 +     *
   2.329 +     * @param isDesignTime  True if we're in an application builder tool.
   2.330 +     * @exception  SecurityException  if a security manager exists and its
   2.331 +     *             <code>checkPropertiesAccess</code> method doesn't allow setting
   2.332 +     *              of system properties.
   2.333 +     * @see SecurityManager#checkPropertiesAccess
   2.334 +     */
   2.335 +
   2.336 +    public static void setDesignTime(boolean isDesignTime)
   2.337 +                        throws SecurityException {
   2.338 +        SecurityManager sm = System.getSecurityManager();
   2.339 +        if (sm != null) {
   2.340 +            sm.checkPropertiesAccess();
   2.341 +        }
   2.342 +        AppContext.getAppContext().put(DESIGN_TIME, Boolean.valueOf(isDesignTime));
   2.343 +    }
   2.344 +
   2.345 +    /**
   2.346 +     * Used to indicate whether of not we are running in an environment
   2.347 +     * where GUI interaction is available.
   2.348 +     *
   2.349 +     * <p>Note that this method is security checked
   2.350 +     * and is not available to (for example) untrusted applets.
   2.351 +     * More specifically, if there is a security manager,
   2.352 +     * its <code>checkPropertiesAccess</code>
   2.353 +     * method is called. This could result in a SecurityException.
   2.354 +     *
   2.355 +     * @param isGuiAvailable  True if GUI interaction is available.
   2.356 +     * @exception  SecurityException  if a security manager exists and its
   2.357 +     *             <code>checkPropertiesAccess</code> method doesn't allow setting
   2.358 +     *              of system properties.
   2.359 +     * @see SecurityManager#checkPropertiesAccess
   2.360 +     */
   2.361 +
   2.362 +    public static void setGuiAvailable(boolean isGuiAvailable)
   2.363 +                        throws SecurityException {
   2.364 +        SecurityManager sm = System.getSecurityManager();
   2.365 +        if (sm != null) {
   2.366 +            sm.checkPropertiesAccess();
   2.367 +        }
   2.368 +        AppContext.getAppContext().put(GUI_AVAILABLE, Boolean.valueOf(isGuiAvailable));
   2.369 +    }
   2.370 +}
   2.371 +
   2.372 +/**
   2.373 + * This subclass of ObjectInputStream delegates loading of classes to
   2.374 + * an existing ClassLoader.
   2.375 + */
   2.376 +
   2.377 +class ObjectInputStreamWithLoader extends ObjectInputStream
   2.378 +{
   2.379 +    private ClassLoader loader;
   2.380 +
   2.381 +    /**
   2.382 +     * Loader must be non-null;
   2.383 +     */
   2.384 +
   2.385 +    public ObjectInputStreamWithLoader(InputStream in, ClassLoader loader)
   2.386 +            throws IOException, StreamCorruptedException {
   2.387 +
   2.388 +        super(in);
   2.389 +        if (loader == null) {
   2.390 +            throw new IllegalArgumentException("Illegal null argument to ObjectInputStreamWithLoader");
   2.391 +        }
   2.392 +        this.loader = loader;
   2.393 +    }
   2.394 +
   2.395 +    /**
   2.396 +     * Use the given ClassLoader rather than using the system class
   2.397 +     */
   2.398 +    protected Class resolveClass(ObjectStreamClass classDesc)
   2.399 +        throws IOException, ClassNotFoundException {
   2.400 +
   2.401 +        String cname = classDesc.getName();
   2.402 +        return ClassFinder.resolveClass(cname, this.loader);
   2.403 +    }
   2.404 +}
   2.405 +
     3.1 --- a/src/share/classes/java/beans/Beans.java	Wed Jun 17 14:45:59 2009 +0200
     3.2 +++ b/src/share/classes/java/beans/Beans.java	Wed Jun 17 15:11:07 2009 +0200
     3.3 @@ -69,10 +69,11 @@
     3.4       * @exception ClassNotFoundException if the class of a serialized
     3.5       *              object could not be found.
     3.6       * @exception IOException if an I/O error occurs.
     3.7 +     * @deprecated Use {@link BeanFactory}
     3.8       */
     3.9  
    3.10      public static Object instantiate(ClassLoader cls, String beanName) throws IOException, ClassNotFoundException {
    3.11 -        return Beans.instantiate(cls, beanName, null, null);
    3.12 +        return BeanFactory.instantiate(cls, beanName, null, null);
    3.13      }
    3.14  
    3.15      /**
    3.16 @@ -90,10 +91,11 @@
    3.17       * @exception ClassNotFoundException if the class of a serialized
    3.18       *              object could not be found.
    3.19       * @exception IOException if an I/O error occurs.
    3.20 +     * @deprecated Use {@link BeanFactory}
    3.21       */
    3.22  
    3.23      public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext) throws IOException, ClassNotFoundException {
    3.24 -        return Beans.instantiate(cls, beanName, beanContext, null);
    3.25 +        return BeanFactory.instantiate(cls, beanName, beanContext, null);
    3.26      }
    3.27  
    3.28      /**
    3.29 @@ -149,103 +151,8 @@
    3.30  
    3.31      public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext, AppletInitializer initializer)
    3.32                          throws IOException, ClassNotFoundException {
    3.33 -
    3.34 -        InputStream ins;
    3.35 -        ObjectInputStream oins = null;
    3.36 -        Object result = null;
    3.37 -        boolean serialized = false;
    3.38 -        IOException serex = null;
    3.39 -
    3.40 -        // If the given classloader is null, we check if an
    3.41 -        // system classloader is available and (if so)
    3.42 -        // use that instead.
    3.43 -        // Note that calls on the system class loader will
    3.44 -        // look in the bootstrap class loader first.
    3.45 -        if (cls == null) {
    3.46 -            try {
    3.47 -                cls = ClassLoader.getSystemClassLoader();
    3.48 -            } catch (SecurityException ex) {
    3.49 -                // We're not allowed to access the system class loader.
    3.50 -                // Drop through.
    3.51 -            }
    3.52 -        }
    3.53 -
    3.54 -        // Try to find a serialized object with this name
    3.55 -        final String serName = beanName.replace('.','/').concat(".ser");
    3.56 -        final ClassLoader loader = cls;
    3.57 -        ins = (InputStream)AccessController.doPrivileged
    3.58 -            (new PrivilegedAction() {
    3.59 -                public Object run() {
    3.60 -                    if (loader == null)
    3.61 -                        return ClassLoader.getSystemResourceAsStream(serName);
    3.62 -                    else
    3.63 -                        return loader.getResourceAsStream(serName);
    3.64 -                }
    3.65 -        });
    3.66 -        if (ins != null) {
    3.67 -            try {
    3.68 -                if (cls == null) {
    3.69 -                    oins = new ObjectInputStream(ins);
    3.70 -                } else {
    3.71 -                    oins = new ObjectInputStreamWithLoader(ins, cls);
    3.72 -                }
    3.73 -                result = oins.readObject();
    3.74 -                serialized = true;
    3.75 -                oins.close();
    3.76 -            } catch (IOException ex) {
    3.77 -                ins.close();
    3.78 -                // Drop through and try opening the class.  But remember
    3.79 -                // the exception in case we can't find the class either.
    3.80 -                serex = ex;
    3.81 -            } catch (ClassNotFoundException ex) {
    3.82 -                ins.close();
    3.83 -                throw ex;
    3.84 -            }
    3.85 -        }
    3.86 -
    3.87 -        if (result == null) {
    3.88 -            // No serialized object, try just instantiating the class
    3.89 -            Class cl;
    3.90 -
    3.91 -            try {
    3.92 -                cl = ClassFinder.findClass(beanName, cls);
    3.93 -            } catch (ClassNotFoundException ex) {
    3.94 -                // There is no appropriate class.  If we earlier tried to
    3.95 -                // deserialize an object and got an IO exception, throw that,
    3.96 -                // otherwise rethrow the ClassNotFoundException.
    3.97 -                if (serex != null) {
    3.98 -                    throw serex;
    3.99 -                }
   3.100 -                throw ex;
   3.101 -            }
   3.102 -
   3.103 -            /*
   3.104 -             * Try to instantiate the class.
   3.105 -             */
   3.106 -
   3.107 -                try {
   3.108 -                result = cl.newInstance();
   3.109 -            } catch (Exception ex) {
   3.110 -                // We have to remap the exception to one in our signature.
   3.111 -                // But we pass extra information in the detail message.
   3.112 -                throw new ClassNotFoundException("" + cl + " : " + ex, ex);
   3.113 -            }
   3.114 -        }
   3.115 -
   3.116 -        if (result != null) {
   3.117 -
   3.118 -            // Ok, if the result is an applet initialize it.
   3.119 -            Iterator<AppletProxy> it = ServiceLoader.load(AppletProxy.class).iterator();
   3.120 -            AppletProxy ap = it.hasNext() ? it.next() : null;
   3.121 -            if (ap != null || !ap.initialize(
   3.122 -                result, initializer, serialized, beanName, beanContext, cls
   3.123 -            )) {
   3.124 -                if (beanContext != null) beanContext.add(result);
   3.125 -            }
   3.126 -        }
   3.127 -
   3.128 -        return result;
   3.129 -    }
   3.130 +        return BeanFactory.instantiate(cls, beanName, beanContext, initializer);
   3.131 +   }
   3.132  
   3.133  
   3.134      /**
   3.135 @@ -261,7 +168,7 @@
   3.136       *
   3.137       * @param bean        Object from which we want to obtain a view.
   3.138       * @param targetType  The type of view we'd like to get.
   3.139 -     *
   3.140 +     * @deprecated Use {@link BeanFactory}
   3.141       */
   3.142      public static Object getInstanceOf(Object bean, Class<?> targetType) {
   3.143          return bean;
   3.144 @@ -276,10 +183,10 @@
   3.145       * @param bean  Bean from which we want to obtain a view.
   3.146       * @param targetType  The type of view we'd like to get.
   3.147       * @return "true" if the given bean supports the given targetType.
   3.148 -     *
   3.149 +     * @deprecated Use {@link BeanFactory#isInstanceOf}
   3.150       */
   3.151      public static boolean isInstanceOf(Object bean, Class<?> targetType) {
   3.152 -        return Introspector.isSubclass(bean.getClass(), targetType);
   3.153 +        return BeanFactory.isInstanceOf(bean, targetType);
   3.154      }
   3.155  
   3.156  
   3.157 @@ -290,10 +197,10 @@
   3.158       *          environment.
   3.159       *
   3.160       * @see DesignMode
   3.161 +     * @deprecated Use {@link BeanFactory}
   3.162       */
   3.163      public static boolean isDesignTime() {
   3.164 -        Object value = AppContext.getAppContext().get(DESIGN_TIME);
   3.165 -        return (value instanceof Boolean) && (Boolean) value;
   3.166 +        return BeanFactory.isDesignTime();
   3.167      }
   3.168  
   3.169      /**
   3.170 @@ -307,11 +214,10 @@
   3.171       *     running as part of a batch job.
   3.172       *
   3.173       * @see Visibility
   3.174 -     *
   3.175 +     * @deprecated Use {@link BeanFactory}
   3.176       */
   3.177      public static boolean isGuiAvailable() {
   3.178 -        Object value = AppContext.getAppContext().get(GUI_AVAILABLE);
   3.179 -        return (value instanceof Boolean) ? (Boolean) value : !GraphicsEnvironment.isHeadless();
   3.180 +        return BeanFactory.isGuiAvailable();
   3.181      }
   3.182  
   3.183      /**
   3.184 @@ -333,11 +239,7 @@
   3.185  
   3.186      public static void setDesignTime(boolean isDesignTime)
   3.187                          throws SecurityException {
   3.188 -        SecurityManager sm = System.getSecurityManager();
   3.189 -        if (sm != null) {
   3.190 -            sm.checkPropertiesAccess();
   3.191 -        }
   3.192 -        AppContext.getAppContext().put(DESIGN_TIME, Boolean.valueOf(isDesignTime));
   3.193 +        BeanFactory.setDesignTime(isDesignTime);
   3.194      }
   3.195  
   3.196      /**
   3.197 @@ -355,49 +257,10 @@
   3.198       *             <code>checkPropertiesAccess</code> method doesn't allow setting
   3.199       *              of system properties.
   3.200       * @see SecurityManager#checkPropertiesAccess
   3.201 +     * @deprecated Use {@link BeanFactory}
   3.202       */
   3.203 -
   3.204      public static void setGuiAvailable(boolean isGuiAvailable)
   3.205                          throws SecurityException {
   3.206 -        SecurityManager sm = System.getSecurityManager();
   3.207 -        if (sm != null) {
   3.208 -            sm.checkPropertiesAccess();
   3.209 -        }
   3.210 -        AppContext.getAppContext().put(GUI_AVAILABLE, Boolean.valueOf(isGuiAvailable));
   3.211 +        BeanFactory.setGuiAvailable(isGuiAvailable);
   3.212      }
   3.213  }
   3.214 -
   3.215 -/**
   3.216 - * This subclass of ObjectInputStream delegates loading of classes to
   3.217 - * an existing ClassLoader.
   3.218 - */
   3.219 -
   3.220 -class ObjectInputStreamWithLoader extends ObjectInputStream
   3.221 -{
   3.222 -    private ClassLoader loader;
   3.223 -
   3.224 -    /**
   3.225 -     * Loader must be non-null;
   3.226 -     */
   3.227 -
   3.228 -    public ObjectInputStreamWithLoader(InputStream in, ClassLoader loader)
   3.229 -            throws IOException, StreamCorruptedException {
   3.230 -
   3.231 -        super(in);
   3.232 -        if (loader == null) {
   3.233 -            throw new IllegalArgumentException("Illegal null argument to ObjectInputStreamWithLoader");
   3.234 -        }
   3.235 -        this.loader = loader;
   3.236 -    }
   3.237 -
   3.238 -    /**
   3.239 -     * Use the given ClassLoader rather than using the system class
   3.240 -     */
   3.241 -    protected Class resolveClass(ObjectStreamClass classDesc)
   3.242 -        throws IOException, ClassNotFoundException {
   3.243 -
   3.244 -        String cname = classDesc.getName();
   3.245 -        return ClassFinder.resolveClass(cname, this.loader);
   3.246 -    }
   3.247 -}
   3.248 -
     4.1 --- a/src/share/classes/java/beans/beancontext/BeanContextSupport.java	Wed Jun 17 14:45:59 2009 +0200
     4.2 +++ b/src/share/classes/java/beans/beancontext/BeanContextSupport.java	Wed Jun 17 15:11:07 2009 +0200
     4.3 @@ -28,7 +28,7 @@
     4.4  import java.awt.Component;
     4.5  import java.awt.Container;
     4.6  
     4.7 -import java.beans.Beans;
     4.8 +import java.beans.BeanFactory;
     4.9  
    4.10  
    4.11  import java.beans.PropertyChangeEvent;
    4.12 @@ -193,7 +193,7 @@
    4.13             throws IOException, ClassNotFoundException {
    4.14          BeanContext bc = getBeanContextPeer();
    4.15  
    4.16 -        return Beans.instantiate(bc.getClass().getClassLoader(), beanName, bc);
    4.17 +        return BeanFactory.instantiate(bc.getClass().getClassLoader(), beanName, bc);
    4.18      }
    4.19  
    4.20      /**