Separatelly compiling Beans and Applet modules. Using 'code injection' to allow Beans class to perform its Applet related functionality if Applet module is around.
1.1 --- a/build.xml Tue Jun 16 15:37:17 2009 +0200
1.2 +++ b/build.xml Tue Jun 16 17:53:32 2009 +0200
1.3 @@ -3,7 +3,7 @@
1.4 <description>Scripts to build JDK Java sources in modularized way</description>
1.5
1.6 <target name="all">
1.7 - <antcall target="extract-base"/>
1.8 + <antcall target="base"/>
1.9 <antcall target="beans"/>
1.10 <antcall target="applet"/>
1.11 </target>
1.12 @@ -20,16 +20,23 @@
1.13 -->
1.14 <selector id="applet">
1.15 <or>
1.16 + <filename name="java/beans/AppletInitializer*"/>
1.17 <filename name="java/applet/**"/>
1.18 <filename name="sun/applet/**"/>
1.19 + <filename name="META-INF/services/sun.beans.AppletProxy"/>
1.20 </or>
1.21 </selector>
1.22 <selector id="beans">
1.23 - <or>
1.24 - <filename name="java/beans/**"/>
1.25 - <filename name="sun/beans/**"/>
1.26 - <filename name="com/sun/beans/**"/>
1.27 - </or>
1.28 + <and>
1.29 + <or>
1.30 + <filename name="java/beans/**"/>
1.31 + <filename name="sun/beans/**"/>
1.32 + <filename name="com/sun/beans/**"/>
1.33 + </or>
1.34 + <none>
1.35 + <selector refid="applet"/>
1.36 + </none>
1.37 + </and>
1.38 </selector>
1.39
1.40 <selector id="corba">
1.41 @@ -52,6 +59,7 @@
1.42 <target name="applet">
1.43 <antcall target="-compile-one-module">
1.44 <param name="module" value="applet"/>
1.45 + <param name="depends" value="beans"/>
1.46 </antcall>
1.47 </target>
1.48 <target name="beans">
1.49 @@ -65,7 +73,7 @@
1.50 the modularization by extracting the base module from an existing
1.51 classes
1.52 -->
1.53 - <target name="extract-base">
1.54 + <target name="base">
1.55 <property name="rt.jar" location="${java.home}/lib/rt.jar"/>
1.56 <fail message="Cannot find rt.jar, specify with -Drt.jar=...">
1.57 <condition><not><available file="${rt.jar}"/></not></condition>
1.58 @@ -73,7 +81,7 @@
1.59
1.60 <mkdir dir="${build.dir}/rt"/>
1.61 <unzip src="${rt.jar}" dest="${build.dir}/rt"/>
1.62 - <jar file="${build.dir}/base.jar">
1.63 + <jar file="${build.dir}/base.jar" compress="false">
1.64 <fileset dir="${build.dir}/rt">
1.65 <selector refid="base"/>
1.66 </fileset>
1.67 @@ -83,11 +91,37 @@
1.68 <!-- shared routine to compile one of the modules -->
1.69 <target name="-compile-one-module">
1.70 <mkdir dir="${build.dir}/classes/${module}"/>
1.71 - <javac bootclasspath="${build.dir}/base.jar" sourcepath="" destdir="${build.dir}/classes/${module}">
1.72 + <pathconvert pathsep="," property="module.cp">
1.73 + <path path="${depends}"/>
1.74 + <mapper type="regexp" from=".*[/\\]([^/\\]*)" to="${build.dir}/\1.jar"/>
1.75 + </pathconvert>
1.76 + <javac
1.77 + bootclasspath="${build.dir}/base.jar"
1.78 + sourcepath=""
1.79 + destdir="${build.dir}/classes/${module}"
1.80 + classpath="${module.cp}"
1.81 + includejavaruntime="false"
1.82 + includeantruntime="false"
1.83 + >
1.84 <src refid="src.path"/>
1.85 <selector refid="${module}"/>
1.86 </javac>
1.87 - <jar basedir="${build.dir}/classes/${module}" destfile="${build.dir}/${module}.jar"/>
1.88 + <copy todir="${build.dir}/classes/${module}">
1.89 + <fileset dir="src/share/classes">
1.90 + <and>
1.91 + <selector refid="${module}"/>
1.92 + <not>
1.93 + <filename name="**/*.java"/>
1.94 + </not>
1.95 + </and>
1.96 + </fileset>
1.97 + </copy>
1.98 +
1.99 + <jar
1.100 + basedir="${build.dir}/classes/${module}"
1.101 + destfile="${build.dir}/${module}.jar"
1.102 + compress="false"
1.103 + />
1.104 </target>
1.105
1.106 <!-- clean everything -->
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/src/share/classes/META-INF/services/sun.beans.AppletProxy Tue Jun 16 17:53:32 2009 +0200
2.3 @@ -0,0 +1,1 @@
2.4 +sun.applet.BeansBridge
3.1 --- a/src/share/classes/java/beans/Beans.java Tue Jun 16 15:37:17 2009 +0200
3.2 +++ b/src/share/classes/java/beans/Beans.java Tue Jun 16 17:53:32 2009 +0200
3.3 @@ -27,13 +27,7 @@
3.4
3.5 import com.sun.beans.finder.ClassFinder;
3.6
3.7 -import java.applet.Applet;
3.8 -import java.applet.AppletContext;
3.9 -import java.applet.AppletStub;
3.10 -import java.applet.AudioClip;
3.11 -
3.12 import java.awt.GraphicsEnvironment;
3.13 -import java.awt.Image;
3.14
3.15 import java.beans.beancontext.BeanContext;
3.16
3.17 @@ -43,17 +37,15 @@
3.18 import java.io.ObjectStreamClass;
3.19 import java.io.StreamCorruptedException;
3.20
3.21 -import java.net.URL;
3.22
3.23 import java.security.AccessController;
3.24 import java.security.PrivilegedAction;
3.25
3.26 -import java.util.Enumeration;
3.27 -import java.util.Hashtable;
3.28 import java.util.Iterator;
3.29 -import java.util.Vector;
3.30 +import java.util.ServiceLoader;
3.31
3.32 import sun.awt.AppContext;
3.33 +import sun.beans.AppletProxy;
3.34
3.35 /**
3.36 * This class provides some general purpose beans control methods.
3.37 @@ -155,8 +147,14 @@
3.38 * @exception IOException if an I/O error occurs.
3.39 */
3.40
3.41 - public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext, AppletInitializer initializer)
3.42 - throws IOException, ClassNotFoundException {
3.43 + public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext,
3.44 + /** TBD: Oops , this is bad. The AppletInitializer is used from
3.45 + * public API. I have not noticed that sooner. Opps.
3.46 + AppletInitializer initializer
3.47 + * meanwhile turning into object, but this cannot be final solution:
3.48 + */
3.49 + Object initializer
3.50 + ) throws IOException, ClassNotFoundException {
3.51
3.52 InputStream ins;
3.53 ObjectInputStream oins = null;
3.54 @@ -231,7 +229,7 @@
3.55 * Try to instantiate the class.
3.56 */
3.57
3.58 - try {
3.59 + try {
3.60 result = cl.newInstance();
3.61 } catch (Exception ex) {
3.62 // We have to remap the exception to one in our signature.
3.63 @@ -243,108 +241,13 @@
3.64 if (result != null) {
3.65
3.66 // Ok, if the result is an applet initialize it.
3.67 -
3.68 - AppletStub stub = null;
3.69 -
3.70 - if (result instanceof Applet) {
3.71 - Applet applet = (Applet) result;
3.72 - boolean needDummies = initializer == null;
3.73 -
3.74 - if (needDummies) {
3.75 -
3.76 - // Figure our the codebase and docbase URLs. We do this
3.77 - // by locating the URL for a known resource, and then
3.78 - // massaging the URL.
3.79 -
3.80 - // First find the "resource name" corresponding to the bean
3.81 - // itself. So a serialzied bean "a.b.c" would imply a
3.82 - // resource name of "a/b/c.ser" and a classname of "x.y"
3.83 - // would imply a resource name of "x/y.class".
3.84 -
3.85 - final String resourceName;
3.86 -
3.87 - if (serialized) {
3.88 - // Serialized bean
3.89 - resourceName = beanName.replace('.','/').concat(".ser");
3.90 - } else {
3.91 - // Regular class
3.92 - resourceName = beanName.replace('.','/').concat(".class");
3.93 - }
3.94 -
3.95 - URL objectUrl = null;
3.96 - URL codeBase = null;
3.97 - URL docBase = null;
3.98 -
3.99 - // Now get the URL correponding to the resource name.
3.100 -
3.101 - final ClassLoader cloader = cls;
3.102 - objectUrl = (URL)
3.103 - AccessController.doPrivileged
3.104 - (new PrivilegedAction() {
3.105 - public Object run() {
3.106 - if (cloader == null)
3.107 - return ClassLoader.getSystemResource
3.108 - (resourceName);
3.109 - else
3.110 - return cloader.getResource(resourceName);
3.111 - }
3.112 - });
3.113 -
3.114 - // If we found a URL, we try to locate the docbase by taking
3.115 - // of the final path name component, and the code base by taking
3.116 - // of the complete resourceName.
3.117 - // So if we had a resourceName of "a/b/c.class" and we got an
3.118 - // objectURL of "file://bert/classes/a/b/c.class" then we would
3.119 - // want to set the codebase to "file://bert/classes/" and the
3.120 - // docbase to "file://bert/classes/a/b/"
3.121 -
3.122 - if (objectUrl != null) {
3.123 - String s = objectUrl.toExternalForm();
3.124 -
3.125 - if (s.endsWith(resourceName)) {
3.126 - int ix = s.length() - resourceName.length();
3.127 - codeBase = new URL(s.substring(0,ix));
3.128 - docBase = codeBase;
3.129 -
3.130 - ix = s.lastIndexOf('/');
3.131 -
3.132 - if (ix >= 0) {
3.133 - docBase = new URL(s.substring(0,ix+1));
3.134 - }
3.135 - }
3.136 - }
3.137 -
3.138 - // Setup a default context and stub.
3.139 - BeansAppletContext context = new BeansAppletContext(applet);
3.140 -
3.141 - stub = (AppletStub)new BeansAppletStub(applet, context, codeBase, docBase);
3.142 - applet.setStub(stub);
3.143 - } else {
3.144 - initializer.initialize(applet, beanContext);
3.145 - }
3.146 -
3.147 - // now, if there is a BeanContext, add the bean, if applicable.
3.148 -
3.149 - if (beanContext != null) {
3.150 - beanContext.add(result);
3.151 - }
3.152 -
3.153 - // If it was deserialized then it was already init-ed.
3.154 - // Otherwise we need to initialize it.
3.155 -
3.156 - if (!serialized) {
3.157 - // We need to set a reasonable initial size, as many
3.158 - // applets are unhappy if they are started without
3.159 - // having been explicitly sized.
3.160 - applet.setSize(100,100);
3.161 - applet.init();
3.162 - }
3.163 -
3.164 - if (needDummies) {
3.165 - ((BeansAppletStub)stub).active = true;
3.166 - } else initializer.activate(applet);
3.167 -
3.168 - } else if (beanContext != null) beanContext.add(result);
3.169 + Iterator<AppletProxy> it = ServiceLoader.load(AppletProxy.class).iterator();
3.170 + AppletProxy ap = it.hasNext() ? it.next() : null;
3.171 + if (ap != null || !ap.initialize(
3.172 + result, initializer, serialized, beanName, beanContext, cls
3.173 + )) {
3.174 + if (beanContext != null) beanContext.add(result);
3.175 + }
3.176 }
3.177
3.178 return result;
3.179 @@ -504,134 +407,3 @@
3.180 }
3.181 }
3.182
3.183 -/**
3.184 - * Package private support class. This provides a default AppletContext
3.185 - * for beans which are applets.
3.186 - */
3.187 -
3.188 -class BeansAppletContext implements AppletContext {
3.189 - Applet target;
3.190 - Hashtable imageCache = new Hashtable();
3.191 -
3.192 - BeansAppletContext(Applet target) {
3.193 - this.target = target;
3.194 - }
3.195 -
3.196 - public AudioClip getAudioClip(URL url) {
3.197 - // We don't currently support audio clips in the Beans.instantiate
3.198 - // applet context, unless by some luck there exists a URL content
3.199 - // class that can generate an AudioClip from the audio URL.
3.200 - try {
3.201 - return (AudioClip) url.getContent();
3.202 - } catch (Exception ex) {
3.203 - return null;
3.204 - }
3.205 - }
3.206 -
3.207 - public synchronized Image getImage(URL url) {
3.208 - Object o = imageCache.get(url);
3.209 - if (o != null) {
3.210 - return (Image)o;
3.211 - }
3.212 - try {
3.213 - o = url.getContent();
3.214 - if (o == null) {
3.215 - return null;
3.216 - }
3.217 - if (o instanceof Image) {
3.218 - imageCache.put(url, o);
3.219 - return (Image) o;
3.220 - }
3.221 - // Otherwise it must be an ImageProducer.
3.222 - Image img = target.createImage((java.awt.image.ImageProducer)o);
3.223 - imageCache.put(url, img);
3.224 - return img;
3.225 -
3.226 - } catch (Exception ex) {
3.227 - return null;
3.228 - }
3.229 - }
3.230 -
3.231 - public Applet getApplet(String name) {
3.232 - return null;
3.233 - }
3.234 -
3.235 - public Enumeration getApplets() {
3.236 - Vector applets = new Vector();
3.237 - applets.addElement(target);
3.238 - return applets.elements();
3.239 - }
3.240 -
3.241 - public void showDocument(URL url) {
3.242 - // We do nothing.
3.243 - }
3.244 -
3.245 - public void showDocument(URL url, String target) {
3.246 - // We do nothing.
3.247 - }
3.248 -
3.249 - public void showStatus(String status) {
3.250 - // We do nothing.
3.251 - }
3.252 -
3.253 - public void setStream(String key, InputStream stream)throws IOException{
3.254 - // We do nothing.
3.255 - }
3.256 -
3.257 - public InputStream getStream(String key){
3.258 - // We do nothing.
3.259 - return null;
3.260 - }
3.261 -
3.262 - public Iterator getStreamKeys(){
3.263 - // We do nothing.
3.264 - return null;
3.265 - }
3.266 -}
3.267 -
3.268 -/**
3.269 - * Package private support class. This provides an AppletStub
3.270 - * for beans which are applets.
3.271 - */
3.272 -class BeansAppletStub implements AppletStub {
3.273 - transient boolean active;
3.274 - transient Applet target;
3.275 - transient AppletContext context;
3.276 - transient URL codeBase;
3.277 - transient URL docBase;
3.278 -
3.279 - BeansAppletStub(Applet target,
3.280 - AppletContext context, URL codeBase,
3.281 - URL docBase) {
3.282 - this.target = target;
3.283 - this.context = context;
3.284 - this.codeBase = codeBase;
3.285 - this.docBase = docBase;
3.286 - }
3.287 -
3.288 - public boolean isActive() {
3.289 - return active;
3.290 - }
3.291 -
3.292 - public URL getDocumentBase() {
3.293 - // use the root directory of the applet's class-loader
3.294 - return docBase;
3.295 - }
3.296 -
3.297 - public URL getCodeBase() {
3.298 - // use the directory where we found the class or serialized object.
3.299 - return codeBase;
3.300 - }
3.301 -
3.302 - public String getParameter(String name) {
3.303 - return null;
3.304 - }
3.305 -
3.306 - public AppletContext getAppletContext() {
3.307 - return context;
3.308 - }
3.309 -
3.310 - public void appletResize(int width, int height) {
3.311 - // we do nothing.
3.312 - }
3.313 -}
4.1 --- a/src/share/classes/java/beans/beancontext/BeanContextSupport.java Tue Jun 16 15:37:17 2009 +0200
4.2 +++ b/src/share/classes/java/beans/beancontext/BeanContextSupport.java Tue Jun 16 17:53:32 2009 +0200
4.3 @@ -29,16 +29,12 @@
4.4 import java.awt.Container;
4.5
4.6 import java.beans.Beans;
4.7 -import java.beans.AppletInitializer;
4.8
4.9 -import java.beans.DesignMode;
4.10
4.11 import java.beans.PropertyChangeEvent;
4.12 import java.beans.PropertyChangeListener;
4.13 -import java.beans.PropertyChangeSupport;
4.14
4.15 import java.beans.VetoableChangeListener;
4.16 -import java.beans.VetoableChangeSupport;
4.17 import java.beans.PropertyVetoException;
4.18
4.19 import java.beans.Visibility;
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/src/share/classes/sun/applet/BeansBridge.java Tue Jun 16 17:53:32 2009 +0200
5.3 @@ -0,0 +1,298 @@
5.4 +/*
5.5 + * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5.7 + *
5.8 + * This code is free software; you can redistribute it and/or modify it
5.9 + * under the terms of the GNU General Public License version 2 only, as
5.10 + * published by the Free Software Foundation. Sun designates this
5.11 + * particular file as subject to the "Classpath" exception as provided
5.12 + * by Sun in the LICENSE file that accompanied this code.
5.13 + *
5.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
5.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5.17 + * version 2 for more details (a copy is included in the LICENSE file that
5.18 + * accompanied this code).
5.19 + *
5.20 + * You should have received a copy of the GNU General Public License version
5.21 + * 2 along with this work; if not, write to the Free Software Foundation,
5.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5.23 + *
5.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
5.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
5.26 + * have any questions.
5.27 + */
5.28 +
5.29 +package sun.applet;
5.30 +
5.31 +import java.applet.Applet;
5.32 +import java.applet.AppletContext;
5.33 +import java.applet.AppletStub;
5.34 +import java.applet.AudioClip;
5.35 +import java.awt.Image;
5.36 +import java.beans.AppletInitializer;
5.37 +import java.beans.beancontext.BeanContext;
5.38 +import java.io.IOException;
5.39 +import java.io.InputStream;
5.40 +import java.net.MalformedURLException;
5.41 +import java.net.URL;
5.42 +import java.security.AccessController;
5.43 +import java.security.PrivilegedAction;
5.44 +import java.util.Enumeration;
5.45 +import java.util.Hashtable;
5.46 +import java.util.Iterator;
5.47 +import java.util.Vector;
5.48 +import sun.beans.AppletProxy;
5.49 +
5.50 +/**
5.51 + * Implementaiton of the bridge between
5.52 + * java.beans module and java.applet module.
5.53 + *
5.54 + * @author Jaroslav Tulach
5.55 + */
5.56 +
5.57 +public class BeansBridge extends AppletProxy {
5.58 + public boolean initialize(
5.59 + Object result, Object init, boolean serialized,
5.60 + String beanName, BeanContext beanContext, ClassLoader cls
5.61 + ) throws MalformedURLException {
5.62 + if (!(result instanceof Applet)) {
5.63 + return false;
5.64 + }
5.65 + AppletInitializer initializer = (AppletInitializer)init;
5.66 +
5.67 + AppletStub stub = null;
5.68 + Applet applet = (Applet) result;
5.69 + boolean needDummies = initializer == null;
5.70 +
5.71 + if (needDummies) {
5.72 +
5.73 + // Figure our the codebase and docbase URLs. We do this
5.74 + // by locating the URL for a known resource, and then
5.75 + // massaging the URL.
5.76 +
5.77 + // First find the "resource name" corresponding to the bean
5.78 + // itself. So a serialzied bean "a.b.c" would imply a
5.79 + // resource name of "a/b/c.ser" and a classname of "x.y"
5.80 + // would imply a resource name of "x/y.class".
5.81 +
5.82 + final String resourceName;
5.83 +
5.84 + if (serialized) {
5.85 + // Serialized bean
5.86 + resourceName = beanName.replace('.', '/').concat(".ser");
5.87 + } else {
5.88 + // Regular class
5.89 + resourceName = beanName.replace('.', '/').concat(".class");
5.90 + }
5.91 +
5.92 + URL objectUrl = null;
5.93 + URL codeBase = null;
5.94 + URL docBase = null;
5.95 +
5.96 + // Now get the URL correponding to the resource name.
5.97 +
5.98 + final ClassLoader cloader = cls;
5.99 + objectUrl = (URL) AccessController.doPrivileged(new PrivilegedAction() {
5.100 +
5.101 + public Object run() {
5.102 + if (cloader == null) {
5.103 + return ClassLoader.getSystemResource(resourceName);
5.104 + } else {
5.105 + return cloader.getResource(resourceName);
5.106 + }
5.107 + }
5.108 + });
5.109 +
5.110 + // If we found a URL, we try to locate the docbase by taking
5.111 + // of the final path name component, and the code base by taking
5.112 + // of the complete resourceName.
5.113 + // So if we had a resourceName of "a/b/c.class" and we got an
5.114 + // objectURL of "file://bert/classes/a/b/c.class" then we would
5.115 + // want to set the codebase to "file://bert/classes/" and the
5.116 + // docbase to "file://bert/classes/a/b/"
5.117 +
5.118 + if (objectUrl != null) {
5.119 + String s = objectUrl.toExternalForm();
5.120 +
5.121 + if (s.endsWith(resourceName)) {
5.122 + int ix = s.length() - resourceName.length();
5.123 + codeBase = new URL(s.substring(0, ix));
5.124 + docBase = codeBase;
5.125 +
5.126 + ix = s.lastIndexOf('/');
5.127 +
5.128 + if (ix >= 0) {
5.129 + docBase = new URL(s.substring(0, ix + 1));
5.130 + }
5.131 + }
5.132 + }
5.133 +
5.134 + // Setup a default context and stub.
5.135 + BeansAppletContext context = new BeansAppletContext(applet);
5.136 +
5.137 + stub = (AppletStub) new BeansAppletStub(applet, context, codeBase, docBase);
5.138 + applet.setStub(stub);
5.139 + } else {
5.140 + initializer.initialize(applet, beanContext);
5.141 + }
5.142 +
5.143 + // now, if there is a BeanContext, add the bean, if applicable.
5.144 +
5.145 + if (beanContext != null) {
5.146 + beanContext.add(result);
5.147 + }
5.148 +
5.149 + // If it was deserialized then it was already init-ed.
5.150 + // Otherwise we need to initialize it.
5.151 +
5.152 + if (!serialized) {
5.153 + // We need to set a reasonable initial size, as many
5.154 + // applets are unhappy if they are started without
5.155 + // having been explicitly sized.
5.156 + applet.setSize(100, 100);
5.157 + applet.init();
5.158 + }
5.159 +
5.160 + if (needDummies) {
5.161 + ((BeansAppletStub) stub).active = true;
5.162 + } else {
5.163 + initializer.activate(applet);
5.164 + }
5.165 +
5.166 + return true;
5.167 + }
5.168 +}
5.169 +
5.170 +
5.171 +/**
5.172 + * Package private support class. This provides a default AppletContext
5.173 + * for beans which are applets.
5.174 + */
5.175 +
5.176 +class BeansAppletContext implements AppletContext {
5.177 + Applet target;
5.178 + Hashtable imageCache = new Hashtable();
5.179 +
5.180 + BeansAppletContext(Applet target) {
5.181 + this.target = target;
5.182 + }
5.183 +
5.184 + public AudioClip getAudioClip(URL url) {
5.185 + // We don't currently support audio clips in the Beans.instantiate
5.186 + // applet context, unless by some luck there exists a URL content
5.187 + // class that can generate an AudioClip from the audio URL.
5.188 + try {
5.189 + return (AudioClip) url.getContent();
5.190 + } catch (Exception ex) {
5.191 + return null;
5.192 + }
5.193 + }
5.194 +
5.195 + public synchronized Image getImage(URL url) {
5.196 + Object o = imageCache.get(url);
5.197 + if (o != null) {
5.198 + return (Image)o;
5.199 + }
5.200 + try {
5.201 + o = url.getContent();
5.202 + if (o == null) {
5.203 + return null;
5.204 + }
5.205 + if (o instanceof Image) {
5.206 + imageCache.put(url, o);
5.207 + return (Image) o;
5.208 + }
5.209 + // Otherwise it must be an ImageProducer.
5.210 + Image img = target.createImage((java.awt.image.ImageProducer)o);
5.211 + imageCache.put(url, img);
5.212 + return img;
5.213 +
5.214 + } catch (Exception ex) {
5.215 + return null;
5.216 + }
5.217 + }
5.218 +
5.219 + public Applet getApplet(String name) {
5.220 + return null;
5.221 + }
5.222 +
5.223 + public Enumeration getApplets() {
5.224 + Vector applets = new Vector();
5.225 + applets.addElement(target);
5.226 + return applets.elements();
5.227 + }
5.228 +
5.229 + public void showDocument(URL url) {
5.230 + // We do nothing.
5.231 + }
5.232 +
5.233 + public void showDocument(URL url, String target) {
5.234 + // We do nothing.
5.235 + }
5.236 +
5.237 + public void showStatus(String status) {
5.238 + // We do nothing.
5.239 + }
5.240 +
5.241 + public void setStream(String key, InputStream stream)throws IOException{
5.242 + // We do nothing.
5.243 + }
5.244 +
5.245 + public InputStream getStream(String key){
5.246 + // We do nothing.
5.247 + return null;
5.248 + }
5.249 +
5.250 + public Iterator getStreamKeys(){
5.251 + // We do nothing.
5.252 + return null;
5.253 + }
5.254 +}
5.255 +
5.256 +/**
5.257 + * Package private support class. This provides an AppletStub
5.258 + * for beans which are applets.
5.259 + */
5.260 +class BeansAppletStub implements AppletStub {
5.261 + transient boolean active;
5.262 + transient Applet target;
5.263 + transient AppletContext context;
5.264 + transient URL codeBase;
5.265 + transient URL docBase;
5.266 +
5.267 + BeansAppletStub(Applet target,
5.268 + AppletContext context, URL codeBase,
5.269 + URL docBase) {
5.270 + this.target = target;
5.271 + this.context = context;
5.272 + this.codeBase = codeBase;
5.273 + this.docBase = docBase;
5.274 + }
5.275 +
5.276 + public boolean isActive() {
5.277 + return active;
5.278 + }
5.279 +
5.280 + public URL getDocumentBase() {
5.281 + // use the root directory of the applet's class-loader
5.282 + return docBase;
5.283 + }
5.284 +
5.285 + public URL getCodeBase() {
5.286 + // use the directory where we found the class or serialized object.
5.287 + return codeBase;
5.288 + }
5.289 +
5.290 + public String getParameter(String name) {
5.291 + return null;
5.292 + }
5.293 +
5.294 + public AppletContext getAppletContext() {
5.295 + return context;
5.296 + }
5.297 +
5.298 + public void appletResize(int width, int height) {
5.299 + // we do nothing.
5.300 + }
5.301 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/src/share/classes/sun/beans/AppletProxy.java Tue Jun 16 17:53:32 2009 +0200
6.3 @@ -0,0 +1,42 @@
6.4 +/*
6.5 + * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6.7 + *
6.8 + * This code is free software; you can redistribute it and/or modify it
6.9 + * under the terms of the GNU General Public License version 2 only, as
6.10 + * published by the Free Software Foundation. Sun designates this
6.11 + * particular file as subject to the "Classpath" exception as provided
6.12 + * by Sun in the LICENSE file that accompanied this code.
6.13 + *
6.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
6.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6.17 + * version 2 for more details (a copy is included in the LICENSE file that
6.18 + * accompanied this code).
6.19 + *
6.20 + * You should have received a copy of the GNU General Public License version
6.21 + * 2 along with this work; if not, write to the Free Software Foundation,
6.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6.23 + *
6.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
6.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
6.26 + * have any questions.
6.27 + */
6.28 +
6.29 +package sun.beans;
6.30 +
6.31 +import java.beans.beancontext.BeanContext;
6.32 +import java.net.MalformedURLException;
6.33 +
6.34 +
6.35 +/**
6.36 + * Bridge between java.beans module and java.applet module.
6.37 + * @author Jaroslav Tulach
6.38 + */
6.39 +
6.40 +public abstract class AppletProxy {
6.41 + public abstract boolean initialize(
6.42 + Object result, Object init, boolean serialized,
6.43 + String beanName, BeanContext beanContext, ClassLoader cls
6.44 + ) throws MalformedURLException;
6.45 +}