[jdom-interest] Document Listeners?

wes at tralfamadore.com wes at tralfamadore.com
Mon Mar 26 14:11:32 PST 2001

--- Jon Baer <jonbaer at digitalanywhere.com> wrote:
> The FileWatcher util class seems like it would need
> to interact or be part of the
> Document class?  Or would I use the Document in
> there:

You could give the FileWatcher class the
responsibility of constructing the JDOM objects in the
first place, and when the program in general needed to
reference the document, it could do so by querying the
watcher for a Document object.

In a setup like this, a single FileWatcher thread
could watch multiple files (or more generally, URLs),
and keep a map of filenames/URLs vs. Documents.  This
would be a very handy utility to put in a JDOM-contrib
type package.

One issue with this approach is that you don't have a
well-defined way of synchronously catching errors in
the XML files that suddenly cause the parser to barf. 
You could log that or have it basically null out the
document.  Another thing to worry about is making
access to a given Document instance synchronized, so
the FileWatcher isn't updating the Document at the
same time a consumer thread is iterating through it,
for example.


More information about the jdom-interest mailing list