J323 home | previous page | next page


J323 usage patterns

(Last reviewed April 2000)

This section is for people who want to start writing communication applications on top of the J323 engine. As the J323 engine provides at its top the Java Telephony API this section explains how to write and where to find samples for JTAPI applications. We will discuss the following applications:

CPhone demonstration application

We have written the CPhone demo application to show the call control features of the J323 engine.

Installation

We provide demo scripts for Unix (Bourne Shell) and Windows (batch file). Please edit the file demo-env/demo-env.bat to adapt it to your Java environment:

If you run the demo on a Windows machine and you don't have a network connection change your TCP/IP configuration to enable the resolution of the name of the local host. (Failure to do so will freeze the application until DNS times out.) If the name of the local host is for example cadenazzo, enter the following line in the file c:\windows\hosts:

127.0.0.1 localhost cadenazzo

Running CPhone

The provided scripts do the following:

A sample screenshot of a running CPhone is shown in the figure below.

Figure 2: Sample CPhone screenshot

Sample CPhone screenshot  

There are three main areas:

Speed-dials work like on a normal telephone. Clicking on a speed-dial places a call to the specified target. Each speed-dial has a context menu for editing the target address and for invoking supplementary services that involve a third party.

The dial area in the top left corner is for placing calls to targets for which you don't have a speed-dial. Enter the target address in the text field and press the `call' button to place the call. You use the `invite' button to invite the target to an existing call/conference.

A detailed description of how you can exercise the advanced call control features of the J323 engine with the CPhone application is provided in J323 features.

Sample application code from the JTAPI documentation

The JTAPI documentation from Sun contains sample code for a simple JTAPI application. (See link below. The samples are called Incall and Outcall .) The code illustrates the basic functionality of both the core and call control packages. To run these samples with the J323 engine a number of adaptations and bug fixes are required.

Related links:
Class Incall.java

The sample application assumes a third-party call control scenario and therefore tells the JTAPI service provider which terminal to observe. The J323 engine however provides an interface for first-party call control. Thus it is more appropriate for the application to retrieve from the JTAPI service provider the name of the local terminal.

The J323 engine needs to go IN_SERVICE before an application can ask the Provider for Terminals. To keep the sample simple the code sleeps for a while (this is a hack!).


...
// Terminal terminal = myprovider.getTerminal("4761111");
// Allow JTAPI 1.2 provider to transition from
// OUT_OF_SERVICE to IN_SERVICE
Thread.sleep(10000);
// Retrieve default local terminal
Terminal terminal = myprovider.getTerminals()[0];
...

Class MyInCallObserver.java

Note that the lines dealing with termconn are in the wrong order (termconn is used before it is initialized).

Class Outcall.java

Here the same modifications are in order as for Incall.java.

To place an IP telephony call to another host the last parameter of the connect() method is the host name (instead of a telephone number).


...
// origaddr = myprovider.getAddress("4761111");
// Allow JTAPI 1.2 provider to transiton from
// OUT_OF_SERVICE to IN_SERVICE
Thread.sleep(10000);
// Retrieve default local address
origaddr = myprovider.getAddresses()[0];
...
// Connection c[] = mycall.connect(origterm, origaddr, "5551212");
Connection c[] = mycall.connect(origterm, origaddr, "<hostname>");

IBM CallPath Beans

IBM offers a downloadable version of a telephony toolkit that is compatible with the IBM CallPath Server (see link below). The Telephony Beans package contains

The sample application and a subset of the Beans run on both the CallPath JTAPI service provider and the J323 engine. This section explains which adaptations are necessary in conjunction with the J323 engine.

Related links

JtapiAppl sample application

Code changes

To use the 'JtapiAppl' sample application with the J323 engine the following code adaptations are required:

  • Retrieve the J323 JtapiPeer instead of the CallPath JtapiPeer by setting peerName = "com.ibm.telephony.mm.MM_JtapiPeer" .
  • Avoid deadlock by removing synchronized from doIt() (otherwise myCallObserver cannot report back events during myCall.connect(...) ).
  • To recompile define a dummy SmpCopyright class like
    class SmpCopyright { final static String SHORT_STRING = null; }
Running the application

The names of JTAPI Addresses and Terminals have to be specified as user names and host names (domain names). Upon program execution enter the following Provider Arguments:

  • CallPath Enterprise Server: "H.323 Endpoint"
  • Login: user name
  • For the password you may enter anything, as this version of the J323 engine ignores it.

Later you are prompted to select an "Originating Address". During initialization the J323 engine creates a default JTAPI Address and Terminal which the application retrieves and displays to you. The originating address you see corresponds to the previously specified user name ; the originating terminal has the name of the host the J323 engine is running on (domain name).

In the same menu you are asked to enter a "Destination Address". Enter the address in the form of a domain name (host name) or an IP address and surround it by square brackets, e.g., "[cadenazzo]". Press Enter and the Connect button to initiate a call to any H.323 compliant audio/video conferencing client.

IBM CallPath Beans

The IBM CallPath Beans are a set of Java Beans that use JTAPI to control telephony systems. Using these Beans, one can develop applications with or without a visual builder. However, connecting objects together using a visual builder is the easiest way to add telephony functions to an existing Java-based application or to develop new, telephony-enabled applications.

Since CallPath is aiming at providing Computer/Telephony Integration (CTI) for call centers, several of the provided Telephony Beans make use of the JTAPI call center package which is currently not supported by J323. However, in the IBM CallPath Beans documentation one can find a step by step example on how to create a simple phone application using the Beans and a visual builder (e.g. Visual Age for Java).

To adapt to the J323 engine a number of modifications are required which are explained in the remainder of this section. The headings follow those of the Java Programmer's Guide and Reference, Chapter 2.

Step 1: Add a CPLineResource

The following Bean properties must be set:

  • address: user name
  • lineResourceService: "H.323 Endpoint"
  • terminal: (The fully qualified domain name of the host the J323 engine is running on surrounded by square brackets, e.g., "[cadenazzo.zurich.ibm.com]". Note: We found that on some Windows systems we had to use the abbreviated domain name, i.e. "[cadenazzo]".)
  • user : user name
  • For the password you may enter anything, as this version of the J323 engine ignores it.
Step 2: Start the CPLineResource

Connect the application initialize() event to the start() method of the CPLineResource.

To retrieve the correct JTAPI peer insert manually the following program statement before calling CPLineResource.start() : CPLineResource1.setJtapiImplementation("com.ibm.telephony.mm.MM_JtapiPeer") . If you are using VisualAge for Java the statement can be added in the getCPLineResource() method call.

Step 3: Add the telephony action Beans

Associate the action Beans with the CPLineResource Bean by connecting the lineResourceAvailable() event to the respective associate(...) method together with passing the CPLineResource reference.

Step 4: Add visible controls

(No changes.)

Step 5: Connect visible controls to the model

Connect the textValueChanged() event of the destination TextField to the destination(..) method of MakeCall together with passing the updated text String.

Step 6: Set the enable and disable states of buttons

The animation of the buttons according the Make-/Answer-/DisconnectCall enable/disable Bean states is not supported since the initial state value is retrieved from various JTAPI capability queries (e.g., provider.getCallCapabilities().canConnect() , provider.getConnectionCapabilities().canDisconnect() , and provider.getTerminalConnectionCapabilities().canAnswer() ) which are not yet implemented in J323 and thus cause an invalid CPLineResource canDoAction() evaluation.

Step 7: Compile the code and test your application

(No changes.)

Note: A much more elaborate example of a JTAPI application with a graphical user interface is provided with J323 in the form of the CPhone demo application.


J323 home | previous page | next page

(c) Copyright 2000 IBM Corp.