ivr IVR Studio User Guide Table of Content << Previous  >> Next

Java Action

(Advanced software integration topic. Require Java programming knowledge)

An Java action is an action to invoke a Java method.

Create an Java Action

Actions can be created from the action properties of an element. Right click on any element, select Properties from the popup menu, select the action tab, then click the New button. From the Choose Action Type dialog window, select Java action. The following is a Java action of element Voicemail To Email from the Voicemail to Email sample.

This Java action defines the following:

  • The Java Class Name: voicent.sample.MyEmailSender
  • The method to be invoked: send
  • The parameters and values used by the method
  • Jar files that the Java class is defined and used: testjar.jar

Invoke a Java Action

The execution of a Java action involves the following steps:

  • Load the defined Jar files
  • Create a new object of the defined class for none-static method

The class must have a default constructor, it will be used to create the object.

  • Prepare arguments of the method based on parameter types and values defined

The parameter types is used to match the method signature

  • Invoke the Java method

Values are resolved and used to call the defined method

  • Set the action return variable based on method return

If the method returns java.util.Properties, the all the name value pairs are assigned to the action return variable.

For other return types, the value is converted to string by calling the toString method of the class. The string value is set to be the value of the action return variable, and the name of the return is "result". To access the return, use <action_name>.result, where <action_name> is the name of the action.

The Java Class

The Voicemail to Email sample has the full listing of the Java class. The function signature is listed here:

public class MyEmailSender
{
  // must have default constructor
  public MyEmailSender()
  {
    ...
  }
public boolean send(String wavfile, String emailto) {
... } }

 

ivr IVR Studio Table of Content << Previous >> Next