Here we describe setup and interaction with the asterisk dialplan.
You need at least the these jars in your classpath:
You retrieve the Asterisk JTAPI provider by issueing
JtapiPeer.getProvider("Asterisk; parameters"); where parameters
are in the form
name=value; name=value; .... Supported parameters
ServerIP address or hostname of your Asterisk box
PortPort number of the Manager Interface
Loginmanager login user
PasswordSecret for the asterisk manager login
IncomingContextContext of incoming calls, see Dialplan section below
TerminalContextContext of terminal, see Dialplan section below
OutgoingContextContext of outgoing calls, see Dialplan section below
The JTAPI standard allows an application to retrieve information about the addresses and terminals under control and their actual state. To avoid doubled configuration work we construct this information by analysing the Asterisk dialplan.
Before we go into detail some definitions from the JTAPI and Asterisk "worlds":
There are many different ways to construct an Asterisk dialplan. Let's start with an example: We have a trunk line with two digits direct dial in numbers. A straight-forward dialplan looks like this:
[dialin] ; telephone from jens routed to internal ISDN exten => 30,1,Dial(Zap/g2/30) ; telephone from birgit routed to her SIP phone exten => 31,1,Dial(SIP/birgit,30,r) ; hotline calls go to birgit exten => 24,1,Goto(31,1)
As we can see the extension ids 30 and 31 are routed to some endpoints and number 24 is just an alias of 31.
Asterisk JTAPI transfers such a dialplan automatically to meaningfull JTAPI objects: We get two terminals named 30 and 31. Terminal 31 has the address 31 and 24 and terminal 30 has just the address 30. To use this kind of dialplan set incomingContext and terminalContext to the same value (in the above example this is "dialin").
It is best practise to seperate terminals from the routing either by using a special number space or a different context for the terminals:
[terminals] ; telephone from jens routed to internal ISDN exten => jens,1,Dial(Zap/g2/30) ; telephone from birgit routed to her SIP phone exten => birgit,1,Dial(SIP/birgit,30,r) [dialin] exten => 30,1,Goto(terminals,jens,1) exten => 31,1,Goto(terminals,birgit,1) ; hotline calls go to birgit exten => 24,1,Goto(terminals,birgit,1)
Defined this way JTAPI application get two terminals named "jens" and "birgit". Terminal "jens" has the assigned address 30 and terminal "birgit" has the assigned address 31 and 24. In the Asterisk JTAPI configuration inscomingContext needs to be set to dialin and terminalContext needs to be set to terminals.
Now that we saw two example dialplans, lets define how the translation from dialplan to JTAPI object model is done. The dialplan is parsed and the JTAPI object model is constructed according to the following rules: