File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes ready to upload,but... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "ready to upload,but..." Watch "ready to upload,but..." New topic
Author

ready to upload,but...

jianqiang huhu
Greenhorn

Joined: Nov 26, 2002
Posts: 6
Hi Mark,Peter and other guys:
I read the instruction again,and I found my assignment are not match the requirement at two points:
In Sun instrution:
The lock method should block until the requested lock can be applied

In my assignment:
public syrnchonized lock(int recNum,Object clientId){
....
if (the record was locked by other cliend)[
wait();
}
}
When the record that you want to lock was locked by other client,you will go to the waiting pool and give up the objec lock of lock() mehtod,so other cliend can access the mehod. The lock() method was not block,would I will lost the point?

To connect with your server,you should create a client program.This implementation should include a class that implements the same pulbic methods as the Data class,although it will need different constructors to allow it to support the network configuration.

On my client side,I define a LocalModel class implements the DataAccess interface,which contains the all public methods of Data class,but this class is only used for local database,donot need different constructors to support network.For the remote object,I get a reference of remote object and invoke the remote methods through the reference,I also donot need the network configuration.
Do I need to change my design?
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

if (the record was locked by other cliend){
wait();
}
}

A much preferred way of doing it is:

Unlike your original code, this code will guarantee that you check the record before locking it.

When the record that you want to lock was locked by other client,you will go to the waiting pool and give up the objec lock of lock() mehtod,so other cliend can access the mehod. The lock() method was not block,would I will lost the point?

When your thread is in the waiting state, it IS blocked, so there is no violation of Sun's requirement.
Eugene.
HiBob Chu
Ranch Hand

Joined: Aug 12, 2002
Posts: 86
In my assignment instruction:
***********************************************
The remote client code that you write must provide all the public methods of the suncertify.db.Data class.
***********************************************
It seems like SUN changed instruction.
I think you had better do it as your instruction said.
jianqiang huhu
Greenhorn

Joined: Nov 26, 2002
Posts: 6
Hi guys:
Thanks for your reply!
When your thread is in the waiting state, it IS blocked, so there is no violation of Sun's requirement.

yes,when my thread is in the waiting state,it is not blocked,but have ot give off the object lock of syrnchonzied block,it is different with Sun's instruction:
The lock method should block until the requested lock can be applied

Maybe it means before you lock the record,you will stay in the lock() method and other threads can not access this method,is right?
HiBob Chu
Ranch Hand

Joined: Aug 12, 2002
Posts: 86
I think the block means block to run instead of blocking to be called.
[ November 26, 2002: Message edited by: HiBob Chu ]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

jianqiang,
in the lock method you synchornize on the collection of locks or the method. Using the while statement to check availability of the record, then issue the wait surrounded by a try, which catches the InterruptedException. This way you will stay until you can lock, then it will exit out of the while loop, and you can then add the record to you collection.
As far as the Public methods instructions, what you have is basically correct, there is some information missing that you didn't include in your post, but that doesn't really matter to say that you have two classes one for local and one for remote and both have all the public methods of Data, requirement filled.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
jianqiang huhu
Greenhorn

Joined: Nov 26, 2002
Posts: 6
Thanks!
so I will upload my assignment,do I need to send an email to Sun before upload the assignment?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Well you can try first, but I think most people find they will have to send an e-mail to get the permission to upload.
mark
jianqiang huhu
Greenhorn

Joined: Nov 26, 2002
Posts: 6
Thanks,Mark!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ready to upload,but...