cancel
Showing results for 
Search instead for 
Did you mean: 

.properties config files

former_member190457
Contributor
0 Kudos

Hi developers,

I know that WDJ allow .properties files to be accessed both by API and by Visual Admin.

I would like to do the same with properties file placed in a J2EE server component accessed by plain java object (pojo).

I know how to read files in a jar, but how should I make them visibile to Visual Admin?

I don't want to put my configs in WDJ because these are backend config files.

Can anyone help?

Thanks, regards

Vincenzo

Accepted Solutions (1)

Accepted Solutions (1)

siarhei_pisarenka3
Active Contributor
0 Kudos

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 and available for configuring your application/service.

BR, Sergei

former_member190457
Contributor
0 Kudos

Hi, thanks for your helpful reply

I usually access properties file with InputStream, using something like


Thread.currentThread.getContextClassLoader().getResourceAsStream("path to resource");

In this case could you please specify what the path to the resource is?

Thanks,

regards

Vincenzo

siarhei_pisarenka3
Active Contributor
0 Kudos

In the case you have to use SAP AS Java Configuration Adapter API:

 
InitialContext ctx = new InitialContext();

ConfigurationRuntimeInterface configRuntimeInterface = (ConfigurationRuntimeInterface) ctx.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

Answers (0)