aspose file tools*
The moose likes JSP and the fly likes Common resource for all configurable parameters. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Common resource for all configurable parameters." Watch "Common resource for all configurable parameters." New topic
Author

Common resource for all configurable parameters.

Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Hi All,
I'm a newbie to programming . I was wondering , whether I could maintain a single file that would contain all the configurable parameters in a project . Example-- As of now I use a Connector class to manage my database connections, and have commented the various modifiable parameters throughout my code. Is there a place/way where I could maintain these parameters so that they can be modified easily (probably at the production environment ), instead of having to go through each file and then make the required change.
Thanks in advance.

Learning and Learning!-- Java all the way!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

properties file


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Hi Bear !
Thanks for replying and where does this properties file go?
Like is it in the same folder as my .java files , src folder ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

It depends how you want to read it.

If you want to use the classloader, it goes in the classes hierarchy. If you want to read it with the ServletContext, it goes in the WEB-INF hierarchy. If you want it to be independent of the web application (so that customers can edit it), then that's a whole 'nother ball of wax.

Which is your desire? For starters, is it internal or external to the application?
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Hm ,
I'd rather want it to be something external to the application so that my client can change the database connectivity URL or pagination size of my webpage without having to recompile the code . It would be great if you could shed some light on that.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

I'd start by researching java.util.PropertyResourceBundle.

The challenging part is deciding where to put the file external to the application and how to let the application know where that location is. Especially if it will change from client to client.
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Hi Bear,
Thanks for replying!
Two things
1. I find the ResourceBundle approach kinda complex , can you point me to any books that elicit their usage???
2.Secondly,is is it necessary to recompile my code if I were to follow the plain .properties file approach?
Thank you.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

1. What's complex? You create a PropertyResourceBundle instance passing an input stream to the properties file to the constructor.

2. No.
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Thanks for pointing me in the right direction! Reading up on it now . Will get back if necessary
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

thanks Bear!
I configured my resource bundle successfully!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Common resource for all configurable parameters.