Entering content frame

Procedure documentation Modifying the Application Configuration Locate the document in its SAP Library structure

Use

Modifying the application configuration may involve:

·        Creating or deleting sub-configurations

·        Creating, deleting, or modifying configuration entries

These operations are provided by the methods of the com.sap.engine.frame.core.configuration.Configuration interface. For more information, see the J2EE Engine API documentation in the SAP NetWeaver Developer Studio documentation.

 

Prerequisites

·        You must have connected to the Configuration Manager

·        You must have opened the configuration in write mode.

 

Procedure

To modify the application configuration:

       1.      Invoke the relevant modification method on the configuration.

       2.      Commit the changes or rollback the transaction in case of error.

Caution

The write access to a configuration is strictly transactional. Therefore, you must always include code for completing the transaction.

The following example illustrates the modification of a configuration named “data”:

Example

//get a handler:

Context ctx = new InitialContext();

ApplicationConfigHandlerFactory appCfgHdlFctry =  

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

ApplicationConfigurationHandler cfgHandler = 

     appCfgHdlFctry.getApplicationConfigurationHandler();

 

Configuration data;

 

try {

 

  //open configuration "data" in write-mode

   boolean configObtained = false;

   data = null;

   while (!configObtained) {

      try {

         data =

            cfgHandler.openSubConfiguration(

               "data",

               ConfigurationHandler.WRITE_ACCESS);

         configObtained = true;

      } catch (ConfigurationLockedException e) {

         try {

            Thread.sleep(1000);

         } catch (InterruptedException f) {

         }

      }

   }

  ...

 

  //modify the configuration entry of "data", named "text".

  data.modifyConfigEntry("text", myText);

 

  ...

 

  //in case of success, commit the transaction

  cfgHandler.commit();

 

} catch (SomeException e) {

  //in case of exceptions, rollback the transaction

  cfgHandler.rollback();

 

} finally {

 

  cfgHandler.closeAllConfigurations();

  //alternatively, use: cfgHandler.closeConfiguration(data)

  ...

}

 

See also:

Exception Handling

 

 

Leaving content frame