Cheat sheet on writing JTAPI client programs to access the PBX switch

  1. Get a userid and password for playpen.cs.cornell.edu.  This  workstation has the Lucent Tserver software loaded onto it.
  2. Make sure the Tserver software is up and running on that host. (You can run the sample program provided below.)
  3. Make sure tsapi.pro is in your classpath. The contents of tsapi.pro is provided below.
  4. Make sure that jtapi.zip, jtapi.jar, and/or package com.lucent.jtapi.tsapi is in your classpath.
  5. Make sure that jvax.telephony is in your classpath (you can download this from www.javasoft.com/product/jtapi).
  6. Compile and run your client program (a brief example follows). The Lucent implementation will set up a socket to an internet host named in the tsapi.pro file, using the port on which the Tserver is listening. Your call to the Provider.getProvider() method determines which Tserver you will use.

APPENDIX

Simple JTAPI client program:

// Donna Bergmark - CS 519 - October 1998
// MyPBX - an example jtapi program for accessing the PBX in Upson Hall
// 
// All this program does is access the PBX, get a provider, get and print
// the list of services, and then shut down.
import javax.telephony.*;
import com.lucent.jtapi.tsapi.*;
public class MyPBX {

    public static void main (String args[]) {

      System.out.println ("About to create a JtapiPeer");
      try {
	 // get Lucent's implementation of the JtapiPeer object
	 JtapiPeer jtapiPeer = JtapiPeerFactory.getJtapiPeer 
	    ("com.lucent.jtapi.tsapi.TsapiPeer");
	 System.out.println ("Got one! its name is " +
	    jtapiPeer.getName() );

    // We got our jtapiPeer.  Now create a provider.
	 // (Replace your-userid and your-password with what is relevant
	 // in your case)
	 try {
	 Provider provider = 
	    jtapiPeer.getProvider("LUCENT#G3_SWITCH#CSTA#PLAYPEN;"
	      + "login=your-userid; + "passwd=your-password);
	 System.out.println("Got a provider! It's name is " 
	      + provider.getName() );

	 // Wait for the provider to enter the ready state
	 while (provider.getState() != Provider.IN_SERVICE)
	 {
	    try{ Thread.sleep(1000);}
	    catch (Exception e){}
	    System.out.print(".");
	 }
	 System.out.println("Provider is in service");
	 provider.shutdown();  // This takes a minute or so
	 }
	 catch (PlatformException e) {System.out.println(e);}
      }
      catch (JtapiPeerUnavailableException e) {
	 System.out.println (e);
      }
      System.out.println ("That's it for now.");
      System.exit(0);X

  } // end main
}

Contents of tsapi.pro:

# tsapi.properties
#
# This file must be located in one of the directories found in CLASSPATH
#
# This is a list of the servers offering Telephony Services via TCP/IP.
# Either domain name or IP address may be used; default port number is 450
# The form is: host_name=port_number   For example:
#
# tserver.mydomain.com=450
128.84.223.24=450
playpen.cs.cornell.edu=450
#
# (Remove the '#' when creating actual server entries.)