Entering content frame

Process documentation Configuration Service Locate the document in its SAP Library structure

Purpose

The configuraion service can be used for accessing configuration files that are deployed by a Web Dynpro application. The configuration data is available as name value pair in the properties files. The IWDConfigurationinterface provides methods for accessing this configuration data as typed objects.

Web Dynpro provides several configuration properties files. For information about these files, refer to Web Dynpro System Configuration and Configuring a Web Dynpro Application.

A Web Dynpro application can define its own configuration properties files - either at the level of a deployable object or at the level of a part of the deployed object. The IWDConfiguration interface also provides methods for accessing the properties files that you defined and using these properties files to read data.

Note

You can define application-specific properties files yourself. You can use any editor to create a properties file that contains corresponding name value pairs. You import this file into the corresponding directory structure in the Package Explorer:

·         If you want to use the properties file at the level of the deployable object (interface IWDDeployableObject), you must import the file into directory /src/configurations in your Web Dynpro project.

·         If you want to use the properties file at the level of the deployable object parts (interface IWDDeployableObjectPart), you must import the file into directory /src/configurations/<type of deployable object parts>/<name of deployable object parts> in your Web Dynpro project.
Types for deployable object parts are
Application, Component, or ComponentInterface. You can find a complete list of the types in the enumeration class com.sap.tc.webdynpro.services.sal.deployment.WDDeployableObjectPartType. When you deploy a Web Dynpro application that contains properties files either at the level of the deployable objects or at the level of the deployable object parts, these property files are deployed as properties sheets in the Configuration Adapterof the J2EE Engine. To change these properties files, you can use the Configuration Adapter service of the Visual Administrator of the J2EE Engine. You need not modify the source text or perform another deployment. You must restart the server if you changed a properties file in order for the changes to take effect.
Note
Note that redeployment of the development component overwrites all the changes to the properties files that were made with the Configuration Adapter.

Example

The following source code describes how to access the data of configuration properties files:

 

// All used classes are contained in package

// com.sap.tc.webdynpro.services.sal.config.api or

// com.sap.tc.webdynpro.services.sal.deployment.api.

 

// get the deployable object part for application

// “com.sap.test.CICApplication” of the deployable

// object “SPICe” using the WDConfiguration factory class

DeployableObject spiceDeplObj = WDDeployableObject.getDeployableObject(“SPICe”);

WDDeployableObjectPart[] applParts =

    spiceDeplObj.getParts(WDDeployableObjectPartType.APPLICATION);

WDDeployableObjectPart cicPart = null;

for ( int i=0; i<allParts.length; i++) {

    if ( allParts[i].getName().equals(“com.sap.test.CICApplication”) ) {

       cicPart = allParts[i];

       break; 

    }

}

// Note: You can access the deployable object part of the application you are

//currently in also by using the wdComponentAPI instance variable that

// is available in each generated Web Dynpro view:

WDDeployableObjectPart currentAppPart = wdComponentAPI.getApplication().getDeployableObjectPart();

 

// get the “CICApplication.properties” that belong to the deployable oject part

//named “com.sap.test.CICApplication”

IWDConfiguration cicConfig = WDConfiguration.getConfiguration(cicPart);

 

// alternatively, you can use the following call to access the property file

//named "CICApplication" under the deployable object part

//"com.sap.test.CICApplication"; you have to use this API in case you like

//to access property files which have a name not equal

//to the unqualified name of the deployable object part

IWDConfiguration cicConfig2 = WDConfiguration.getConfigurationByName(cicPart, "CICApplication");

 

// get the integer value of the property with name “prop1”

int prop1 = cicConfig.getIntEntry(“prop1”);

 

// get the boolean value of the property with name “prop2”,

// set a default value in case “prop2” is not contained in the

// properties

boolean prop2 = cicConfig.getBooleanEntry(“prop2”, false);

 

// get the configuration “my_config.properties” in the scope

// of the application part using the WDConfiguration factory class

IWDConfiguration myConfig =

    WDConfiguration.getConfigurationByName(cicPart, “my_config.properties”); 

 

// get the “default.properties” configuration belonging to the

// deployable object

IWDConfiguration spiceConfig = 

    WDConfiguration.getConfiguration(cicPart.getDeployableObject);

 

  

  

 

Leaving content frame