Meena Pitchiah

Greenhorn
+ Follow
since Apr 24, 2003
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 Meena Pitchiah

Hi,

I got my results after three weeks. Here is the actual breakdown.
Test: Sun Certified Developer for the Java 2 Platform (310-027)
Date Taken: 2003-10-01 19:56:16.360
Grade: P
Score: 150
Comment: This report shows the total points that could have been awarded in each section, and the actual number of points you were awarded. This is provided to give you per-section feedback on your strengths. The maximum possible score is 155; the minimum to pass is 124. General Considerations (maximum = 58): 58 Documentation (maximum = 20): 20 GUI (maximum = 24): 23 Server (maximum = 53): 49
Thanks to JavaRanch and all those people who helped me to acheive this.

regards
Meena
20 years ago
Hi Andrew,

I have submitted my assignment and took the essay exam on Friday. Thank you for all your help.

Thanks
Meena
Hi Badari,

Thanks for the information.


Skeleton??. Dont create it at all. Use rmic with an option for creating stubs only.


Is it Ok if I don't include the skeleton in the final jar. Since I already packaged and tested everything that way. Option -v1.2 is the only option which creates stubs for Java 2 stub protocol version. Is that right?
thanks,
Meena
Hi,
Don't we have to include the javadoc documentation files(I mean the .html files created using javadoc utility) in the final submission.
Also do we have to include the skeleton with the server jar though it is not used?
Thanks,
Meena
Hi Andrew,
Thanks for your comments.

Sun's requirements is


Record locking must be implemented using the methods public void lock(int) and public void unlock(int). These methods are required to allow concurrent use of the database when booking flights from multiple clients...


Here is my justification : these two methods are required when there are multiple clients. In the case of local mode there will be only one client and hence there is no need for locking. Data class will be used in the local mode. Only in the network mode there will be multiple clients accessing the database concurrently. So I feel RemoteData is the right place to implement these two methods.
I hope I understand the requirements correctly and my justification is reasonable. Please correct me if am wrong.


Normally in an MVC design, it is the model which models the data (and hence has all the accessor / modifier methods).


I wanted to implement a generic data server. Also business logic ( searchFlight, bookFlight and other methods) is application specific. So I implemented them in the client. These methods inturn call criteriaFind, read, lock, modify and unlock methods.(that are implemented in the model). Correct me if I am on trhe wrong track.

thanks,
Meena
Hi,
I am almost done with the assignment. Planning to submit it in few days. Thanks for all your help. I have listed down my server and GUI design. Please comment on it.

Server :
Patterns used : Adapter and Factory
  • Contains a high level interface called DataInterface. All the public methods in Data class are declared in the interface and all of them throws IOException. DataAdapter class implements DataInterface and contains an instance of Data. The RemoteDataInterface extends Remote and DataInterface. RemoteData implements RemoteDataInterface and

  • contains an instance of DataAdapter. The remote server contains RemoteConnectionInterface which extends RemoteInterface. RemoteConnectionFactory implements RemoteConnectionInterface.
  • When the Network server is started, An instance of RemoteConnectionFactory is created and Registered with the RMI Registry. getConnection() method in RemoteConnectionFactory class creates an instance of RemoteData each time when it is called.
  • Modified Data class. Implemented criteriaFind in Data.java. Implemented Left lock() and unlock() methods in RemoteData and left them blank in Data.
  • Implemented unrefernced() to handle dead clients.
  • Using GUI to start up and shutdown server. Server shutdown acquires DB lock and closes the db file and the server startup window. It does not inform the connected clients about the shutdown.


  • GUI :
    Patterns used: MVC and Facade (FBNController contains one instance of DataInterface to handle both local and network mode).
  • Using JDialog to get the connetion type and local/remote server connection.
  • Application contains a main window called FBNView implements. FBNView contains an instance of classes FBNController, SearchButton, BookButton, ResetButton, FBNTable, FBNTableModel and four instances of FBNComboBox (one for each search field - origin, destination, departure day and Carrier).
  • FBNController contains an instance of DataInterface (private) and methods to get connetion, search flights and book flight, populate all the comboboxes with values from the database fields.
  • All the button classes are derived from GenericButton which implements ActionListener. The actionPerformed() method is overriden by all these derived classes implements action to be performed when that button is pressed.
  • FBNCombobox extends JComboBox. Populates the combobox with values of that field from the database.
  • FBNTable extends JTable and implements ListSelectionListener. Implements valueChange() method. Also implements updateFlightTable() method which will be called when the search Panel needs to be updated (after search or booking a flight). Uses the pull model to update the table panel with matching flights with most current available seats.
  • FBNTableModel extends AbstractTableModel.


  • I think I have covered all the requirements. Any comments would be very helpful.
    Thanks,
    Meena
    [ September 07, 2003: Message edited by: Meena Pitchiah ]
    Hi Andrew,
    Thank you for your help.
    I got rid of this problem by changing the lock(), unlock() methods. Initially I was using synchronized methods. I changed to synchronized blocks and synchronized on the HashMap. Now I am able create threads withot any delay between stating the threads. I still don't know why my synchronized method did not work? Have to spend time on this.
    Thanks
    Meena
    Hi Andrew,
    Thanks for the information about the UBB Code.

    I noticed that you are using the 'this' reference to track ownership of the lock. This implies you have one instance of the Data class per connected client. If I am wrong then the remainder of these comments do not apply.


    I have one instance of RemoteData per client. But all these RemoteData instances refer to the same instance of Data and HashMap (used for locking / unlocking). I have given is my server design below. Can you please comment on this. You see any problem with this design which causes the original problem?
    Server Design :
  • I have an interface called DataInterface. My DataAdapter class implements DataInterface and contains an instance of Data object as a private member. Using Adapter pattern to satisfy the requirement "the implementation should include a class that implements the same public methods as the Data class..."
  • Using RMI for networking. RemoteDataInterface implements DataInterface and Remote. RemoteData class implements remote interface. RemoteData contains two private members

  • private DataAdapter adaptee;
    private HashMap lockMap;
  • Using factory pattern to create a RemoteData object for each client. The ConnectionFactory creates one instance of DataAdapter and HashMap. When the ConnectionFactory class creates RemoteData instance it passes the same instance of DataAdapter and HashMap. So all the RemoteData instances refers to the same DataAdapter (and Data indirectly) and HashMap.
  • Implemented unreferenced() in RemoteData.

  • Thanks,
    Meena
    [ September 04, 2003: Message edited by: Meena Pitchiah ]
    Hi,
    I am testing lock() with multiple clients. My test program spawns multiple threads and tries to book the same flight
    concurrently. I see some strange behaviour
    Created 3 threads. Each thread tries to book one ticket for the same flight. First two threads succeed in booking and
    unreferenced() gets called for those two RemoteData objects. Third one is waiting to acquire the lock. After that I have
    no idea what happens to that remote object which is waiting for the lock. If some delay is introduced between creation
    of threads it works perfect. All the threads succeed. Is it OK to introduce delay like this for testing. Can someone
    please help review my lock and unlock methods.

    Here is my lock and unlock methods of RemoteData class. Using HashMap for locking.

    thanks
    Meena
    [Andrew: Added [code] blocks to make this more readable]
    [ September 04, 2003: Message edited by: Andrew Monkhouse ]
    Hi Avi,
    Thank you so much. It works now. Can you please clarify one more problem?
    How can I get focus on some JtextField on window load. In a Dialog, I have JTabbedPane and two tabs. At the time of load, I need to select the first tab and place the cursor on the first entry field of that tab. I tried component.requestFocus, pane.requestFocus() (here the pane is the JPanel that contains the entry field). Also tried component.requestFocus() in windowOpened() of WindowListener. Nothing works. The focus is on the first tab when it is loaded.
    The requestFocus() works fine inside stateChanged() of ChangeEvent. So if I select the second tab and come back to the first one, the focus is on the entry field.
    Thanks
    Meena
    20 years ago
    Hi,
    This is a Swing related question. Posted it here since, someone in this will be able to help me.
    I am using setMnemonic() to set short cut key to buttons and using SystemLookandFeel.
    In Windows system, it does not underline the hot keys when loaded. After pressing Alt key once, everything seems to work fine (All the hot keys are underlined and pressing the hot key fires the button's action event).
    Has anyone faced similar problem.
    thanks
    Meena
    Hi,
    I am using setMnemonic() to set short cut key to buttons and using SystemLookandFeel.
    In Windows system, it does not underline the hot keys when loaded. After pressing Alt key once, everything seems to work fine ( all the hot keys are underlined and pressing the hot key fires the button's action event.
    Can anyone faced similar problem. Any suggestion please?
    20 years ago
    Hi Anitha,
    Where are located? Do you live in the US. If so let me know.
    Meena
    20 years ago
    Andrew,
    Thank you for your comments.
    I am planning to generate unique ID for each client and use it for locking and unlocking the records. I hope that will satisfy the requirement you mentioned. I have to test it.

    I have one more question in the case of ConnectionFactory:
    If each client gets an instance of RemoteData, which is a wrapper to Data, I think the adaptee (Data class) should be a singleton or pass the same instance of Data to the RemoteData constuctor. Can you please comment on this.
    Thanks,
    Meena
    Hi,
    I am working on Fly By Night.
    At the server side, I am using Adapter pattern to handle Local and network mode
    1. I have a top level interface called DataInterface. Changed the Data class (which come with the Assignment) to implement the DataInterface. I have the RemoteInterface which extends Remote and DataInterface. My remote implementation implements RemoteInterface and is the Adapter class. In order to acheive this, I have to change all the public methods in Data to throw IOException. Otherwise, compilation of RemoteData fails. Is it OK to make changes like this to the Data class (for the exam). Is there any other way to overcome this problem?
    2. My server is very simeple, creates rmi registry, only one instance of RemoteData and binds it to the registry. At any point of time there will be one instance of RemoteData. Initially I was thinking of using singleton pattern for Data class. I am not sure whether I still need to make Data a singleton.
    3. In the ranch I have seen many postings on using ConnectionFactory and creating a new instance of RemoteData for each client. Which is different from my design (item 2). Why do we have to do it this way. Trying to find out, whether I am missing any thing if I do it as per item 2.
    I very much appreciate your comments.

    Thanks
    Meena