[Embedlets-dev] Re: JAPL Events
Status: Alpha
Brought to you by:
tkosan
|
From: Andrzej J. T. <an...@ch...> - 2003-03-23 21:01:03
|
Ted: > My first thought was to use a JaplEventListener interface that Embedlets > can implement and then the Embedlet instance in question can register as > an event listener to the JAPL device it has a reference to. But of course the > state of an Embedlet is held within a ComponentContext object so how does one > register a ComponentContext object instance as a listener to JAPL events? How are the JAPL events triggered? Interrupt? Polled? If polled, then you can create a small polling embedlet that polls the JAPL device (using the Timer Service) on a regular basis, and then posts a Robot Embedlet Event when something interesting is detected. If Interrupt driven, one way would be to write a Robot JAPL driver routine that implements the EventProducer interface, and have the Robot JAPL driver get/store a reference to the Event Service (there is a static method you can use in Container to get the EventService instance). The driver would then post a suitable Robot Embedlet event (using the EventService to send() the event) when the interrupt triggers. Downstream devices/components should not know what upstream components are "listening" for their events typically, since that produces too much coupling. ComponentContext objects are passive data holders ONLY! They should never be registered as a callback object, since that would imply that they would have to have application logic in them. I would advise against having the JAPL device issue a callback against an Embedlet instance.....since that again couples the two layers a bit too closely. The Event Service is the preferred way to interface two layers together (per the above suggestions). Send an Event, Ted! ;-) Andrzej Jan Taramina Chaeron Corporation: Enterprise System Solutions http://www.chaeron.com |