Você está na página 1de 3

The purpose of this exercise is to combine all of the above into a single large exercise

while covering some more topics like code design using UML and very basic design
patterns.
The exercise will be conducted in the following manner:
1. A detailed design (preferably using UML) will be composed prior to any coding. The
purpose of this step is to give the developer a sample of our coding procedures design
before coding.
2. Implementation of the design including a client for testing.
Prior to the coding learn the strengths of design patterns understand the Factory
design pattern this pattern is mandatory for the exercise.
The exercise itself is to implement a client-server application that will manage banking
operations of bank branches and the customer accounts. The client will read a list of
operations to be done from a file and will contact the server for their execution.

The database

Banks table
Field Name Type Nullable Description
CODE Varchar2(10) N Unique identifier of
the bank
NAME Varchar2(30) N Bank name
Indexes
CODE primary key


Accounts table
Field Name Type Nullable Description
ACCT_NUMBER Varchar2(10) N Account number.
Unique identifier of
the account
OWNER Varchar2(30) N Name of the account
owner
BANK_CODE Varchar2(10) N Code of the bank
BRANCH_NUM Varchar2(30) N Bank branch number
LAST_UPDATE Date N Date time of the last
operation done in
this account
BALANCE Number N Account balance
Indexes
ACCT_NUMBER + BANK_CODE primary key

Keys
BANK_CODE foreign key to BANKS. CODE



Input file

This file will be read by the client and will contain the following data:

Type: ACCT/BANK
ACCT - Account, BANK Bank

Operation: Depends on request type:
ACCT (account):
A add account
U update account
D delete account
Q query balance
BANK (bank):
A add bank
U update bank
D delete bank

File format:
Each file contains the request type, requested operation and relevant fields.
Each line in the file represents an operation to be executed. The fields in the record are
separated by ; character (semi-colon).

Example: ACCT;A;BLL;Leumi
This example represents a request to add new bank with code=BLL, and
description=Leumi

Note: in case a value of a field is missing in the file assume that an empty string will
represent it (2 consecutive semi-colons will be displayed)

Example: BANK;A;;Leumi
In this example bank code is missing and there are 2 consecutive semi-colons

Client
The client reads the data from the input file, sends it to the server and waits for a
response with the operation result. The response should be printed to console in the
following format:
Date = <response date> Type = <Request type > Operation = <operation type>, identifier
= <entity identifier*>, Status = <returned status>

*Identifier identifies the record uniquely.
If request type = ACCT, the identifier will be account number.
If request type = BANK, the identifier will be bank code.


Protocol type, IP-Address of the server and the port to connect to should be read from
client.ini or properties file.

Client.ini file format:
PROTOCOL=<Protocol type TCP or UDP>
SERVER_ADDRESS=<IP address of the server e.g. 127.0.0.1>
PORT=<port of the server e.g. 2000>
FILENAME=The data file name of the client, for example client.dat

Server
Receives messages (on a specific port) from the client, performs the corresponding
operation and sends a response back to the client with the operation result (if the
operation succeeded status will be OK, if the operation failed status will be FAIL and the
reason for failure should be added also.

Example: if the server gets a request to delete a account that does not exist
The returned response will contain status = FAIL and reason = account does not exist
Will wait for both TCP and UDP messages.

Server.ini file format
UDP_PORT=<port to listen to in UDP protocol, e.g. 2000>
TCP_PORT=<port to listen to in TCP protocol, e.g. 2000>

Guidelines
The exercise is consists of 2 parts: design and implementation

Design - in this part you should not write code. You should describe the classes you
need, their structure, and the relations between them (draw a diagram, preferably,
UML). Also describe the general algorithm in client and server .
Implementation write a code for the suggested design


Notes
Use java.net.ServerSocket and java.net.Socket classes for TCP protocol
Use java.net.DatagramSocket,java.net.DatagramPacket classes for UDP protocol
There is no need to create the tables in the application. Create them manually in PLSQL
developer.
Port value in client.ini and server.ini must be the same and should be greater than 1024
Each protocol should have a corresponding thread (in client and server)
Both client and server must check for exceptional cases.
The server must be able to deal with several clients at the same time.
All communications between the client and the server will be based on byte buffers.
The server needs to be divided into two main modules the communication, the
database. The communication between them should be done by messages and thread-
safe queues.

Você também pode gostar