This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: suncertify.properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX: suncertify.properties" Watch "NX: suncertify.properties" New topic
Author

NX: suncertify.properties

Ulrich Heeger
Ranch Hand

Joined: Jun 06, 2003
Posts: 266
Hi everyone,
Now I�m trying to get my way to the handling of the suncertify.properties.
Ihave some questions concerning this point.
1.
In my submission, it�s written:

When you submit your assignment, each part (client and server) must be executable using a command of this exact form:
java -jar <path_and_filename> [<mode>]
Your programs must not require use of command line arguments other than the single mode flag, which must be supported. Your programs must not require use of command line property specifications. All configuration must be done via a GUI, and must be persistent between runs of the program. Such configuration information must be stored in a file called suncertify.properties which must be located in the current working directory.
The mode flag must be either "server", indicating the server program must run, "alone", indicating standalone mode, or left out entirely, in which case the network client and gui must run.

For all the three cases, I will start with a dialog box.
a.) For �server� , a dialog box will start, asking the User to type in two texfields the location of the db-file and the port-number. Perhaps also a button to shut-down the server.
b.)at the client side, there are two possibilities: �standalone� and nothing for network client. Here also a dialog box will start. For �standalone� a textfield where the user can type in the location of the db-file; for the empty mode flag two textfields for the hostname and the port-number. After we have confirmed these informations, the dialog-box is closed and the GUI-client opens.
I don�t know if this is a good approach. I would be glad about comments.
2.
a)Because I don�t have much experience concerning DNS, IP etc. I just want to know, if the User can determine the hostname at the server-side? The IP of course can�t be influenced by our Java-application, but the hostname? So eventually, if the hostname can arbitrairly be determined by the User, at the "server" dialog box, there could also be a textfield to type in the hostname?
b)Should the client address the server by IP or by hostname?
3.
I have read some threads concerning the properties, but I�m still a little bit confused why you guys are making differences for the db-Path in standalone or networking mode. I mean, the location of the db-file I have to enter for the �server� or the �standalone�- dialog box, should be the same, or do I miss something?
4.
As default db-location I have following String:

I must admit that I�m not very familiar with other OS than Windows (I imagine everybody rolling his eyes;.)) so I don�t know if this String would be valuable for other vendors.
Since the User can type in the textfield of the �server� dialog box the vendor-specific path encoding, I would be fine!?
Are my assumptions correct?
5.;
Vlad lead me through the implementation of the Properties-classes, thanks Vlad. So the properties will be stored when the User clicks the Connect/Ok-Button.
Now my question, concerning the further handling of the DB-Location.
I�m using the ConnectionFactory, my code there looks like:

I don�t know if you guys have a similar implementation. I mean do you load the properties once more from suncertify.properties or do you pass them as arguments directly from the dialog box to the Server and store them there in an instance variable , so suncertify.properties doesn�t need to be loaded once more?
I hope my questions don't sound stupid ,
I would be very thankfull if you could help me...
Greetings
Ulrich
[ November 07, 2003: Message edited by: Ulrich Heeger ]
Vlad Rabkin
Ranch Hand

Joined: Jul 07, 2003
Posts: 555
Hi Ulrich,
1. Sounds very good
2. if the User can determine the hostname at the server-side?

3.
Should the client address the server by IP or by hostname

It doesn't matter. I have only one field "hostname". It doesn't matter if a user enters ip or hostname there.
4.
why you guys are making differences for the db-Path in standalone or networking mode.

Let's say you want to start a remote database and local database on the same computer. Each database should use different database file. How can you do it having one "dbfile" property.
5. Ulrich, it is not correct: I don't load properties form the file in getDBPath() method. I do it only in Constructor. I feel there Properties object with all values from the file. getDBPath() get an apprpriate value from the properties. It doesn't read properties (load) from the file, when getXXX invoked:

Best,
Vlad
[ November 07, 2003: Message edited by: Vlad Rabkin ]
Paul Tongyoo
Ranch Hand

Joined: Sep 30, 2003
Posts: 91

I asked the server admin to explicitly input the server's hostname/ip since my computers are given a NAT IP from my router and I believe that getHostName() function would return that IP instead of my (reachable) WAN IP. Or is there another way around this problem?

Let's say you want to start a remote database and local database on the same computer. Each database should use different database file. How can you do it having one "dbfile" property.

It sounds like you're trying to run the program in two modes at once. Is this functionality out of scope of Sun's specs? I'd imagine if Sun wanted to run a local and remote database simultaneously they'd run two separate JVMs for two invocations of the program, each loading their own respective database file.
Regards,
Paul
[ November 07, 2003: Message edited by: Paul Tongyoo ]

Sun Certified Java Web Component Developer for J2EE v1.4<br />Sun Certified Java Developer for J2SE v1.4<br />Sun Certified Java Programmer for J2SE v1.4
Ulrich Heeger
Ranch Hand

Joined: Jun 06, 2003
Posts: 266
Hi Vlad, hi Paul,
thank you for your help.
Vlad, you wrote:

Let's say you want to start a remote database and local database on the same computer. Each database should use different database file. How can you do it having one "dbfile" property.

Ah, does it mean with these different properties you will ensure the possibility of different locations for the remote database and local database, discarding our situation where we have only one database for remote and local connection?
5. Ulrich, it is not correct: I don't load properties form the file in getDBPath() method. I do it only in Constructor. I feel there Properties object with all values from the file. getDBPath() get an apprpriate value from the properties. It doesn't read properties (load) from the file, when getXXX invoked:

Sorry for confusion, my mistake. I have understood you correctly. At the ServerProperties-class, for the getDBPath() method I have also:

But I need this property once more at my ConnectionFactoryImpl-class.
I suppose you want to suggest that like at the Server-GUI I should create in my ConnectionFactoryImpl one instance of ServerProperties-Class?
So using SeverProperties' getDBPath()-method and not to create a new getDBPath()-method for ConnectionFactoryImpl?
Thanks in advance
Ulrich
Ulrich Heeger
Ranch Hand

Joined: Jun 06, 2003
Posts: 266
Hi everyone,
Sorry that my questions were perhaps a little bit misleading, so I will post one of them once more:
As default db-location I have following String:

I must admit that I�m not very familiar with other OS than Windows (I imagine everybody rolling his eyes;.)) so I don�t know if this String would be valuable for other vendors.
Since the User can type in the textfield of the �server� dialog box the vendor-specific path encoding, I would be fine!?
Are my assumptions correct?
Regards
Ulrich
Paul Tongyoo
Ranch Hand

Joined: Sep 30, 2003
Posts: 91


Hi Ulrich--
I believe a safe route would be to have the textfield be initially blank at your first run of the GUI, but then create a File object (let's call it dbFile) from the user's valid file input and save whatever is returned from the dbFile.getAbsolutePath() command in your properties file. I believe I've read somewhere that this operation should return whatever absolute path format that is compatible with the host computer's filesystem.

Regards,
Paul
[ November 07, 2003: Message edited by: Paul Tongyoo ]
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11465
    
  94

Hi Ulrich
Originally posted by Ulrich Heeger:
Ah, does it mean with these different properties you will ensure the possibility of different locations for the remote database and local database, discarding our situation where we have only one database for remote and local connection

It is also possible that the same physical database may appear to be in two separate locations depending on who is using it. Consider this as an example:
When the client first gets the software from you, they install it onto the server (so that it will get backed up), but while they are testing it, they only want to run it in local mode from one user's PC. From that user's perspective, the database may be in "Z:\SCJD\DB.DB"
Later they decide to open it up for everyone to use, so they start your server mode on the server computer itself. From the server's perspective, the same database may now appear to be in "C:\SOFTWARE\SCJD\DB.DB".
The same thing can happen in Linux / Unix. For security, when a user logs into the computer, they may be "chroot"ed to hide parts of the server that they should not have access to. So as an end user, the database may appear as /scjd/db.db but to the administrator it may appear as /virt/scjd/db.db.
Originally posted by Ulrich Heeger:
As default db-location I have following String:

I must admit that I?m not very familiar with other OS than Windows (I imagine everybody rolling his eyes;.)) so I don?t know if this String would be valuable for other vendors.

I agree with Paul's comments above.
If you really want to provide a base path though (or are creating paths anywhere else in your application), then please look at what the File.pathSeparator field can do for you.
Originally posted by Ulrich Heeger:
Since the User can type in the textfield of the ?server? dialog box the vendor-specific path encoding, I would be fine!?
Are my assumptions correct?

You might also want to look at using a FileChooser
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Ulrich Heeger
Ranch Hand

Joined: Jun 06, 2003
Posts: 266
Hi Paul, hi Andrew, hi Vlad
thank you very much for your help, that's really cool to have guys like you, Phil and others who can lead me newbie through this stuff. I wouldn't manage it without you.
Thanx, thanx, thanx
Ulrich
 
GeeCON Prague 2014
 
subject: NX: suncertify.properties