The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Hello,
I have decided to apply 3-tier architecture in my assignment (URLyBird 1.1.1).
I have provided new local and remote interfaces to allow high level access to the database:
public interface DBServer {
public void book(RecordModel record)
throws RecordNotFoundException,
DBConcurrentModificationException,
IOException;
public RecordModel[] find(RecordModel criteria) throws IOException;
public MetaData getMetaData() throws IOException;
}
public interface DBServerRemote extends DBServer, Remote {
}
The interface for database access defined by Sun, which will be available only for local use, because it will be used by implementation of DBServer interface, not the client application:
package suncertify.db;
public interface DB
{
public String[] read(int recNo) throws RecordNotFoundException;
public void update(int recNo, String[] data, long lockCookie)
throws RecordNotFoundException, SecurityException;
public void delete(int recNo, long lockCookie)
throws RecordNotFoundException, SecurityException;
public int[] find(String[] criteria);
public int create(String[] data) throws DuplicateKeyException;
public long lock(int recNo) throws RecordNotFoundException;
public void unlock(int recNo, long cookie)
throws RecordNotFoundException, SecurityException;
}
The only access point to work in network mode will be then DBServerRemote interface, which provides only 3 methods required by the my client application.
There is a following requirement in the assignment:
The following are the "top level" features that must be implemented:
A client program with a graphical user interface that connects to the database
A data access system that provides record locking and a flexible search mechanism
Network server functionality for the database system
My question is:
-if my design satisfies requirement,
-Do I have to provide additionally a Remote interface, whose methods would have the same signatures and functionality as local DB interface, except throwing RemoteException,
since I don't understand what interface do you mean by saying "Network server functionality for the database system ".
Your server [...] must provide locking functionality as specified in the [provided] interface
"I'm not back." - Bill Harding, Twister
Vlad: I think that your mail is probably too long for Sun
The cookie only makes sense if the client has to receive it and work with it.
"I'm not back." - Bill Harding, Twister
Your server must be capable of handling multiple concurrent requests, and as part of this capability, must provide locking functionality as specified in the interface provided above.
"I'm not back." - Bill Harding, Twister
Sudhansu<br />SCJP, SCWCD, SCBCD, SCJD, SCEA, SCDJWS
SCJP (1.4), SCWCD, SCJD
SCJP,SCJD,SCWCD,SCBCD,SCDJWS,SCEA
SCJP (1.4), SCWCD, SCJD
Your server must be capable of handling multiple concurrent requests, and as part of this capability, must provide locking functionality as specified in the interface provided above.
"I'm not back." - Bill Harding, Twister
"I'm not back." - Bill Harding, Twister
Server
Required Interface
Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface:
package suncertify.db;
public interface DBAccess
{
// Reads a record from the file. Returns an array where each
// element is a record value.
public String [] readRecord(long recNo)
throws RecordNotFoundException;
// Modifies the fields of a record. The new value for field n
// appears in data[n]. Throws SecurityException
// if the record is locked with a cookie other than lockCookie.
public void updateRecord(long recNo, String[] data, long lockCookie)
throws RecordNotFoundException, SecurityException;
// Deletes a record, making the record number and associated disk
// storage available for reuse.
// Throws SecurityException if the record is locked with a cookie
// other than lockCookie.
public void deleteRecord(long recNo, long lockCookie)
throws RecordNotFoundException, SecurityException;
// Returns an array of record numbers that match the specified
// criteria. Field n in the database file is described by
// criteria[n]. A null value in criteria[n] matches any field
// value. A non-null value in criteria[n] matches any field
// value that begins with criteria[n]. (For example, "Fred"
// matches "Fred" or "Freddy".)
public long[] findByCriteria(String[] criteria);
// Creates a new record in the database (possibly reusing a
// deleted entry). Inserts the given data, and returns the record
// number of the new record.
public long createRecord(String [] data)
throws DuplicateKeyException;
// Locks a record so that it can only be updated or deleted by this client.
// Returned value is a cookie that must be used when the record is unlocked,
// updated, or deleted. If the specified record is already locked by a different
// client, the current thread gives up the CPU and consumes no CPU cycles until
// the record is unlocked.
public long lockRecord(long recNo)
throws RecordNotFoundException;
// Releases the lock on a record. Cookie must be the cookie
// returned when the record was locked; otherwise throws SecurityException.
public void unlock(long recNo, long cookie)
throws SecurityException;
}
Any unimplemented exceptions in this interface must all be created as member classes of the suncertify.db package. Each must have a zero argument constructor and a second constructor that takes a String that serves as the exception's description.
Any methods that throw RecordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file.
Network Approaches
Your choice of RMI or serialized objects will not affect your grade, but no other approach is acceptable. In either case, the program must allow the user to specify the location of the database, and it must also accept an indication that a local database is to be used, in which case, the networking must be bypassed entirely. No authentication is required for database access.
Locking
Your server must be capable of handling multiple concurrent requests, and as part of this capability, must provide locking functionality as specified in the interface provided above. You may assume that at any moment, at most one program is accessing the database file; therefore your locking system only needs to be concerned with multiple concurrent clients of your server. Any attempt to lock a resource that is already locked should cause the current thread to give up the CPU, consuming no CPU cycles until the desired resource becomes available.
Return to top
There are three key parts: the server-side data management system, the client-side GUI, and the network connection between the two.
Your server must be capable of handling multiple concurrent requests, and as part of this capability, must provide locking functionality as specified in the interface provided above.
Regarding your bookHotel() method - how do you know that some other client hasn't just booked the hotel room, perhaps just before your own request?
What you must do
The following are the "top level" features that must be implemented:
A client program with a graphical user interface that connects to the database
A data access system that provides record locking and a flexible search mechanism
Network server functionality for the database system
Server - The data server and its network connection
Your server must be capable of handling multiple concurrent requests, and as part of this capability, must provide locking functionality as specified in the interface provided above
Your server must be capable of handling multiple concurrent requests, and as part of this capability, must provide locking functionality as specified in the interface provided above.
Server - The data server and its network connection
When I book my ticket to see Wayne Rooney and the ten no marks that play around him, the Server locks my seat while I pay, which part of the server I don't know( though I can bet its at the back end) but its still the server. The networking provides a connection to the server.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
We define Server differently
Server - The data server and its network connection
Your server must be capable of handling multiple concurrent requests, and as part of this capability, must provide locking functionality as specified in the interface provided above.
I think you inadvertantly just provided me with more amunition
Instructions:
The IT director does not anticipate much reuse of the first Java technology system, but intends to use that system as a learning exercise before going on to a web based system.
Instructions:
The following are the "top level" features that must be implemented:
* A client program with a graphical user interface that connects to the database
* A data access system that provides record locking and a flexible search mechanism
* Network server functionality for the database system
The work involves a number of design choices that have to be made.
Instructions:
A clear design, such as will be readily understood by junior programmers, will be preferred to a complex one, even if the complex one is a little more efficient.
Instructions:
The main architecture of the application must be a traditional client-server system. There are three key parts: the server-side data management system, the client-side GUI, and the network connection between the two.
Instructions:
The program must be able to work in a non-networked mode. In this mode, the database and GUI must run in the same VM and must perform no networking, must not use loopback networking, and must not involve the
serialization of any objects when communicating between the GUI and database elements.
Instructions: (about the client-side GUI)
The user interface for this assignment must satisfy the following criteria:
* ...
* It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user.
* ...
* It must allow the user to book a selected record, updating the database file accordingly.
Instructions:
Your user interface should be designed with the expectation of future functionality enhancements, and it should establish a framework that will support this with minimal disruption to the users when this occurs.
Instructions:
Server
Required Interface
Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface:
Instructions:
Locking
Your server must be capable of handling multiple concurrent requests, and as part of this capability, must provide locking functionality as specified in the interface provided above. You may assume that at any
moment, at most one program is accessing the database file; therefore your locking system only needs to be concerned with multiple concurrent clients of your server. Any attempt to lock a resource that is already locked should cause the current thread to give up the CPU, consuming no CPU cycles until the desired resource becomes available.
Instructions:
This document deliberately leaves some issues unspecified, and some problems unraised. Your ability to think through these issues, in the face of realistically imperfect specifications, and come to a tenable solution
is something upon which you are being graded.
Andrew:
Some of the assignments have a lock method that returns a cookie which must be used in the database modification methods and in the unlock method. I see that as further evidence that the lock method should be
called from the client side.
Consider the normal "booking" method: if it is on the server side, the cookie provides no benefit whatsoever. If you did not have the cookie requirement, the code would still work in an identical manner.
The cookie only makes sense if the client has to receive it and work with it.
Jim:
Well I don't really think the cookie makes much sense at all. But I agree that, given that the specifications went to the trouble of putting it in there, it seems that someone, somewhere thinks that cookies are useful and important, and though I don't agree I figure it's best to make them happy by requiring cookie usage on the client as well.
Instructions:
A clear design, such as will be readily understood by junior programmers, will be preferred to a complex one, even if the complex one is a little more efficient.
Vlad:
The only thing which I have change is : added two new adapter interfaces local/remote for the client which change slichtly a signature of methods:
String[] read (int recNo)-> RecordModel read(int recNo), int[] find(String[] criteria) -> RecordModel[] find (Hashtable criteria) and so on to make info and changes on the database transparent to the client. I am sure it is going to work.
and I submit that we don't know whether the client application is locking the record or not
"One good thing about music - when it hits, you feel no pain" <P>Bob Marley
As a 3-tiers supporter, I don't like the sentence "A client program ... that connects to the database", but I think it's compensated by "Network server functionality for the database system".
My own general strategy is to explain how my interpretations influenced my design, and what the alternatives were for other interpretations I can see.
I feel it would be a cruel Sun examiner indeed who fails you in such circumstances...
So, I have a question: who is from the team of "guinea pigs" first to take the test?
"One good thing about music - when it hits, you feel no pain" <P>Bob Marley
SCJP (1.4), SCWCD, SCJD
could you please update your ratings!
"I'm not back." - Bill Harding, Twister
Your server must be capable of handling multiple concurrent requests, and as part of this capability, must provide locking functionality as specified in the interface provided above.
Your server must be capable of handling multiple concurrent requests without nausing up the data file and making you look like a complete spanner. It must be doing this at the lowest level via a locking mechanism using the above interface. Not something you come up with yourself that might make you look like a complete spanner. Or that our examiner won't be able to understand (which would make you look like a spanner).
"One good thing about music - when it hits, you feel no pain" <P>Bob Marley
Originally posted by Philippe Maquet:
Hi Vlad,
Hmh... No need. Just change the section title "Don't know yet" by "Traitors"...![]()
Best,
Phil.
SCJP (1.4), SCWCD, SCJD
"I'm not back." - Bill Harding, Twister
1. Andrew
You might want to take another look at the first post in this thread, Philippe. Andrew did FBN, which didn't have the requirements under discussion. But he's made his position clear for those who do have such requirements.
But note the word "provide". Provide to who? Other components on the server? I think not - if a server is required to provide something, it's required to provide it to clients. That's what servers do, they serve clients. If your server implementation has a lock method somewhere internally but the client can't call it, you haven't "provided" that functionality as specified in the interface.
The instrutions are so unclear in that area (2-tiers/3-tiers), that, with Michael, I think there is no risk at all to choose one solution or the other. Or, at least, there is not more risk to choose 3-tiers while the grader would expect a 2-tiers system, than to choose 2-tiers while the grader would expect a 3-tiers one. But we should pass in both cases anyway (or fail for other reasons).
SCJP,SCJD,SCWCD,SCBCD,SCDJWS,SCEA
It's a beautiful day in this neighborhood - Fred Rogers. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|