Why do most Xbeans only support a single listener?

Bruce Martin

The DOMSource interfaces defines two operations, getDOMListener() and setDOMListener(DOMListener next), for getting and setting the next Xbean, i.e. the Xbean that will receive the output of the Xbean. While one could imagine operations to set multiple listeners, most Xbeans only directly support the registration of a single listener.

The reason for this is if an Xbean has multiple listeners for its resulting document, the document can either be a shared, concurrently accessed document or it can be copied for each listener. The appropriate behavior is usually not dictated by the source Xbean but by the application itself. For example, if the multiple listeners all read the document without modifying it, they can easily share the resulting document. Only the application knows that the Xbeans were configured this way.

To make this explicit in the chaining of Xbeans into an application, the parallelizer Xbean supports multiple listeners. It contains properties to indicate whether the document should be concurrently shared among the multiple listeners or whether the document should be copied. In case the document is concurrently shared, the synchronizer Xbean can be used to wait until all concurrent Xbeans are done.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact