Solved

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

Posted on 2013-06-19
10
303 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
print map entry 34 72
How to convert String matching to regex in java 4 50
hashmap order 17 37
java mysql insert application 14 28
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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…
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

828 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