Browse Prior Art Database

Sequencing Event Handlers in Java

IP.com Disclosure Number: IPCOM000123930D
Original Publication Date: 1999-Jul-01
Included in the Prior Art Database: 2005-Apr-05
Document File: 1 page(s) / 34K

Publishing Venue

IBM

Related People

Lee, JR: AUTHOR [+2]

Abstract

The current implementation of Java* allows for registering Event Listeners on Event Handlers, but does not guarantee the order in which registered Listeners are called by the Handler. This can be an issue if Listeners are modifying the event as it is processed because different Listeners may react differently to a modified event than they would to an unmodified event. A method is needed that insures that handlers are in fact called in a specified order.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 89% of the total text.

Sequencing Event Handlers in Java

   The current implementation of Java* allows for registering
Event Listeners on Event Handlers, but does not guarantee the order
in which registered Listeners are called by the Handler.  This can be
an issue if Listeners are modifying the event as it is processed
because different Listeners may react differently to a modified event
than they would to an unmodified event.  A method is needed that
insures that handlers are in fact called in a specified order.

   The solution is traditionally done by subclassing the
Event Handler class, and overriding the method code which calls the
Listeners, and if needed the methods which add and remove Listeners
as well.  This has the downside of requiring access to Event Handler
class source code itself and assumes the class can in fact be
subclassed, e.g. that it is not in fact a final class.  It also may
require changes to the subclass every time the source class of the
Event Handler code changes.  The solution we are advocating is to
create a custom Event Listener class that is registered with the
Event Handler in place of multiple Listener classes being registered.
This custom Listener would also be an Event Handler, which is used to
sequence and forward the Events to the other Listeners.  The
Listeners which normally would have been added directly to the Event
Handler would instead be added as Listeners to this custom
Listener/Handler class.  Said another way, the custom Event
Listener/Seq...