- Forward


Protocol Handlers
An Introduction with Examples in Java


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Motivation
Back SMYC Forward
  • An Observation:
    • Stream-oriented protocols have many similarities
  • Implications:
    • We can think in the abstract about a stream-oriented protocol handler
Returning to an Earlier Example
Back SMYC Forward

It would be nice if we could do something like...

javaexamples/sfp/ConnectionDriver.java (Fragment: 0)
 
Returning to an Earlier Example (cont.)
Back SMYC Forward

The Relevant Classes in Java

custom_urls_java
Returning to an Earlier Example (cont.)
Back SMYC Forward

SFPConnection

javaexamples/sfp/SFPConnection.java
 
Returning to an Earlier Example (cont.)
Back SMYC Forward

SFPStreamHandler

javaexamples/sfp/SFPStreamHandler.java
 
Returning to an Earlier Example (cont.)
Back SMYC Forward

SFPStreamHandlerFactory

javaexamples/sfp/SFPStreamHandlerFactory.java
 
Returning to an Earlier Example (cont.)
Back SMYC Forward

Telling the URL Class the Kind of Connection to Create

javaexamples/sfp/ConnectionDriver.java (Fragment: 1)
 
Some Observations
Back SMYC Forward
  • Some Messiness:
    • We have to do a lot of type-casting
  • It Would Be Nice If:
    • URL was parameterized (so we could specify the type of URLConnection)
    • URLConnection was parameterized (so we could specify the type of InputStream and OutputStream)
There's Always More to Learn
Back -