Shailendra Guggali

Ranch Hand
+ Follow
since Feb 01, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Shailendra Guggali

No, you should get it from the Database each time - so that itbecomes independent of the database, i.e., any additions to the database will automatically reflect in your search.
Its quite straightforward - get the record - get value - in array - get the appropriate index value - put in a collection to eliminate duplicates - add 'any' to the list and pass it to a combo box constructor
I read about SwingWorker but couldn't figure out how to use.
My bookTicket() goes something like this ::
Double click on the JTable row
MouseListener picks up - transfers to Controller which calls
bookTicket() method
bookTicket() method -
calls lock()
{
if record locked - wait()
// from here I want to tell the client that his // thread is waiting - and prevent him from using the JTable
when notifyAll() called -- moves out of wait
// again inform client that his request is now being processed
}
calls readRecord()
checks avail seats
calls modify()
calls unlock()
{
checks ClientID and removes record from HT
notifiesAll()
}
Now how do you perform invokeLater()
"If not, I would invokeLater at the GUI and from that call the lock while I would write to the Status line (or window)"
My main concern is that if the Client who is blocked, keeps doubleClicking on the JTablerow( thinking nothing is happening) it could create another problem - machine hangs. Is there a way we can disable listeners to the JTable till the lock is removed??
hi friend
I have a probelem which you might have already solved
When a Client is waiting in the lock method as that record is already locked by someone else, how do you convey this back to the Client.
lock( int recNum, String ClientID)
{
if(record not locked)
{
put this record in Hashtable
i.e., lock this record
}
else
{
wait();
till the unlock method is called by the earlier client which will call the notifyAll()
/// AT THIS STAGE HOW DO YOU INFORM THIS CLIENT
(GUI ) THAT THE RECORD IS LOCKED AND HE HAS TO WAIT.
}
}
I am using RMI
Thanx for sparing your valuable time
Shailendra
Ideally use the second approach but with MVC - i.e., let the action events be generated at the View and be passed to the controller to perform further actions(methods)
I thought on this too - but it seems impossible to have a locking which can cater to both the local and the server clients - As server clients would use one object of the Data class and the local client would use another. There is no common meeting place for the two except in the Database file - ( just for trial - try marking the record which has to be locked - just as a deleted record is marked).
Then I re-read the instructions and found that Sun expects the user to be EITHER in local or networked mode. So I have used locking for networked mode only.
Pls. also shed light on how are you planning to inform the Client that his thread is waiting - if the record is locked.
I have used the same method to CREATE ClientID for both the Socket and RMI networking : WORKS FINE ::: PLS COMMENT
I have a method called getClientID() which is present in the DataIMPL class( it extends the Data class)
This method creates a unique ID based on the
System.currentTimeMillis() method. A variable is created in this class to check whether the new ID created is same as the one created earlier - else increment it - convert to String and return to the CLIENT.
Now my reasoning is that since all client get the ID from the Server - the time is also in the same TIMEZONE - there is check at one place so it has to be unique.
When this is used by the CLIENT in all the methods it calls it remains uniform.
Seems too good to be actually true and working - PLS BLOW HOLES IN IT !!!
Thanx
Got something more :::
Some Design Patterns are a must for proper code :
1. Adapter Pattern / Factory :: for deciding between the TYPE of Connection :: Remote / Socket / Local / CORBA
2. MVC Pattern : For the GUI :: There is a MODEL to handle Data; a VIEW to create actual gui elements; and a CONTROLLER to control the actions - all the action Listeners report here and the actionPerformed happens here( the methods like bookTicket(), getClientID(), exit(), searchFlight(), etc)
3. Proxy Pattern : as used by RMI inherently
4. Reader / Writer Pattern for LOCKS
WARNING : Singleton pattern is the most debated - maybe most misused :: BUT almost all agree that it is really not required in this assignment.
Does one have to close something when one wants to exit???
The object you have is the remote object - You are closing with EXIT or WONDOWCLOSING - Do you need to do anything with this remote object like making it ready for Garbage Collection.
I tried to use the close() method, but it closes the RandomAccessFile Object and any more connections are refused due to NULL POINTER.
How do you exit the CLIENT gracefully with all programming etiquettes followed???
Thanx for replying
hi friends
why not build a checklist to ensure high scoring ( assuming the code works)- maybe a jist of what all the high scorers have commented -
Let me make a beginning :::::
1. the GUI should have a MENUBAR - at least shows you know how to make one - put HELP, EXIT, OTHER ITEMS equivalent of all the Buttons, etc - suggestion from ERNEST - the author of Java2 Certification Study Guide.
2. GUI should have ComboBoxes for selection of only ORIGIN & DEST airports - not JOptionPanes for input - not good HCI
3. Reg MODE of NETWORKING selection - both accepted equally well - command prompt entry / special GUI / or maybe use the menubar!!!
Pls add more -- one area at a time
hi ricardo
I have a peculiar RMI problem
All works fine the first time the server and clients are started but when you disconnect a client and try to connect again it gives null pointer exception - traced it to RandomAccessFile Object - it shows null the second time
WHY ?? What is different the second time
:::::::::RMI problem :::::::
I am using RMI
the first time the server is started and the clients login all works fine BUT if the Client exits and then logs in again it throws a Null pointer exception
I traced it an found that it gets a null reference to the RandomAccessFile object - the second time
Where do you think is the problem - what goes wrong the second time??
I have completed the assignment using Sockets. wanted to try RMI
I have a peculiar problem ==
The Client works fine the first time it is connected, but if I exit and then try to connect again it gives an exception which is :
Remote object = RMIServerDBAdapter_Stub[RemoteStub [ref: [endpoint:[127.0.0.1:10
80](remote),objID:[3ac748:e8735f5dd2:-8000, 0]]]]
in populate combobox
in populate combobox ::: no. of records = 24
Caught Exceptionnull
java.lang.NullPointerException
at Sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at RMIServerDBAdapter_Stub.getRecord(Unknown Source)
at RMIClientDBAdapter.getRecord(RMIClientDBAdapter.java:157)
at ComboPanel.populateComboBoxOfPort(ComboPanel.java:77)
at ComboPanel.makeInputPanel(ComboPanel.java:29)
at ComboPanel.<init>(ComboPanel.java:137)
at ClientFrame.<init>(ClientFrame.java:66)
at Client.main(Client.java:56)
in populate combobox == return airport = null
EXCEPTION In initializing client.
java.lang.NullPointerException
at javax.swing.DefaultComboBoxModel.<init>(Unknown Source)
at javax.swing.JComboBox.<init>(Unknown Source)
at ComboPanel.makeInputPanel(ComboPanel.java:29)
at ComboPanel.<init>(ComboPanel.java:137)
at ClientFrame.<init>(ClientFrame.java:66)
at Client.main(Client.java:56)
WHAT COULD THE PROBLEM BE?
WHEN I RESTART THE SERVER, EVERYTHING IS FINE.
I am creating registry via server code.
Where shd i start looking for problem?? Testing on one machine.
Pls comment
Thanx
Shailendra
Congrats Max good show
I have also completed my assignment but am stuck at 2-3 points -
could you pls help
1. I have not used any patterns as I never felt the need for any - which patterns according to you are absolutely necessary ??
2. What have you provided in the GUI menubar?? Is it needed at all?
3. Apart from Javadocs have you provided anyother help ( except for running instructions)??
Any other comment would be highly appreciated
All the best
I have used GBL - as it allows me to fix places for various components - I have a Frame in which there are 3 panels - in each one I have used GBL.
It is a bit time consuming but it is sure shot
If you want your code to be generic and the results to be dynamically decided then you have to use the column names from the database itself.
if the idea is to shorten the names, I can't think of any way to automatically reduce the size and yet be meaningful