cancel
Showing results for 
Search instead for 
Did you mean: 

How can I load custom properties from the j2ee engine?

Former Member
0 Kudos

I have a J2EE application. I use a property file aze.properties. It includes property for the connection to sap and the links. These properties can always change. I want to change without to deploy the application. How can I make this? Can I start the J2EE engine with custom properties or classes?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks for the answer. Can I change the property, when the application is started from anyone users? Refresh the property automatically?

Former Member
0 Kudos

I have tested this code. When I have started the application with the property.

+++++ aze.properties ++++

ip = 10.195.160.95

The application read the property at first. Then I have changed the property file.

+++++ aze.properties ++++

ip = 10.195.160.96

I closed the browser and I started the application. The property is always 10.195.150.95. But it soul be 10.195.160.96.

What can I do?

Former Member
0 Kudos

Hi,

if you application is loading the properties file once, they you need to restart the application.

regards

Vivek Nidhi

Former Member
0 Kudos

Hi,

but I don´t want to restart the application. The property file shouldn't be read once. What can I do in this situation.

Regards,

Annett

Former Member
0 Kudos

Hi,

In that case every time you make a call to the socket, reload the properties file, you can write a java function which will reload the properties. call it before getting the socket every time.

Hope you understood my point. else please let me know.

regards

Vivek Nidhi

Former Member
0 Kudos

a crude way --->

1. have your xyz.properties file with some value as you mentioned

      1. xyz.properties###

A_PROPERTY = VALUE

2. read this property in the context listener of your web app and put the property value against property name in a hashtable in the application context..

3. have a dedicated page in your application to reload the properties file once it is changed to

      1. xyz.properties###

A_PROPERTY = NEW_VALUE

and once you read the new value, also refresh the values stored in application context EXPLICITELY...

-


Suggestion : Properties files are not a very good option for frequently changing key value pairs due to such reloading issue...try considering alternatives ...

Former Member
0 Kudos

Hi,

This can be done using a properties file. change the values in properties file as when you require, you dont need to restart or deploy the application. Unless you are not initializing the properties on start up. It can be in this way

Properties prop = new Properties();

try {

prop.load(new FileInputStream("filename.properties"));

} catch (IOException e) {

}

String value = prop.get("Key");

Also look into these links for more details. Even you can set a timer for reloading the properties again and again.

<a href="http://www.javaworld.com/javaworld/javatips/jw-javatip125.html">timer properties</a>

other related link

<a href="http://www.java-tips.org/java-se-tips/java.util/how-to-read-and-write-a-properties-file.html">prop files</a>

HTH

Vivek Nidhi