• Post Reply Bookmark Topic Watch Topic
  • New Topic

EAR application and defined constant accessible in ejb  RSS feed

 
daniele licitra
Ranch Hand
Posts: 81
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all.

I have an EAR application with ejb module and WAR module, with also some librari in simple jar.

I want to have a file (XML or properties) at EAR level containing some information, for example FTPURL=192.168.1.1
Then I need to access this properties in a simpler way in all the places (EJBs, JSF managed bean, ecc). This parameters must be accessible from everywhere in the app.

If in future the property change, i need only to disable application, change the value in the file and re-enable it.

Time ago i used a singleton EJB with string field, but if i need to change some value, i need to recompile. I used also DB, but i don't want to create a table for 2 values.

Does exists a simple and smart way for doing this?
 
Claude Moore
Ranch Hand
Posts: 877
8
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about saving values in appserver naming directory via jndi?
 
SaurabhRc Jain
Greenhorn
Posts: 12
Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure about the smartness of the solution, but my suggestion is -
Create a singleton class Configuration to read and store all configuration values from properties file.
Initialize this class during ear deployment.
Expose getters for the property value.

You can utilize java.util.Properties class.

Sample code to read properties file
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!