Setting the application environment

The application environment is controlled by setting the application properties. This is done automatically by the Java and VoiceXML environment for managed applications . (See Managed and unmanaged applications.) The Java and VoiceXML environment automatically retrieves the settings for the application environment, such as locale, from the configuration file. These application properties are returned in the form of an ApplicationProperties object (see The ApplicationProperties class). The Java and VoiceXML environment then invokes the WVRApplication.setAppplicationProperties() method to set the properties within the application.

Your application code must access these application properties in order to create a usable WVR object later on, to represent the base Blueworx Voice Response system. To access the application properties, use the WVRApplication.getApplicationProperties() method.

For example:
public class MyVoiceApp extends WVRApplication {
	
  public void voiceMain() throws WVRException {
	
    // Retrieve the application properties that have been loaded
    // automatically from the configuration file
    ApplicationProperties appProperties = this.getApplicationProperties();
	
    // The application properties will be used later on to create the WVR
    // object that makes or receives the telephone calls
    .
    .
    .
  }
  .
  .
  .
}

For unmanaged applications, the application properties are not loaded automatically. (See Managed and unmanaged applications.) In this case, you must define them within your application. To do this, create an ApplicationProperties object directly, with properties according to your environment.

For example:
public class MyVoiceApp extends WVRApplication {
	
	public void voiceMain() throws WVRException {
	
    // Create the application properties object
    ApplicationProperties appProperties = new ApplicationProperties();
	
    // The application properties will be used later on to create the WVR
    // object that makes or receives the telephone calls
    .
    .
    .
  }
  .
  .
  .
}
Note: If you create your own ApplicationProperties object, and then run the application managed, your application properties will be overriden by the AppName entry in the configuration file.
You can arrange your code so that your application can run managed or unmanaged. This will help you move your application from a test environment (where you will probably run it unmanaged) to a deployment environment (where it will be managed). For example:
public class MyVoiceApp extends WVRApplication {
	
  public void voiceMain() throws WVRException {
	
    // Retrieve the application properties that have been loaded automatically
    // from the configuration file
    ApplicationProperties appProperties = this.getApplicationProperties();
			
    // If the application properties are null (application is unmanaged), then
    // set the properties manually
    if (appProperties == null) {
      // Create the application properties object
      ApplicationProperties appProperties = new ApplicationProperties();
    }
		
    // The application properties will be used later on to create the WVR
    // object that makes or receives the telephone calls.
    .
    .
    .
  }
  .
  .
  .
}