The request handler interacts with the application server via EJB
components. The normal pattern is to execute commands on session
beans, which in turn get their data from entity beans. The internal
behavior of the EJB layer is irrelevant to the web tier, however.
Once the EJB method call is complete, one or more "data
objects" are returned to the web tier. From this point, the
data object must be converted to XML.
The conversion to XML can be handled in a few different ways. One
common approach is to write methods in the data objects themselves
that know how to generate a fragment of XML, or perhaps an entire
document. Another approach is to write an XML adapter class for each
data object. Instead of embedding the XML generation code into the
data object, the adapter class generates the XML. This approach has
the advantage of keeping the data objects lightweight and clean, but
it does result in additional classes to write. In either approach, it
is preferable to return XML as a DOM or JDOM tree, rather than raw
XML text. If the XML is returned as raw text, it will have to be
parsed right back into memory by the XSLT processor. Returning the
XML as a data structure allows the tree to be passed directly to the
XSLT processor without the additional parsing step.