CONTENTS | PREV | NEXT | Extensible Runtime Containment and Services Protocol for JavaBeans |
The current implementation of java.beans.instantiate() contains minimal support for instantiating JavaBeans that are also Applets. In particular, this method will currently construct an AppletContext and AppletStub for the newly instantiated JavaBean, set the stub on the newly instantiated Applet, and init() the Applet if it has not already been invoked.Unfortunately this does not provide sufficient support in order to allow most Applets to be fully functional, since the AppletContext and AppletStub created by java.beans.instantiate(), are no-ops. This is a direct consequence of the lack of sufficient specification of how to construct AppletContext and AppletStub implementations in the existing Applet API's. Furthermore, even if such specifications existed we would require an API that propagated a number of Applet attributes such as its Codebase, Parameters, AppletContext, and Documentbase into java.beans.instantiate() in order for it to subsequently instantiate the appropriately initialized objects.
Since key to supporting fully functional Applets is to provide them with fully functional AppletContext and AppletStub instances, the design goal is to provide a mechanism to provide this state to instantiate() so that it may carry out the appropriate initialization and binding1, therefore the proposed interface is:
public static Object instantiate(ClassLoader cl, String beanName, BeanContext bCtxt, AppletInitializer ai ); public interface AppletInitializer { void initialize Applet(newApplet, BeanContext bCtxt); void activate Applet(newApplet); }
If the newly instantiated JavaBean component is an instance of java.applet.Applet then the new constructed Applet, (Bean) will be passed to the AppletInitializer via a call to initialize().Compliant implementations of AppletInitializer.initialize() shall:
- Associate the newly instantiated Applet with the appropriate AppletContext.
- Instantiate an AppletStub() and associate that AppletStub with the Applet via an invocation of setStub().
- If BeanContext parameter is null, then it shall associate the Applet with its appropriate Container by adding that Applet to its Container via an invocation of add(). If the BeanContext parameter is non-null, then it is the responsibility of the BeanContext to associate the Applet with its Container during the subsequent invocation of its addChildren() method.
Compliant implementations of AppletInitializer.activate() shall mark the Applet as active, and may optionally also invoke the Applet's start() method.Note that if the newly instantiated JavaBean is not an instance of Applet, then the AppletInitializer interface is ignored.