Solved

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

Posted on 2013-06-19
10
300 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
factorial example challenge 10 62
triangle challenge 4 79
noX challenge 17 77
eclipse compiler vs Installed JREs option 3 42
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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 …

747 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

8 Experts available now in Live!

Get 1:1 Help Now