The next handler that you create, CalculationResultsHandler,
creates a pie chart to illustrate details that are issued by the previously
created logic, MortgageCalculatorHandler.
The code that acts as an intermediary between the two
handlers is an Infobus, which is an EGL library in the com.ibm.egl.rui project.
The
Infobus works as follows:
- A handler such as CalculationResultsHandler subscribes to an event
of a specified name. At the time of subscription, the handler also
gives the name of a function that will receive data when the specified
event occurs. As a result of this subscription, the Infobus registers
the function, maintaining the detail necessary to invoke the function
later.
- At the right moment, the same or a different handler publishes
the event. This handler specifies both the event name and event-specific
data and directs the Infobus to invoke the registered function.
You begin this lesson by dealing with the second of those
two steps. You update the previously written MortgageCalculatorHandler
handler to invoke the Infobus publish function when
a new calculation is returned from the remote service. Then, you ensure
that the CalculationResultsHandler handler has subscribed to the event.
The
publish-and-subscribe makes possible the pie-chart display.