Java Reference
In-Depth Information
mote access. Those proprietary protocols are invariably faster than CORBA (that is the reas-
on the server vendors developed them in the first place). So when remote EJB calls must be
used (and when interoperability is not a concern), explore the options for access protocols
provided by the application server vendor.
Remote interfaces impose a performance burden when calling EJBs, even within the same
XML and JSON Processing
When Java EE application servers host servlet-based applications to display their output in a
browser, the data returned to the user is almost always HTML. This chapter has covered
some best practices of how to exchange that data.
Application servers are also used to exchange data with other programs, particularly via
HTTP. Java EE supports different kinds of HTTP-based data transfer: full-blown web service
calls using the JAX-WS stack, RESTful calls using JAX-RS, and even simpler roll-your-own
HTTP calls. The common feature of these APIs is that they utilize a text-based data transfer
(based on either XML or JSON). Although they are quite different in their data representa-
tion, XML and JSON are similar in terms of how they are processed in Java, and the per-
formance considerations of that processing are similar.
This is not meant to minimize the important functional differences between the two repres-
entations. As always, the choice of which representation to utilize should be based on al-
gorithmic and programmatic factors rather than (solely) on their performance characteristics.
If interoperability with another system is the goal, then the choice is dictated by that defined
interface. In a complex program, dealing with traditional Java objects is often much easier
than walking through document trees; in that case, JAXB (and hence XML) is the better op-
tion, at least for the time being: Java EE 7 only mandates support for JSON-P via JSR 353
(which supplies standard parsing and document model features). At the time of this writing,
the JSON-B JSR (which will supply JAXB-like features for JSON) has not yet been ap-
proved (but will likely be a future technology).
There are other important functional differences between XML and JSON as well. So while
this section makes some performance comparisons, the real goal here is to understand how to
Search WWH ::

Custom Search