Appendix A. Content and Protocol Handlers
Content and protocol handlers represent one of the most interesting ideas from the original Java vision. Unfortunately, as far as we can tell, no one has taken up the challenge of using this intriguing facility. We considered dropping them from the book entirely, but that decision just felt bad. Instead, we banished the discussion of how to write content and protocol handlers to an appendix. If you let us know that this material is important to you, we’ll keep it in the next edition. If you feel “yes, this is interesting, but why do I care?” we’ll drop them from the book. (You can send us comments through the book’s web page at http://www.oreilly.com/catalog/learnjava.)
This appendix picks up where we left our discussion of content and protocol handlers in Chapter 12. We’ll show you how to write your own handlers, which can be used in any Java application, including the HotJava web browser. In this section, we’ll write a content handler that reads Unix tar files and a protocol handler that implements a pluggable encryption scheme. You should be able to drop both into your class path and start using them in the HotJava web browser right away.
Writing a Content Handler
The URL
class’s getContent( )
method invokes a content handler
whenever it’s called to retrieve an object at some URL. The
content handler must read the flat stream of data produced by the
URL’s protocol handler (the data read from the remote source), and construct a well-defined ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access