Process Loops

A process loop occurs when the output of one process is used as the input for another process. Most often, it refers to using the same process; the output is fed into the process that created the output as input. It’s actually easier to visualize this concept than to explain it in words, so let Figure 5-3 be worth a thousand words.

Process loops

Figure 5-3. Process loops

This is particularly relevant to data binding, as you will often marshal Java objects into the same XML file that the instances were unmarshalled from. In fact, that is exactly what has occurred in the case of the MoviesServlet. When the servlet starts up, it reads the XML movie database. When movies or actors are added, marshalling occurs to that same file. The loop occurs when the servlet is restarted and the XML data is read again; in this way, output from marshalling is used as input for unmarshalling. Figure 5-4 fits this into the general diagram in Figure 5-3.

Process loops in the movie database

Figure 5-4. Process loops in the movie database

However, process loops have their own set of tricky issues to watch out for. I want to address those issues before going on, as they often come up in data binding situations.

Continuity

The first issue to watch for is continuity. Specifically, a process loop generally involves two discrete data sets, an input ...

Get Java & XML Data Binding now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.