?
Solved

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

Posted on 2013-06-19
10
Medium Priority
?
306 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
10 Comments
 
LVL 36

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 36

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 36

Accepted Solution

by:
mccarl earned 1500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month8 days, 22 hours left to enroll

764 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