The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
It seems that in my design, I have no place to deal with client crash. Is this a big problem ?
And will RMI gurantee my DBAdapter unique for every client?
And will RMI gurantee my DBAdapter unique for every client?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
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.
If all you have is one DBAdapter registered with the RMI Registry, then that one instance will be used by all the connected clients. RMI will allow more than one thread to use your instance of DBAdapter, but there are no guarantees about which thread will be used by any given client at any given time (that is - one client could use two different threads for two consecutive method invocations, or two clients could use the same thread for non concurrent method invocations).
Yes, I will use a Factory and return a DbAdapter instance for each client,so each client will have it's own DbAdapter and in turn gets it's own cookie. And this DbAdapter is inside server side, client won't know about the cookie,
But if no guarantee each client will still get it's own DbAdapter, then my design will be totally wrong, because the cookie will not be correct.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
But can I surround a member declaration/definition in a try/catch?, seems messy even if possible.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
That being the case, I would invite you to consider two things:
what is the point of the cookie? Since your code will work identically with or without the cookie, the cookie has no value. No client can directly call lock, update, or unlock, so the whole point of the cookies is lost. Given that, do you think that Sun were hinting that the DBAdapter.update() method should be on the client side, in which case the cookies make sense?
Do you have the statement in your instructions: "Your server [...] must provide locking functionality as specified in the interface provided above" (in the Locking section under the interface description). If so, do you believe you are meeting this "must" requirement?
What do you mean exactly there ? That the DBAccess interface "must" be exposed to clients ? (you know that I don't do that, so your opinion here it's quite important to me).
Do you think that I should make the effort to implement DB commands client-side, even if I don't use them. Would it be risky not to do it ?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
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 have considered whether I should start up a new topic for this. But the questions all seemed relevant to Jonathan's implementation. Hmmmm. Do you want to continue the discussion here or shall we move to another thread?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
brevity is the soul of wit - shakepeare. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|