cancel
Showing results for 
Search instead for 
Did you mean: 

Custom application configuration parameters without a properties file

Former Member
0 Kudos

Hello.

This has to be simple, but I can't find any documentation on this subject -- I have a Java application I'm deploying on the SAP J2EE AS. Right now it uses a properties file stored in the EAR which is read using getResrouceAsStream. The problem is that it means that any chance to the properties required re-building and re-deploying the EAR, which is a huge inconvenience for maintenance.

I'd like to store the configuration options in the AS, and be able to change them using Visual Admin -- I'm sure there has to be a way to do it, but I can't find where I can configure these custom application parameters and how do I read their values from the AS. It's fine if I need to restart the application after changing a value, I just want to avoid re-packging and re-deploying the EAR.

Any lead in the right direction would appreciated.

Thanks,

Alon

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi, Alon!

Use the ConfigurationManager:

[build connection|http://help.sap.com/saphelp_nw04/helpdata/en/45/e7e14b517b42788a1c166f9f32455e/content.htm]

[open configuration in r/w mode|http://help.sap.com/saphelp_nw04/helpdata/en/33/8439e52dc94c7192eb53f99854dfd6/content.htm]

Regards,

Thomas

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Alon,

Here is some more information

http://help.sap.com/saphelp_nw04/helpdata/en/03/37c0ba8b17466eb072ad0152a0fce3/content.htm

Regards

Ventsi Tsachev

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi Alon

You need to put your properties into special file with name sap.application.global.properties in folder META-INF of your J2EE application or service. After this they'll be visible in Visual Admin, in Offline Config Tool and be available for configuring your application/service.

After this In the case you can use NW Java Configuration Adapter API to read the properties programmatically:

ConfigurationRuntimeInterface configRuntimeInterface = (ConfigurationRuntimeInterface) new InitialContext().lookup("configuration");
ConfigurationContext configContext = configRuntimeInterface.getConfigurationContext();
ConfigurationHandler configHandler = configContext.getConfigurationHandler();

Configuration serviceConfig = configHandler.openConfiguration("cluster_data/server/cfg/...<your app name>", ConfigurationHandler.READ_ACCESS);
PropertySheet propSheet = serviceConfig.getPropertySheetInterface();
...
serviceConfig.close();

BR, Sergei