Project #7 (Networking)

CMSC 132

Due Date: Tuesday Nov 21, 6:00 pm

Object-Oriented Programming II

Type of Project: Closed

Fall 2006


Objective

This project has several objectives.  Those objectives are:

This project is considered a closed project.  Make sure you read the open/closed policy before continuing working on this project.

Overview

For this project you will complete the following tasks:

Your project will be graded as follows:

Public JUnit tests                                      50 %

Release JUnit tests                                  30 %

Style                                                          20 %       

For this project:

Specifications

Generic Client and Server Classes

The basic functionality of a client/server environment is for the client to send a request to the server and wait for an answer.  The server receives and process the request sending the answer back to the client.  Your task is to implement generics client and server classes that we can use to develop more specific client and server applications.

GenericServer Class 

In the generic package you will find an interface named CommandProcessor.  A GenericServer object expects an object  that implements the method defined in this interface.  The GenericServer will call the method associated with the interface in order to complete requests submitted by the client.  It is through the CommandProcessor interface that the Server is "generic".

 This GenericServer class has only one public method:

The CommandProcessor provided in the parameter is the object the server relies on to actually process a request.  The server just receives a request and passes the request to the processor.  The result generated by the processor is then returned to the client.  It is this capability what makes the server a generic one.  Usually subclasses will implement the expected processor for a particular server application.

Feel free to add any private instance variables and methods you understand are necessary.  You may not add any additional public methods.

GenericClient Class

 This class has three public methods:

Feel free to add any private instance variables and methods you understand are necessary.  You may not add any additional public methods.

Client and Server Classes

Using the above generic classes you can implement different kinds of clients and servers.  To illustrate this capability, you will define client and server classes that rely on the generic classes defined above. 

Server Class

The Server class will be a subclass of the GenericServer class and it will implement the CommandProcessor interface. 

This class has two public methods:

The requests the Server class must process are:

PING

The server replies to a ping request by sending the message "Server is Running: " followed by the date.

LOOKUP:Person'sName

where the LOOKUP command and the person's name are separated by a colon.

The file information.txt will contain information about individuals.  The server will return the file entry associated with a specified individual or "NOTFOUND".

IMAGES:Web Site

The server will return the urls of images present in the specified web site.  Keep in mind that you must specify the web site address starting with "http://".  For example, if you want to look for images in www.cs.umd.edu, you need to provide the address as http://www.cs.umd.edu

To recognize images, the server will search through the html code of the specified web page, looking for entries starting with "<img src="  where any number of spaces and options (e.g. border) may exist in between img and src.   An image is represented by the string following "src=".  The following is a representative example of one possible entry you will be searching for:

<img src="http://i.cnn.net/cnn/images/1.gif">

The server will return complete urls of images found.  A complete url is defined as one that starts with "http://" and which provide the exact location of the image in such a way that we can cut and past the url in a browser and actually see the image.  For this project you don't have to worry about sites that may use uppercase letters for img or src in the html code. 

Feel free to add to the Server class any private instance variables and methods you understand are necessary.  You may not add any additional public methods.  Also, feel free to add any support classes you might need.

Notes:

Client Class

The Client class will be a subclass of the GenericClient class.  The class must implement the following public methods:

Feel free to add to the Client class any private instance variables and methods you understand are necessary.  You may not add any additional public methods.  Also, feel free to add any support classes you might need.

In the code distribution we have left a class called ClientExample that shows how we can use the Client class to process some requests.

Java Construct Requirements

                                       throw new IllegalArgumentException("Your message here");

Style Requirements

Submission

Submit your project using the submit project option associated with Eclipse. 

Academic Integrity

Please make sure you read the academic integrity section of the syllabus so you understand what is permissible in our programming projects.  We want to remind you that we check your project against other students' projects and any case of academic dishonesty will be referred to the University's Office of Judicial Program

Web Accessibility