• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

question about assignment

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys:
I am confusing about a sentence in SUN assignment doc: If updates occur to a record that is being displayed on another client,then no change occurs at the other client.
Maybe it means:when a client is modifying a record,others cannot modify it,is right?
 
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. I believe all it means is that when one client changes a record, another client does not have to immediately reflect that change.
You do have to make sure two clients can modify the same record if enough seats are available, but yes, only one client at a time for a record. That is where locking will come into play.
 
dennis hu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thnaks Nate!Your help is very important to me.
And I hava anothr question:I had seen many guis had a execute.jar file,why? and what is included in the jar file?
I think we only two jar fles:client.jar,server.jar.
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by dennis hu:

And I hava anothr question:I had seen many guis had a execute.jar file,why? and what is included in the jar file?
I think we only two jar fles:client.jar,server.jar.


I think you probably just misread the messages... it probably said executable jar files, meaning that the client.jar and server.jar each have manifest files pointing to the file with the main method in it so that the jar knows which class to run when the jar is run.
[ August 29, 2002: Message edited by: Nate Johnson ]
 
dennis hu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys:
I create a model extends DefaultTableModel,it is easy to change the table data.But when there is not any flights to match the criteria,I donot know how to clear the table and show nothing,cos cannot use setDataVector(null,null).
What can i do??
 
dennis hu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
somebody can help me about the table question,
thanks!
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dennis,
Don't clear the table. Just pop up a dialog that says no flights matched the search criteria.
But if you are "hell-bent" on clearing the table and using a subclass of DefaultTableModel, then override setDataVector(Vector, Vector) so that if null is the value in the new Vector then call removeRow on every row in the table, otherwise call super.setDataVector(Vector, Vector). Or instead of calling removeRow just clear the protected dataVector member.
Hope this helps,
Michael Morris
[ August 30, 2002: Message edited by: Michael Morris ]
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by dennis hu:
I create a model extends DefaultTableModel,it is easy to change the table data.But when there is not any flights to match the criteria,I donot know how to clear the table and show nothing,cos cannot use setDataVector(null,null).
What can i do??


I am not sure how to use the DefaultTableModel... I am a web guy and only learned enough Swing to do the assignment... I used the AbstractTableModel and that gave me a lot of power to do what I wanted with the data...
My only idea for the DefaultTableModel would be to pass in a new Vector() that was empty and see what happens.
 
dennis hu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help!
Another question: I used TextFields to put in flight number,origin airport and destination airport.And I found some people use comboBox to put in these information,it is a good idea,but when I review the assignment instruction it says:
In the event of an invalid field name being provided as part of the criteria the behavior of this method is the same as if no records matched correctly specified criteria.
It means:client can put in the invalid field name.But if used the comboBox,client cannot put in the invalid field name,is right?
And if I use the comboxes,I will invoke findCriteria(String) method to find all records in db.db file,and add the flight numbr,origin airport and destination airport in different hashset.After visited all records in db.db file,I can get the single string result in hashset and add it to comboes,but when del or add a record in db.db file,what should i do?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dennis,


It means:client can put in the invalid field name.But if used the comboBox,client cannot put in the invalid field name,is right?


That's right. But your criteriaFind method should still check for invalid criteria and return an empty DataInfo[] in that case.


And if I use the comboxes,I will invoke findCriteria(String) method to find all records in db.db file,and add the flight numbr,origin airport and destination airport in different hashset.After visited all records in db.db file,I can get the single string result in hashset and add it to comboes,but when del or add a record in db.db file,what should i do?


In my search panel I subclassed JComboBox. Those classes were always notified when a search completed and each pertinent field was added to the Set keeping it up to date. Any time a criterion was set to "ANY" and a search was performed, then the particular Set would definitely be up to date. It's not a 100% deterministic but the odds are after any particular search, then eventually there will be a search with all criteria set to ANY to reload all the flights into the table. Don't worry about deleted records, if that happens and there are no more "SFA" origin flights available, then selecting that criterion will just result in no records being matched.
Hope this helps,
Michael Morris
 
dennis hu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Micheal,thanks for your reply!


Those classes were always notified when a search completed and each pertinent field was added to the Set keeping it up to date. Any time a criterion was set to "ANY" and a search was performed, then the particular Set would definitely be up to date. It's not a 100% deterministic but the odds are after any particular search, then eventually there will be a search with all criteria set to ANY to reload all the flights into the table.


You means:every time invoke findCriteria() method,you need to add those special fields to hashset,maybe you donot need to do it,only when del or add flight occured need to refresh the hashset to change the JComboBox.
But how do get the JComboBox content from db.db file,maybe by search all flights?


Don't worry about deleted records, if that happens and there are no more "SFA" origin flights available, then selecting that criterion will just result in no records being matched.


Maybe it is not up to date,why not fire a method to refresh JComboBox contents after deleted or add fligh?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dennis,


Maybe it is not up to date,why not fire a method to refresh JComboBox contents after deleted or add fligh?


Excellant idea. I just took the lazy way out. But how will you let the client know since those are server events?
Michael Morris
 
dennis hu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Micheal:
I think maybe some body want to deleted or add a flight in the future,as this event occured,we can invoke a fireModelChangEvent() to fire a event to view by a reference of DataInfo[],so can refresh squre panel on gui.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dennis,
But what if the addition/deletion ocurrs at a different client of at the server?

Michael Morris
 
dennis hu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Micheal:
It is a difficult thing.
Every time add/del flight,client must invoke the method add()/del() in server model,so in this method we can fire a notification to every view that had registried to server model.
But another thind is:
every client has a reference (stub)of server model,there is a ArrayList in server model contains client view reference.When a client connect to server,he will registry to the server(arraylist has client's view reference),and if the client want to disconncet to servr,he must remove the reference in arraylist.In there,I donot know how to deal with the concurrent question.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dennis,
I had a ServerEventService that was bound to the RMI registry along with the ConnectionFactory. It was really pretty simple to implement. You could do something similar and fire events from the server which would be sent to all registered clients whenever an addition/deletion occurred. Mine ran in a background thread on both server and client. If you want some more information about this, let me know and I'll detail how I implemented it.
Michael Morris
 
dennis hu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes,it is so excellent!
Thank you!
 
dennis hu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Micheal:
I am deploying my rmi,but there is a question occured.
Before now,I set these java files in a same path(but in different package).And now I want deploy them in different path.When I run server side,it ok,but when I run client side,a exceptin tell me had not used security,So I used security and policy on client side,but still had exception:
Error java.rmi.UmarshalException:
error unmarshalling return;
nested exception is: java.lang.ClassNotFoundException:suncertify.server.ProductServerImpl_stub.
The file is on the path very clearly,I donot know why this exceptin is occured.
Can you help me!
~Dennis Hu~
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dennis,
Everybody has that problem before they jar up the client and server. You don't need a security manager nor a policy file if you are not loading stubs dynamically. Just make sure that the necessary stub files are in the client jar. Don't forget to run rmic every time you compile your RMI classes either (I did that a lot ).
Hope this helps,
Michael Morris
 
dennis hu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Micheal:
Thanks for you reply!


I had a ServerEventService that was bound to the RMI registry along with the ConnectionFactory. It was really pretty simple to implement. You could do something similar and fire events from the server which would be sent to all registered clients whenever an addition/deletion occurred. Mine ran in a background thread on both server and client. If you want some more information about this, let me know and I'll detail how I implemented it.


Could you mind give me some details,I am so interested in it.
I will test my rmi deploy again and thanks again!
~dennis hu~
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dennis,
I had a detailed description in another post and tried searching for it but the @#!$% search engine here is as worthless as "tits on a boar hog" as we say in Texas. So I'll go thru it again:
You will need to create an event class that extends EventObject and implements Serializable (for RMI transport). My event class was named ServerEvent. You will need an interface that extends Remote and defines addXXXListener(listener) and removeXXXListener(listener) methods which throw RemoteException. My interface was named EventService and the methods were addServerListener(listener) and removeServerListener(listener). You will need to have a class that extends UnicastRemoteObject and implements this interface. It will also have to have method(s) to fire events. My implementation class was named ServerEventService and had one method to fire events named fireServerEvent(ServerEvent se). When this method was called, all registered ServerListeners (described next) had their serverStatusChanged() method called. This object should be bound to the server's RMI registry. You will need a listener interface that also extends Remote with method(s) for being notified when an event occurs. Mine was named ServerListener and its one method was serverStatusChanged(ServerEvent se). You will have to have a class that extends UnicastRemoteObject and implements this interface. Mine was named ServerEventListener. It will be instantiated on the client and not bound in the registry. The reason it has to be a Remote object is that the server will have to make calls on the client object. But put this class and its stubs in the server package to avoid dynamic loading problems. Run the client in a background thread and notify the registered client when an event arrives. I used an Observer pattern to do it. That's about it.
Hope this helps,
Michael Morris
[ August 31, 2002: Message edited by: Michael Morris ]
[ August 31, 2002: Message edited by: Michael Morris ]
 
dennis hu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Micheal:
Thanks for you help,I will read it careful!
~dennis hu~
 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Michael Morris:
Don't forget to run rmic every time you compile your RMI classes either (I did that a lot ).


Ant has an rmic command that does the job really good.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mag,
Yeah, I know that I need to start using Ant, but I'm something of an old fossil, preferring the command line to fancy stuff. I never cared much for using make either. I do think Ant is worth the time to learn though and will eventually start using it.
Michael Morris
 
dennis hu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Micheal and Mag:
I had heard this software,it is very useful to deploy app.
I already had a software named ANT,but I donot know how to set its evironment and how to use it.
Could you tell where I can find tutorial??
Looks forward your reply!
Thanks!
~dennis~
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dennis,
Here is the official documentation for ANT:
ANT Manual

It's not a tutorial in the truest sense, but there are examples and if you are familiar with make, it should be adequate to get you started.
Hope this helps,
Michael Morris
[ September 01, 2002: Message edited by: Michael Morris ]
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After reading a lot in this forum, I guess I know how to implement the LockManager, however I and not very clear how the LockManager is called?
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeff:
After reading a lot in this forum, I guess I know how to implement the LockManager, however I and not very clear how the LockManager is called?


I called it from my RemoteData object.
 
Jeff Shen
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Nate
Do you have the bookFlight method on the RemoteData? I designed the bookFlight on the client site and the bookFlight calls lock, read,modify,unlock. Dose this make sence?
Regards,
Jeff
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jeff,


I designed the bookFlight on the client site and the bookFlight calls lock, read,modify,unlock. Dose this make sence?


I hope so! That's what I did.
Michael Morris
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I only update the Origin and Destination combo boxes once when the system starts up. My reasoning is that these should be updated rarely. Is this OK as long as I explain my reasoning in the choices document?
Also, is anyone going through the trouble of changing the contents of the combo boxes, such that if I select an Origin of "DAL", the only destinations that I can select in the Destination combo boxes are flights with DAL as the origin? I hope that this is not a requirement.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi George,


I only update the Origin and Destination combo boxes once when the system starts up. My reasoning is that these should be updated rarely. Is this OK as long as I explain my reasoning in the choices document?


I think that's fine, like you say, odds are that's pretty stable data for any particular client session.


Also, is anyone going through the trouble of changing the contents of the combo boxes, such that if I select an Origin of "DAL", the only destinations that I can select in the Destination combo boxes are flights with DAL as the origin? I hope that this is not a requirement.


I debated it for a few days and finally decided against it. It would be a pretty cool thing to do though. Only you can determine whether it is worth the effort.
Hope this helps,
Michael Morris
 
dennis hu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Michael:
I have some questions,wish your help!
1: as you know,the table data in db.db file are all String type,how do you know their real data type:such as price,duration and seats.
2:I had a interface contains some static data:like
private static final int NAME=0;
String[] names={"RealName"};
If I had a String variable s="name",I want to get the String "RealName" in names array,I invoke s=s.toUppderCase(),So s="NAME",but I cannot use the method s=names[s] to get "RealName",What can I do?
3:I had a gui on server side to rebind ConnectionFactoryImpl,and no other thinds.
If I want to shut down the server but not use "CTRL+C",what command can I use?
Before I shut down the server,I must lock the database,do I need a reference in this gui?
Look forward your reply!
Thands!
~dennis hu~
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dennis,


1: as you know,the table data in db.db file are all String type,how do you know their real data type:such as price,duration and seats.


You know based on the schema (FieldInfo[]) and by observing the format of a record. For example, the Available Seats field is obviously an int and the Price field is a float. So you determine the type based on the field position. I had an interface named FBNConstants that defined constants to keep up with the field positions. Here is a portion of that interface:


2:I had a interface contains some static data:like
private static final int NAME=0;
String[] names={"RealName"};
If I had a String variable s="name",I want to get the String "RealName" in names array,I invoke s=s.toUppderCase(),So s="NAME",but I cannot use the method s=names[s] to get "RealName",What can I do?


You aren't a PERL programmer are you? Instead of using an array for names, you could use a HashMap to index Strings (keys) to Strings (values) or you could do something similar to my FBNConstants above to keep up with positions in the array so long as those positions are 100% deterministic.


3:I had a gui on server side to rebind ConnectionFactoryImpl,and no other thinds.
If I want to shut down the server but not use "CTRL+C",what command can I use?
Before I shut down the server,I must lock the database,do I need a reference in this gui?


I created a specialized class on the server to lock and shutdown the database. It had a reference to the Data object and the LockManager object. It only implemented lock() and unlock() (each of which always passed -1 to the lock manager regardless of the record parameter) and close(). So yes you will need a reference to gracefully shutdown the server.
Hope this helps,
Michael Morris
 
dennis hu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Michael:
Thanks for your reply!


I created a specialized class on the server to lock and shutdown the database. It had a reference to the Data object and the LockManager object. It only implemented lock() and unlock() (each of which always passed -1 to the lock manager regardless of the record parameter) and close(). So yes you will need a reference to gracefully shutdown the server.


Could you tell me more clearly?
Where to construct the specialized class and who could invoke the methods in this class?
What means regardless of the record parameter,maybe you have many chances to invoke this method?
And the server is always run,how to shut down it gracefully??
Look forward your reply!
~dennis hu~
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


And the server is always run,how to shut down it gracefully?


In my opinion, the graceful server shutdown is a nice feature, but it is out of scope for this assignment because it adds nothing to project clarity or extendibility. I have not implemented it in my design, and I got full score for my server design.
Eugene.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Eugene,
Where ya been? Not drinkin' vodka and tokin' with the kitties I hope?
Michael Morris
 
Jeff Shen
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A simple question
Should we let user input the hosname from command line or using
String hostName = InetAddress.getLocalHost().getHostName();
to detect the hosname.
Regards,
Jeff
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jeff,
What exactly are you wanting to do? If it is for looking up an RMI service on a server then getLocalHost() is not going to help you. The client must already know the host and the service name in order to locate and use that service. If it's for starting the server, just use "//localhost".
Hope this helps,
Michael Morris
[ September 05, 2002: Message edited by: Michael Morris ]
 
Jeff Shen
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Michael
What I mean is that the naming.bind method needs two parameters the first parameter is the hostname composite the port. I want to put the hostname in the method.
Regards,
Jeff
 
Yeah, but is it art? What do you think tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic