Define Configurable properties in an application and maintaining it using the J2EE Visual Administrator
Defining Configurable properties, would be of great help in any application deployment. A typical scenario that can be thought of would be, when an application is tested and promoted through a System landscape. i.e., when it moves from a development system to a testing system and finally on to a production system, some parameters are bound to change. Configurable properties come to the aid, with which the role of a programmer can be avoided.
When an application is developed and deployed using NetWeaver Developer studio, we can easily maintain these using available APIs. The steps for adding these configurable properties and maintaining it using the J2EE visual administrator are given below:-
- Create Development Component of type WebDynpro. Create an Application, Component and a view in this. Create a properties (simple text file which can be created using any text editor) file with the name ‘default.properties’ and put it in the src –> Configuration folder of the project. In this case the properties are maintained at the Deployable object level. The option is there to maintain these at the Deployable object part level, which are Application, Component or Component Interface. In this document the sample is shown to include it at the deployable object level.
- In the wdDoInit method write the following line of code: WDConfiguration.getConfiguration(“deployable object name (‘vendor name/project name’ in case of a DC)”).getStringEntry(“Key as maintained in the properties file.”);
This would get the value for the specified key as maintained in the properties file.
To maintain these values using the visual admin the following steps are needed:-
- Login to the Visual Administrator and select ‘Configuration Adapter’ under System ID –> Server Instance –> Services in the left side pane. Then in the right side pane expand webdynpro –> vendor name(com.wipro) –> project name(utilities).
- After having switched to ‘Change’ mode, double click on the ‘Propertysheet default’ entry. The following screen is obtained. This has all the Key value pairs maintained in the properties file.
- On double clicking on a particular property, the following screen is obtained where custom value can be maintained.
Note: If a custom value is maintained, a restart is required for this to take effect. Also if a re-deployment of the application is done, the values are overwritten by the properties file in the ear file.