Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Jesse Xie Y.S.

+ Follow
since Feb 09, 2004
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jesse Xie Y.S.

I am so happy that I foregot to say thanks to JavaRanch.
Because I've learned so lots from JavaRanch.

My lock implementation is very simple.
1. I uses a static Random long seed initialized once JVM started, as a seed of looked cookie generation.
2. I uses a map to store all current available mapping of locked record and cookie. The key of the entry is a record number, the value mapped to the key (record) is the cookie held by a client.
3. I uses the object locked of the map to synchronize the record lock and unlock process.
4. I notify all thread waiting on the object locked of map only after unlocked a record successfully.
5. Make sure that the process of checking if a record is locked by other thread or checking if the record is exist, before locked a record, should be keep in synchronized block.
16 years ago
Date Taken: 2005-10-27 06:45:22.437

Grade: P
Score: 362
Comment: This report shows the total number of points awarded for each section. The maximum number of points is 400, to pass you need a score of 320. Section Summary: Section Max Actual Points Points General Con: 100 90 Documentation: 70 65 OOD: 30 30 GUI: 40 27 Locking: 80 80 Data Store: 40 40 Network Server: 40 30 Total: 400 362
16 years ago
OK, I just test the following code for your information

Date currDate = new Date();
Date within48HDate = new Date();

within48HDate.setTime(currDate.getTime() + 48 * 60 * 60 * 1000);

if (roomDate.before(currDate) || roomDate.after(within48HDate)) {
throw new UnbookableRoomException("Out of 48 hours exception");
Excute me, I want to give my comments about this topics after I look around this forum about within 48 hours requirement.

1. I think that we should implement this requir, otherwise, my assigment is very simple just do the requirement that marked MUST. But the must requirement is the Automatic Failure requirement. And the other is for your good score requirement I think.

2. The within 48 hours requirement should be implemented in the logical layer, but not the Database layer, because database just only know how to lock & unlock record for update and how to save data into file, and but not the client gui layer, because the within hours rule should be checked according the time in the server, so no matter what time is it in client.

3. I would like to assume that the time of the start of room occupancy in URLyBird company is at noon AM 12:00 (It must be documented in the choice.txt). In other word, customer onwer the room which booked by themself begin from AM 12:00 to next day AM 12:00. So, to check if a room is bookable according to the within 48 hours, just caculate as follow method:
Date dateAvailable = GET_THE_DATE_IN_RECORD & SET 12:00 AM AS ITS TIME;
Date currDate = GET_CURRENT_DATE;
Date within48 = CURRENT_DATE + 48 HOURS;

any comments tks.
Hi Thomas, after I read over this forum about the IOException, I found that it is really a big problem. and now, I want to try your suggestion.

So I just create a new DataException and extends from RuntimeException, and I will catch it on business layer.

I think it's normally a fetal error about reading file, because my program will make sure that the file exist before create new Data instance.
I just cann't find out some post topic create by myself one years ago, and it is difficult to find out some reply post topic by myself recently also.

Could you enhance the search engine GUI for this forum, add more search criteria such as author name match, etc.

16 years ago
I just thinking about the SecurityException again. In this forum, every body all thought that the securityException should be a checked exception. But I don't think so.

User the CSR's don't know there are some cookie exist in URLyBird program, maybe they know how to correct the FileNotFoundException and RecordNotFoundException, but they don't understand the cookie and don't know how to correct the SecurityException too.

So, I think that SecurityException is not a checked exception. It's a runtime exception. It's occured only by programer.
OK, this time, I really got it:

* A class implements the Closeable interface to indicate to the close method
* that it is legal for that method to make a resource release for this class.
* @version 1.1.1, 2005-8-27
* @author Johnson Xie

public interface Closeable {

* Release the resources in this object.
public void close();

public class Data implements DBAccess, Closeable {
... ...

public interface URLyBirdService {
... ...

public class URLyBirdServiceImpl implements URLyBirdService {
private DBAccess dbAccess;
... ...
public void close(){

if(dbAccess instanceof Closeable){


if (locks.containsKey(recordNo) && locks.containsValue(lockLongCookie)) {

If recordNo=1 locked cookie=001
and recordNo=2 locked cookie=002
when invoke deleteRecord(1,002); then...

unlock(recNo, lockCookie);

I don't think it's a good way that invoke unlock in the deleteRecord method.

} catch (FileNotFoundException e) {
} catch (IOException e) {

catch IOException and then just print the message, is it really OK?
Hi, good day every one. I really don't know how to deal with IOException.

public synchronized long[] findByCriteria(String[] criteria) {
long[] result;
... ...
return result;
} catch (IOException ioe) {
//If have exception return null;
return null;
//If have no result,return 0 length array
return new long[0];

how do you think?
Just do it:

String[][] strArray = new String[][]{};
Object obj=strArray;
I got it:

public class Data implements DBAccess{
RandomAccessFile dataFile;
... ...
public void close(){
}catch(IOException ioe){
//ignore this exception
... ...

public class Server{
DBAccess dbAccess;
... ...
public void stop(){
if(dbAccess instanceof Data)
}catch(IOException ioe){
//ignore exception
... ...

How do you think?
In my DBAccess interface, there is no resource release method such as close, dispose, release etc for me to close the opening file (I open the specified database file by RandomAccessFile and don't close it util the program exit), how can i close the file before the program exit or when the user change the database file name.
I prefer to implement a business logic layer between user client and database, and I am just confusing about how could I deal with so much exception. Should I ignore the IOException? Could I ignore the RemoteException? Or maybe I could just transform it into other exception such as RecordNotFoundException or RoomNotFoundException?

Any help. TKS very much.
Dear Andrew, Thank you so much for your very kind, and very excellent reply. Exactly, you give me the clear answer and encourage me by a long way. I feel very good now.

At first, I am sorry for the question 6. It puzzled me too, when I read it by myself. Maybe, my question should be described as follows:

I have no idear about the comment in each java file header. I have looked into some java file in the runtime libaray package. They just look like:

* @(#) 1.1.1 2004-5-15
* Copyright (c) 2004 Sun Certification for Java Development.
* All Rights Reserved.

It's my choice about such comments. Is it OK?

So, I hope I can know the one candidate who took 6 years to complete his assignment. He must be a very brave man .

And I will answer the four questions in "bullet point" format. It's easier for me.

About question 1. My decision is that: It does not allow the user to book a selected record, which have booked by one customer in the same GUI. It will throws exception message when the user try to book a selected record, which have booked by one customer in other program GUI. User can get the last booked record list by using Search All function.

About question 2. My decision is planing to implement the createRecord and deleteRecord method. Because I didn't have a good reason for this, and I don't want to finish my assignment as soon as possible again after I heard someone took 6 year to complete his assignment, also, I have get a new voucher for my essay exam which expired date is in November this year .

But, if so, I think there must be some good tools for testing such method like createRecord and deleteRecord which will never be invoked by other object in URLyBird program. Would you like to give me some?

About question 3. It must make decision by myself, I think. And it's very hard to make a decision for such thing after I totally think about it (But it is easier than making a decision that which one should I marry to). But I didn't have decision about it now. I think I should analyse the original data in the assignment. I will post it as soon as I make a decision.

About question 4. The answer is clear now. Because the SecurityException be throws by some method already, and the java.lang.SecurityException is a runtime exception, no need to throws it.

About question 5. I just create a Service interface. It include Book & Search method. And there are two class implement it: ServiceImpl that maintain a Data object directly, and ServiceProxy that maintain a RemoteServiceImpl implemented by RMI which maintain a ServiceImpl instance, So ~~OhOh ~God . In other words, client GUI just only need to interact with Service interface, when program mode is non-network, just create a ServiceImpl instance for GUI, when program mode is network, just create a ServiceProxy instance for GUI. Am I right? Am I clear?

And so, check the magic cookie value for validating a data file specified by user, is must option. And it's very important too.

By the way, I have more and more question later.

Thanks again!!!