Assignment 5: URL Monitor

Create a URL monitor utility application. This utility will check a set of URLs and report on the last modified date (see notes for an example of this) and on the speed of access -- how long it takes to access the first byte of data on the page, and how long it takes to download the entire page. Such a utility is useful in managing a collection of web sites, or for checking to see which sites are congested. It should support at least the following scenario:

Scenario

  1. User adds the URL "http://www.johnpanzer.com/" to the collection of URLs to check.
  2. The URL appears on the display.
  3. User adds the URL "http://www.xyzzy.org/" as well.
  4. Both URLs now appear on the display.
  5. The system checks the URLs and updates the statistics:
  6. http://www.johnpanzer.com/: Modified 3/03/01, access time 560ms, load time 1245ms.
    http://www.xyzzy.org/: (unreachable)

Additional Requirements

The utility application should have a graphical interface where it displays the current state of the URLs and allows new URLs to be entered. Ability to remove URLs is a "nice if" feature but not required.

The utility's UI can be fairly simple. It should display the current set of URLs with their statistics, and have a way to add a new URL to the system -- an edit box with an "Add" button is sufficient. (I suggest doing this assignment as a standalone application rather than an applet, because the Java security manager will by default prevent an applet from connecting to random URLs.)

The utility should check the URLs periodically while it is running, attempting to keep the statistics fairly current. A good initial value would be to check each URL every 60 seconds, although you will want to change this during testing so you can verify the code more quickly.

Use multiple threads to check URLs in parallel. This is a good use for threads, because each thread may have to wait for data from the remote site while the the other threads are doing useful work. This assumes that your computer is fast enough that the load times are dominated by your Internet connection speed.

Background Information

Use AWT or Swing components for the UI (packages java.awt and javax.swing). A JList or a JTextArea are reasonable ways to display the URLs. Use the URL and URLConnection classes from the java.net package. You may need to do research on these or other standard library components. A good way to search for reference documentation and tutorials online is to use Google (www.google.com) and type in, for example, "site:java.sun.com JList". This will bring up the documentation for JList at java.sun.com.

This assignment is mostly about connecting together and using library classes, so you probably don't have to build very many abstractions of your own. However, you should use them were appropriate. For example, a URLStatistics class is probably a good way to keep track of the information gathered about a URL.

Extra Credit Question (1pt)

Are there any patterns in use in this application? If so, identify which ones and which classes participate in them. Turn in your answers along with your code.

Deliverables

Turn in a class diagram, the code, any println output, and a screen shot of your program. (Under Windows, you can copy screen images to the Clipboard with Control-PrtScn, then paste to an application like Paintbrush for printing.)