Entering content frame

Procedure documentation Defining Application Properties

Use

The application configuration API enables you to define and use sets of properties for your application that are available to all its components at runtime.

Procedure

To define and use global application properties:

...

       1.      Include a standard Java property file named sap.application.global.properties in the META-INF directory of your application EAR, where the application.xml and the application-j2ee-engine.xml descriptors are also stored.

       2.      Access the properties from your application components using the following model:

Example

//get a handler:

Context ctx = new InitialContext();

ApplicationConfigHandlerFactory cfgHandler = (ApplicationConfigHandlerFactory)ctx.lookup("ApplicationConfiguration");

 

java.util.Properties appProps = cfgHandler.getApplicationProperties();

 

if (appProps==null) {

  //some reaction if no application properties are available.

} else {

  //extract properties

}

 

The Properties instance that you obtain is a copy of the application properties. Therefore, any modifications that you make do not affect other methods that access of the properties.

 

Leaving content frame