[Embedlets-dev] JAPL callback experiment update
Status: Alpha
Brought to you by:
tkosan
|
From: Ted K. <tk...@ya...> - 2003-03-27 06:48:34
|
I have continued experimenting with having a JAPL peripheral use a simple
callback to send information asynchronously back to the Embedlet that has a
reference to it and here is what I have come up with so far.
1) Have the Embedlet use a class variable to hold a reference to each JAPL
peripheral that it is interested in.
2) Have all JAPL event listeners implement the following interface if they are
interested in receiving JAPL events:
package org.japl;
public interface JaplEventListener
{
void receiveJaplEvent(Object japlEvent);
}//end method
3) Create an inner class inside of the Embedlet called JaplListener and have
it implement the JaplEventListener interface. Have the Embedlet hold a static
singleton reference to this JaplListener.
4) Place public static setters and getters inside of the Embedlet so that the
JAPL peripherals can be set and obtained and also so that the JaplListener
singleton instance can be obtained.
The main difficulty that I have encountered so far is when to pass in the
instances of the JAPL peripherals to the Embedlet (and also getting a reference
to the Embedlets JaplListener singleton so that it can be placed in the JAPL
peripheral's listener list). Right now I am kind of hacking this part together
by doing this after the outpost container has been started but this is
definitely risky and a better technique must be available.
Anyway, for the most part, the above configuration seems to work well and I
currently have a JaplScanner peripheral sending events into a ScannerEmbedlet
using a callback and then the ScannerEmbedlet controls the firing of the tank
cannon using a JaplCannon peripheral (right now the SittingDuck test robot that
comes with RoboCode is getting the snot knocked out of it by my EmbedletBot!).
My next step is to have the ScannerEmbedlet do some processing on the JAPL
robot scanned event and then to publish this information into the container. A
FireControllerEmbedlet will then be created which will subscribe to this event
along with a ManeuversEmbedlet. More Embedlets should follow from here...
RoboCode is certainly turning out to be a great way to exercise the Embedlet
Container in an intense, easily-deployed-to realtime environment.
Ted
PS, after looking through the Outpost code is it clear that each Embedlet
receives its own conventional Embedlet instance along with its own
ComponentContext object.
__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com
|