For this project I have decided to implement the Façade Pattern. I have applied the pattern to a set of classes which deal with checking IP addresses’ for administrators and allowing Clients to connect to printers on a network. This assignment allowed me to develop some of the structures and classes which I will be using for my fourth year project. The implementation for this assignment is different than for my final year project but the core functionality will be the same. It also allowed me to develop my Java programming skills, especially in the area of servlets.
IntentEncapsulate a subsystem using a high-level interface, simplifying subsystem usage and hiding structural details.
Solution
Consequences
Related Patterns
This program is part of a web based network management system
which I will be developing for my final year project. I have changed
the functionality for the purpose of this project but the principle
ideas are the same. This program allows both administrator and client
access via the web. Administrators
can check if a server is online by pinging the IP address of the server.
The results of the request will be sent via email to the email specified
by the administrator. Clients
can connect to any printer by just selecting that printer and hitting
connect. These are the
basic functions of the program but complicated classes which deal
with pinging servers, verifying the results, email notification and
print server allocation are hidden from the client class and are only
accesses via the façade class – AdminRequest.java The
program can be broken down into three basic sections: 1.
User Details – name, password and email address. 2.
Administrator request – IP check 3.
Client Request – Printer Connection with automated print
server allocation
Throughout
this program it is the façade class, AdminRequest.java which deals
with the classes lying in the subsystem. The client class never access’
or references any of the classes which perform the requested operations.
ServerCheck.java and ServerAllocate.java both inherit common methods from ServerFacility.java. Using inheritence here saves time as both classes share some common methods. AdminNotify.java is accessed by both server classes and performs email notification when a server is down 1.
User Details: This section must be completed by both administrators and clients. For the purpose of this project an administrator can enter any password but clients must be of 8 characters long. (In the correct implementation of this feature a database of valid Ids would be searched and privileges decided from there.) The sample input/output sessions details the response if all details are not entered correctly. 2.
Administrator Request: Administrator requests are contolled by ServerCheck.java and email notification is controlled by AdminNotify.java. If the user has completed all the detail fields and supplied a valid administrator password then they can perform an IP address check. This is done by pinging the IP address entered, verifying the results and sending the results via email to the email address specified. 3.
Client Request: Client
requests are contolled by ServerAllocate.java. If the user has
completed all the detail fields and supplied a valid administrator
password then they can set any of the printers in the drop down list
as their default. This also has the feature of print server allocation.
If for example a company has two or more print servers then they need
a way to efficiently manage new printer connections without the client
having any knowledge of print servers. This is done by firstly making
sure that both print servers are online by pinging the servers. If
one is offline then the client is automatically connected to the printer
via the online server. If both are online then a server needs to be
allocated by comparing the amout of connections via each server. This
will be done by accessing a historical database in the full version.
Printer connection is done by updating the registry settings of the
users machine, these files are controlled by running batch files which
have been created independently of this program.
1. UML diagram - overview diagram + class diagrams
1. Admin Request.java - Facade Class 2. AdminServlet.java - Client Class 3. AdminNotify.java - email notification class 4. ServerFacility.java - Server super class 5. ServerAllocate.java - Printer connection class 6. ServerCheck.java - IP address check class 7. Pause.java - Interface with delay method
Input - sample input and output
|
- |
Project Preparation
OO Models
Z-specification
1. Proposal
1. Functional
Spec.
1.
Object Oriented Metrics
1.
Object Oriented Models
|