Solved

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

Posted on 2013-06-19
10
301 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
 

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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping3 challenge 14 69
firstswap challenge 20 65
Problem to start Neon 20 84
factorial example 4 34
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

914 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now