• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NX: about Property file, Policy file and Logger file

 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Since this is the first time I use those files, I have some stupid Qs wanna ask.
I would like to ask:
1. Should both client and server contains their own property file?
2. Where should I put it? The instruction said the file should be named:
suncertify.properties. If I have 2 properties files, one for the server, and the other for the client, how should I do?
3. From Ken's post, I know he used java.util.logging.Logger class for debug messages. However, when I read Max's book, he mentioned that, we need to change the file for the logging properity. I would like to ask, if it is the case, can I submit the logging preperity file together with my source code, and ask the marker put it into the right place?
4. Following Q3, could we do the same (ask the marker to place the file to the right place) for the policy file for the network connection?
5. Could I fix some of the "paths" of the file? Since the instruction said we cannot ask the marker manually edit any files, for e.g., if I set the log directory (in the logger property file) to C:\SCJDA\log\server.log,
can I assume the marker (if he wants) read the log there?
Thanks a lot.
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nicholas,

1. Should both client and server contains their own property file?


No. As the file name is fixed and both client and server may run from the same directory on the same machine, you must accept the fact that the file may be shared.

2. Where should I put it? The instruction said the file should be named:
suncertify.properties. If I have 2 properties files, one for the server, and the other for the client, how should I do?


In the current directory (user.dir). As the file may be shared, a good practice is to prefix your property names with prefixs like "server.", "alone." and "client.".

3. From Ken's post, I know he used java.util.logging.Logger class for debug messages. However, when I read Max's book, he mentioned that, we need to change the file for the logging properity. I would like to ask, if it is the case, can I submit the logging preperity file together with my source code, and ask the marker put it into the right place?


I guess you are meaning a logging config file. I suppose you may do that, but I would ensure that your application still behave well in case your config file is not found (good logging property default values).

4. Following Q3, could we do the same (ask the marker to place the file to the right place) for the policy file for the network connection?


You don't need such a file IMO.

5. Could I fix some of the "paths" of the file?


I wouldn't do that. If you want to support logging to file(s), the current directory or the temp directory are better places IMO, because you're sure that such directories will be available to your application. Now logging to the console should be enough for the scope of this assignment. Keep it simple !
Best,
Phil.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Phil for replying.
I am nearly finished my suncertify.data package.
One more thing wants to know, in the interface that SUN provided, it contains 8 functions (create, delete, read, lock, isLocked, etc).
However, since the user requirement is, the only functions provided to the user are "BOOK" and "VIEW", do I in fact need to implement the rest functions? (although I had already implemented ALL for safety )
In addition, in my implementation, the isLocked function is never be used. Becos following Max's approach, if the server cannot get a lock on item X, it will wait. And even I first check whether item X is locked, when I applied the lock, it maybe acquired by other thread and my current thread still need to wait. So, I think this is not that useful, and I never use it. Is that possible?
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nicholas,

do I in fact need to implement the rest functions? (although I had already implemented ALL for safety )


Yes, but server-side only.

In addition, in my implementation, the isLocked function is never be used. Becos following Max's approach, if the server cannot get a lock on item X, it will wait. And even I first check whether item X is locked, when I applied the lock, it maybe acquired by other thread and my current thread still need to wait. So, I think this is not that useful, and I never use it. Is that possible?


I have no such an isLocked() method in my own instruction. You had to implement it and you did, so it's OK. If you don't need to use it, simply don't (as for create() and delete()).
Best,
Phil.
 
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nicolas,
Regarding the logging.properties file:
I set things up so that a default set of logging properties are used if the file is not found. I then, in choices.txt, alerted the tester of its existence in the overall jar file and said it could be used by copying it to the appropriate location.
kktec
SCJP, SCWCD, SCJD
"The journey is the reward."
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are there any methods that I can configure the Logger without the help of the logging.properties file?
At my current implementation, if I run on a machine with default setting, IOException will be thrown cos of the non-existence of the target log file.
Thanks for advice.
Nick.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nicholas Cheung:
Are there any methods that I can configure the Logger without the help of the logging.properties file?
Nick.


Hi Nicholas
Yes you can configure the Logger without properties, have a look at: http://java.sun.com/j2se/1.4.2/docs/guide/util/logging/overview.html
I've been running in the same problem. I choose a different approach. I made a LogHelper class with one static method getMyLogger. Every other class that wants to have a Logger can call this static method.
I am not quite sure by now, if this is ok. It is usually very ugly to swallow an exception but in this case i might do it this or in a similar way?
comments please?

 
reply
    Bookmark Topic Watch Topic
  • New Topic