Solved

Can we load properties file at runtime with out build / deployment required?

Posted on 2013-06-19
10
302 Views
Last Modified: 2013-07-06
Dear Experts,

I have a requirement, i.e usually all the labels / error messages we will get it from .properties file, so if you want to change the error message , The developer needs to change and he needs to prepare the war and must be deployed in the server to reflect the changes.

but i need to give this provision(changing the error message) to the customer, so i decided to store this .properties file in the DB, and customer can modify and he can upload it into the DB(we will provide screen for that), So whenever we  log in to application we will get updated .properties file from DB.

Here my question is i will provide a screen to upload this .properties in to DB, once it is uploaded , how will it be reflected with out taking build / deployment? i can retrieve from DB and store it in a specified position, but how can i tell to my application to pick the latest one.

Kindly do needful..

Kindly provide any other solution also to fulfill my above requirement....

Thanks in advance
0
Comment
Question by:prabhualla
  • 4
  • 3
  • 3
10 Comments
 
LVL 35

Expert Comment

by:mccarl
ID: 39261467
Where/how are you loading and using the .properties files? Do you load them directly via say the java.util.Properties class or some higher level abstraction from Spring, etc?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39261892
Why not just use the file system instead of db?
0
 

Author Comment

by:prabhualla
ID: 39264781
Thanks mccarl

i am using JSF framework, not with java.util.Properties
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:prabhualla
ID: 39264786
Thanks CEHJ,

As per my requirement, the customer can download this file, and can modify and re upload to db.
Please tell me is it possible to do with File system also?if possible please give me solution or code how we can do it?
0
 
LVL 35

Expert Comment

by:mccarl
ID: 39264844
i am using JSF framework
Getting closer to the answer... Do you mean via the <f:loadBundle ...> tag, or via faces-config, or some other way?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39265285
As per my requirement, the customer can download this file, and can modify and re upload to db.
Please tell me is it possible to do with File system also?
Yes, you can use a form upload. Not sure using the db would offer any advantage - i can think of disadvantages
0
 

Author Comment

by:prabhualla
ID: 39265301
Yee mccal I am using f:loadbundle only
0
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 39267713
Ok, so f:loadBundle from JSF, is based on Java's ResourceBundle. Two points about this...

If you look at the Javadoc for the .getBundle(3 args) method it doesn't necessarily load files from the filesystem in order to resolve your bundle. You can provide a Java class of the right name/package that extends from ResouceBundle, it will use that in order to lookup your messages/labels. So therefore, you can write a ResourceBundle subclass that retrieves these values from a Database. And then the f:loadBundle would work transparently, ie. it doesn't know exactly where the messages/labels come from, it just uses them
The second point though is that because f:loadBundle uses that 3 arg .getBundle() method, there is no control over the caching of the ResourceBundle implementation. Therefore, YOU need to take that into consideration if you do as above and implement a subclass yourself. ie, the naive way is to just pull the message/label direct from the DB everytime it is requested, but that may not perform so well. So you may want to cache values, but then you need to work out how often to invalidate that cache and reread from the DB in case something has been updated.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39267956
However you do this, you must be careful about the layers of your application, in particular, the confusion/conflation of system and user space in the app. I mean, you wouldn't (shouldn't) ever do something like provide the user with a mechanism to, say, switch classloaders in order to provide different functionality in user space.
Similarly, you need to ask yourself, if the user wants the possibility of different behaviours, then this should normally be occurring without too much reference to system space.

My example of classloaders is not entirely arbitrary of course, since it was ResourceBundle that made me think of them, since they are normally quite closely linked. They are normally in system space
0
 

Author Closing Comment

by:prabhualla
ID: 39304891
Tks for the solution
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HSSFWorkbook cannot be resolved error 10 68
split string containing \r\n in Java 46 43
java jdbc batch example 8 32
Error in @AspectJ Based AOP with Spring 2 13
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question