Date: Sat, 20 Dec 1997 04:30:26 +0300 To: chris@marrin.com From: Dmitri Kondratiev Subject: Browser bean (was: Re: Updated EAI Proposal available) Cc: vrml-eai@vrml.org Sender: vrml-eai-approval@vrml.org Chris Marrin wrote: >As far as JavaBeans go, I think this layer atop the EAI, rather than >being integrated into it. > Why you think that should be done one level up ? What is so special about beans ? In fact, beans are Java classes that follow property access patterns and conform to particular event model. Thinking about beans as "visual components only" is a sad and wide-spread misunderstanding :.( Let's assume for a moment that Browser is a bean. Communication with it becomes much easier both in one address space and from "external environment". To say more this communication becomes *uniform*. Besides, which is even more important, being a bean allows to be manipulated in bean composition frameworks, such as Visual Java Script, which in turn implies easy integration in HTML docs. Not bad, I think... Communication is straightforward : Those objects interested in Browser object are its "listeners". Browser fires BrowserEvent-s. I hope that following below code snippet will illustrate the main idea well enough. //Base event class : vrml.external.BrowserEvent extends java.util.EventObject; //The following events may be defined : // browser fires this event upon completion of loading of the base file. vrml.external.InitializeEvent extends BrowserEvent; // browser fires this event when the scene is about to be unloaded. vrml.external.ShutdownEvent extends BrowserEvent; // browser fires this event when world was just replaced vrml.external.NewWorldEvent extends BrowserEvent; // browser fires this event when event group starts vrml.external.BeginUpdateEvent extends BrowserEvent; // browser fires this event when event group ends vrml.external.EndUpdateEvent extends BrowserEvent; /** Browser also fires an event whenever it is generated from eventOut requested by some listener. From this EventOutChanged event listener should be able to find out the DEF-ed node name/identifier that fired this event. */ vrml.external.EventOutChanged extends BrowserEvent; /*** Listening for events ***/ //Listener interface public interface vrml.external.BrowserEventListener { public void handleBrowserEvents(BrowserEvent evt); } //Somebody interested in EAI Browser : class Foo implements vrml.external.BrowserEventListener { // register with browser public Foo() { Browser b = new Browser(..); b.addBrowserEventListener(this); } public void handleBrowserEvents(BrowserEvent evt) { if (evt instanceof InitializeEvent ) { //....// } else if (evt instanceof ShutdownEvent { //....// } else if (evt instanceof NewWorldEvent { //....// } else if (evt instanceof BeginUpdateEvent { //....// } ... else if (evt instanceof EventOutChanged { String defName = evt.getNodeDefName(); ... } } } Being based on "message passing" instead of "message call" mechanism, Bean event model has one great advantage : One can use it both for components in the same address space and in different spaces connected by some protocol. Note, that going for bean model, makes Browser interface *really independent* from protocol that implements it while remaining *well defined*. Dima ----------------- Dmitri Kondratiev dima@paragraph.com 102401.2457@compuserve.com http://www.geocities.com/SiliconValley/Lakes/3767/ tel: 07-095-464-9241 ------------------------------------------------------------------------ for list subscription instructions, send email to vrml-eai-request@vrml.org with text "info"