Discipline, Dedication and Determination define Destiny.
Qn: Do I have to cut and paste the code from Data.java to DataImpl?
Qn: I need to introduce a reference to the DataImpl object in these 2 classes. So does it make my Data class useless? I mean, then I am not really using that class at all.
1. I do not need lock() and unlock() in my remote access
so I modify the Data class to implement DataServices
Create another class (server-side) extending UnicastRemoteObject. Can I have a Data object inside this class and pass the method calls to the Data class?
But then I am stuck up with lock() and unlock() here. Where are they to be taken care of?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Discipline, Dedication and Determination define Destiny.
"lock() and unlock() are not needed in local access"
When I make DataImpl extend Data, its private methods are not inherited (for example, readRecord()). And so I need to re-define all those methods and some variables in my subclass also??
Let me say..
1. Define FBNS (interface)with getFlightInfo() and book().
2. class MyData extends UnicastRemoteObject (have a Data object inside for reference; define lock() and unlock()ALONE here).
3. Define FBNS_local and FBNS_remote, both implementing FBNS (the latter alone throwing RemoteException)
4. Have a call to Data object inside the FBNS_local and call to myData object inside FBNS_remote.Is this what u meant by additional coding.??
Qn. So I can have the book() inside my client class and allow it to make a call to MyData class (that in turn has the Data object) and reach the database?
Can I call it Remote Access just by making it throw RemoteException or do I need to make it implement a remote interface?
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
Discipline, Dedication and Determination define Destiny.
Actually, I thought of defining the criteriaFind() in a subclass of Data. I had to call the readRecord() method like, String[] s = readRecord())and some private variables directly inside my method.
If lock() and unlock() are not needed for local access, do they also have to be by-passed entirely during local access???
1. interface FBNS with getFlightInfo() and book()
2. interface FBNS_RemoteIF extends Remote AND FBNS :same methods but throwing RemoteExcpn.
3. class MyData extends UnicastRemoteObject implements FBNS_RemoteIF
I have defined the lock, unlock in MyData. Can I define them in Data and not call them in book() definition inside Flight_Svr_Local class?
Here are my lock() and unlock(). Please comment on them too.
...
Can I use HashMap/WeakHashMap instead of vectors?
What should be listed in the booking method? I assume it is just asking for the passenger details and updating the seats.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Discipline, Dedication and Determination define Destiny.
Andrew, I am not able to understand the importance of this unique ID(though I see how people have got one).
What happens in the following scenario?
Client A locks RecordONE
Client B locks RecordTWO
Can Client A lock RecordTWO and Client B lock RecordONE NOW?
Qn. Can 'A' break out of the booking cycle in the middle, before unlocking RecordONE (other than crashing)???
In this case, that record remains locked. So, even 'A' will not be able to access RecordONE again.
Qn. Please give me some examples of deadlock.
Qn. (From the other posting).. implementing the Unreferenced will unlock all the records that a particular client locked(after the client disconnects).. and for this I need the ID..am I right in understanding this?
Qn. What is "write-only" lock? Does this mean the multiple clients can read a record simultaneously but cannot modify simulataneously? (lock..read..modify..unlock)
Once a locked record has been unlocked, the waiting client gets to lock. But what happens when there are more than one client waiting? Do we have to assign priority and then implement this concept?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Discipline, Dedication and Determination define Destiny.
class RemoteData extends UnicastRemoteObject implements FBNS_RemoteIF {
has a reference to data object inside; (do I need to make it private)
In 3 and 5, the interface methods, getFlight() and book() are going to be defined using the methods of the Data class.
So, should the client also have an implementation of the Data class methods?
If that is so, then should DataInfo and FieldInfo also be accessible to the client program directly
One more regarding the connection factory, I think ConnectionFactory and Unreferenced should be implemented by my RemoteData class, am I right?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Discipline, Dedication and Determination define Destiny.
Remote interface (that should provide all the public methods of the Data class and this must be implemented by my server also, right?)
get all the matching values as DataInfo object and add to a vector
In case of local access, the bookFlight() must call only modify(), right???
Now here, I have used the data-object to access all the data methods. In remote access, do I need to use "rf" (in the Client class constructor) to access these methods? Is that my remote client then?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Discipline, Dedication and Determination define Destiny.
Can I modify the Data class to implement an interface (for providing local access)?
The connection factory interface must be implemented by my server and the unreferenced by my connection code, right?
Can u give me some links about using the above mentioned 2 things? I found one on the Sun's site :http://java.sun.com/j2se/1.3/docs/guide/rmi/Factory.html
Is it the same connection factory concept?
When I make another class (extends UnicastRemoteObject)implement the remote interface (that contains all the public methods of Data class), do I need to define all those methods again in this Remote class also?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Discipline, Dedication and Determination define Destiny.
Andrew, the default constructor of a remote class has to throw Remote Exception. Now, if I am going to define another constructor for the remote class taking Data object as an argument, should that also throw RemoteException?
Also, I have read that any object that is passed as an argument in remote methods must be serializable / remote object/primitives .
Is that true for constructors also (like in the above case)?
When I use a hashset to store the locked records in lock(), do I need to make it static ( I read about this somewhere). Please tell me the relevance of making it static.
In the lock() method, when the record is "going to be" -1 (server about to be down), then what happens to the new clients that are in the process of acquiring locks? Do I need to "just say" what I intend doing with those clients (either wait till all them are done or bring it down in anycase) or any coding???
When I design the server, I code to get the localhost name as an argument. Do I need to take into account the port number also?
Eg: Naming.rebind("rmi://localhost/somestring",factoryObject);
Should I modify to include the portnumber also?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Discipline, Dedication and Determination define Destiny.
... method calls passed to Data class ...
Qn. Is this ok?
Unreferenced.unreferenced() will be called automatically once the referenced set becomes empty. And usually takes about 20 min, right? So no action is required by the implementation? Inside my unreferenced, I just need to instruct for unlocking records?
public getConnection() throws RemoteException, IOException {
Data data = new Data("db.db");
return new RemoteData(data);
}
Here since I need to instantiate the data object, I have modified the Factory interface to throw IOExcpn. Is this ok?
Qn. Do I need to get the file name (for eg, db.db) from the command line argument or can I include it in the code myself?
I think I need to have my lock and unlock (methods) inside RemoteData also implementing another set (keeping client IDs) so that I check for "client-lock" pair (I mean, check if 'this' client has 'this' lock)and if yes, I will call my data.lock (whick is going to keep track of the locked records). Is my view right? I'm at a loss as to how to implement it. Please guide me
Also, let me give u my understanding of the connection factory. Please point out if wrong -
Factory object bound to the registry >> clients access the connection objects via the factory object >> so each client gets a connection object for itself >> once a client is done, the factory object reuses the connection object and passes it to another client (and this is regardless of the operations performed by the previous client, right?)
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Discipline, Dedication and Determination define Destiny.
I don't understand when u say, having 1 data per client is going to have us make changes to the create and recordCount variable (in particular).
Qn. I have not synchronized the lock and unlock in data class but having my wait and notify inside. Is this ok, since I am anyway making a call to lock and unlock from a synchronized code from the RemoteData class?
Qn. When I compile FactoryImpl and try to run it on say, 1234(port number), it is started. But when I try to run it on 1099, it gives me java.net.BindException, port already in use. Please tell me what it means.
My unreferenced code ..... Is this ok?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Discipline, Dedication and Determination define Destiny.
Discipline, Dedication and Determination define Destiny.
Regarding my unreferenced, do I need to clear the set inside that method. I can just unlock the records (which is anyway going to remove the record fromt the set).
On searching for the ConcurrentModificationException ....
Am I not implementing your second suggestion in my code for unreferenced?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Discipline, Dedication and Determination define Destiny.
I get a stack trace saying ....
I have used a mix of Flow, Border and Grid Layouts in UI. It's kind of simple. Is it ok?
In the UI, I have included a combobox for the client to select date of travel also. Is it ok?
If the date is the current date or before current date, the client is intimated to choose another date
On the client-side, say , I have a close button, do I need to call System.gc() and runFinalization() before exiting?
I have used JTable as a separate frame. Is it ok?
When seats are booked, changes are not immediately seen on the table, but when it is opened again ( I mean to say when another booking is to be done) the changes are seen. Is this correct? Or should the changes be seen on that client's window immediately?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Discipline, Dedication and Determination define Destiny.
It's never done THAT before. Explain it to me tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
|