⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 overview.html

📁 JTAPI_html 用于JTAPI的HTML文档.
💻 HTML
📖 第 1 页 / 共 3 页
字号:
</P></CENTER><P>In the diagram above, discrete time steps are denoted by integers down thevertical axis. Time increases down this axis, and the integers have norelationship between real (clock) time.</P><P>This diagram, as a whole, represents a single telephone Call. In this case,the diagram represents a two-party telephone call (The<STRONG>Call.connect()</STRONG> method always results in a two-party call). Thediagram may be broken into two halves: the left half and the right half. Theleft half represents the originating-end of the telephone call and the righthalf represents the destination-end of the telephone call.</P><P>On the left-hand (originating) side of the diagram, the two veritcal linesrepresent the originating Terminal and Address (which are arguments to the<STRONG>Call.connect()</STRONG> method) objects, as indicated on the diagram. Thehorizontal lines represent either Connection objects or TerminalConnectionobjects as marked. Note that the Connection objects are drawn in the inner-most region, whereas the TerminalConnection objects are drawn in the outer-most region.</P><P>Similarly, on the right-hand (destination) side of the diagram, the twovertical lines represent the destination Address and Terminals. In thisexample, there are two destination Terminals associated with the destinationAddress. This configuration has been depicted previously in Figure 4. Notethat since there are two Terminals, there are two TerminalConnection objectson the destination side.</P><P>This diagram can be read as follows: as time increases, theConnection and TerminalConnection objects may or may not change states. Theappearance of a new Connection or TerminalConnection horizontal linecorresponds to a new object of that type being created during that time period.</P><P>In the example of placing a telephone call, we see that after the twoConnections are created in the IDLE state, the originating transitions tothe CONNECTED state, while the destination transitions to the INPROGRESSstate. At that time, a TerminalConnection to the originating Terminal iscreated and transitions to the ACTIVE state. When the destination Connectiontransitions to the ALERTING state, two TerminalConnections are created in theRINGING state.</P><P>At this point, a person at one of the destination Terminals answers the call.When this happens, that TerminalConnection moves to the ACTIVE state, and theother TerminalConnection moves to the PASSIVE state. Also, the destinationConnection concurrently moves to the CONNECTED state. When the telephone callends, all Connections move to the DISCONNECTED state, and allTerminalConnections move to the DROPPED state.</P><P>As a final point, this document has used the terms "logical" and "physical"view of a telephone call. This diagram makes these concepts clear. Anapplication can only monitor the state changes of the Connection object(i.e. the logical view). By looking at the diagram, the reader can hopefullyunderstand that these states provide a higher-level view of the progress of thetelephone call. The TerminalConnection state changes represent the physicalview. By monitoring the TerminalConnection state changes, applications canfind out what is happening at each physical endpoint.</P><BR><BR><H2><A NAME="OBSERVERS">The Java Telephony Observer Model</A><HR></H2><P>The Java Telephony API uses the Java observer/observable model to asynchronously notify the application of various changes in the JTAPI callmodel. These changes may include the state change of an object or the creationof an object.</P><P>The Provider, Call, Terminal, and Address objects have Observers. Theinterfaces corresponding to these observers are ProviderObserver,CallObserver, TerminalObserver, and AddressObserver, respectively.</P><P>The ProviderObserver reports all state changes to the Provider object. Forthe core package, this only include when the Provider changes state fromOUT_OF_SERVCE, to IN_SERVICE, to SHUTDOWN.</P><P>The Call observer reports state change information for all Connections andTerminalConnections that are part of the telephone call as well as statechanges to the Call itself. These state changes are not reported on either theAddress nor the Terminal observers.</P><P>At times, the application may want to monitor Address or Terminal objectsfor incoming telephone calls. In these instances, the application uses the<STRONG>Address.addCallObserver()</STRONG> or the<STRONG>Terminal.addCallObserver</STRONG> methods. These methods instruct theimplementation to automatically add a CallObserver to any calls that come toan Address or Terminal. These CallObservers are removed once the call leavesthe Address or Terminal.</P><P>The Address and Terminal observers report any state changes in these objects.In the core there are no events for these objects. The AddressObserver andTerminalObserver interfaces still exist, however, so other packages mayextend these interfaces.</P><BR><BR><H2><A NAME="EXAMPLES">Application Code Examples</A><HR></H2><P>This section presents two application code examples. The first placesa telephone call, and the second answers an incoming telephone call to aTerminal.</P><BR><BR><H3>Outgoing Telephone Call Example</H3><P>The following code example places a telephone call using the coreCall.connect() method. It, however, looks for the states provided by theCall Control package.</P><PRE>import java.telephony.*;import java.telephony.events.*;/* * The MyCallObserver class implements the CallObserver * interface and receives all events associated with the Call. */ public class MyCallObserver implements CallObserver {   public void callChangedEvent(CallEv[] evlist) {     for (int i = 0; i < evlist.length; i++) {       if (evlist[i] instanceof ConnEv) {         String name = null;        try {          Connection connection = evlist[i].getConnection();          Address addr = connection.getAddress();          name = addr.getName();        } catch (Exception excp) {          // Handle Exceptions        }        String msg = "Connection to Address: " + name + " is ");         if (evlist[i].getID() == ConnAlertingEv.ID) {          System.out.println(msg + "ALERTING");        }        else if (evlist[i].getID() == ConnInProgressEv.ID) {          System.out.println(msg + "INPROGRESS");        }        else if (evlist[i].getID() == ConnConnectedEv.ID) {          System.out.println(msg + "CONNECTED");        }        else if (evlist[i].getID() == ConnDisconnectedEv.ID) {          System.out.println(msg + "DISCONNECTED");        }      }      }  }}/* * Places a telephone call from 476111 to 5551212 */public class SampleOutcall {   public static final void main(String args[]) {     /*     * Create a provider by first obtaining the default implementation of     * JTAPI and then the default provider of that implementation.     */    Provider myprovider = null;    try {      JtapiPeer peer = JtapiPeerFactory.getJtapiPeer(null);      myprovider = peer.getProvider(null);    } catch (Exception excp) {      System.out.println("Can't get Provider: " + excp.toString());      System.exit(0);    }    /*    * We need to get the appropriate objects associated with the    * originating side of the telephone call. We ask the Address for a list    * of Terminals on it and arbitrarily choose one.    */    Address origaddr = null;    Terminal origterm = null;    try {      origaddr = myprovider.getAddress("4761111");       /* Just get some Terminal on this Address */      Terminal[] terminals = origaddr.getTerminals();      if (terminals == null) {        System.out.println("No Terminals on Address.");        System.exit(0);      }        origterm = terminals[0];    } catch (Exception excp) {      // Handle exceptions;    }      /*     * Create the telephone call object and add an observer.     */    Call mycall = null;    try {      mycall = myprovider.createCall();      mycall.addObserver(new MyCallObserver());    } catch (Exception excp) {      // Handle exceptions    }     /*     * Place the telephone call.     */    try {      Connection c[] = mycall.connect(origterm, origaddr, "5551212");    } catch (Exception excp) {      // Handle all Exceptions    }  }}</PRE><BR><BR><H3>Incoming Telephone Call Example</H3><P>The following code example illustrates how an application answers a Callat a particular Terminal. It shows how application accept calls when (and if)they are offered to it. This code example greatly resembles the core InCallcode example.</P><PRE>import java.telephony.*;import java.telephony.events.*;/* * The MyObserver class implements the CallObserver and * recieves all Call-related events. */ public class MyObserver implements CallObserver {   public void callChangedEvent(CallEv[] evlist) {     for (int i = 0; i < evlist.length; i++) {       if (evlist[i] instanceof TermConnEv) {        TerminalConnection termconn = null;        String name = null;         try {          TermConnEv tcev = (TermConnEv)evlist[i];          TerminalConnection termconn = tcev.getTerminalConnection();          Terminal term = termconn.getTerminal();          String name = term.getName();        } catch (Exception excp) {          // Handle exceptions.        }        String msg = "TerminalConnection to Terminal: " + name + " is ";         if (evlist[i].getID() == TermConnActiveEv.ID) {          System.out.println(msg + "ACTIVE");        }        else if (evlist[i].getID() == TermConnRingingEv.ID) {          System.out.println(msg + "RINGING")           /* Answer the telephone Call */          try {            termconn.answer();          } catch (Exception excp) {            // Handle Exceptions;          }        }        else if (evlist[i].getID() == TermConnDropped.ID) {          System.out.println(msg + "DROPPED");        }      }      }  }}/* * Create a provider and monitor a particular terminal for an incoming call. */public class SampleIncall {   public static final void main(String args[]) {     /*     * Create a provider by first obtaining the default implementation of     * JTAPI and then the default provider of that implementation.     */    Provider myprovider = null;    try {      JtapiPeer peer = JtapiPeerFactory.getJtapiPeer(null);      myprovider = peer.getProvider(null);    } catch (Exception excp) {      System.out.println("Can't get Provider: " + excp.toString());      System.exit(0);    }     /*     * Get the terminal we wish to monitor and add a call observer to that     * Terminal. This will place a call observer on all call which come to     * that terminal. We are assuming that Terminals are named after some     * primary telephone number on them.     */    try {      Terminal terminal = myprovider.getTerminal("4761111");      terminal.addCallObserver(new MyCallObserver());    }  }}</PRE><BR><BR><H2><A NAME="PROVIDER">Locating and Obtaining Providers</A><HR></H2><P>The Java Telehony API defines a convention by which telephony serverimplementations of JTAPI make their services available to applications.<P>The two elements that link an application to a server are:<P><H3><IMG SRC="images/magenta-ball.gif">JtapiPeerFactory</H3><OL>The JtapiPeerFactory class is the first point of contact for an application that needs telephony services.  It has the ability to return a named JtapiPeer object or a default JtapiPeer object. It is defined as a static class.</OL><P><H3><IMG SRC="images/magenta-ball.gif">JtapiPeer</H3><OL>The JtapiPeer interface is the basis for a vendor's particular implementationof the Java Telephony API. Each vendor which provides an implementation ofJTAPI must implement this interface in a class that can be loaded by theJtapiPeerFactory.<P>It is through a class that implements the JtapiPeer object that an applicationgets a Provider object.</OL<P><H3>JtapiPeerFactory: Getting Started</H3><p>The JtapiPeerFactory is a static class defined in JTAPI.  Its sole publicmethod, <EM> getJtapiPeer() </EM> gets the JtapiPeer implementationrequested or it returns a default implementation.<P><EM> getJtapiPeer() </EM> takes the name of the desired JTAPI serverimplementaion class as a parameter to return an object instance of that class.If no name is provided, <EM> getJtapiPeer() </EM> returns the defaultJTAPI server implementation object.<P><P><H3>JtapiPeer: Getting a Provider Object</H3></OL><p>JtapiPeer is an interface.  It is used by the JTAPI serverimplementors.  It defines the methods that applications use to getProvider objects, to query services available on those providers, andto get the name of the JtapiPeer object instance.  By creating a classthat implements the JtapiPeer interface, JTAPI implementations make thefollowing methods available to applications.<P>  Applications use the <EM>getProvider()</EM> method on this interfaceto obtain new Provider objects. Each implementation may support one ormore different "services" (e.g. for different types of underlying networksubstrate). A list of available services can be obtained via the<EM>getServices()</EM> method.<p>Applications may also supply optional arguments to the Provider. Thesearguments are appended to the string argument passed to the<EM>getProvider()</EM> method. The string argument has the followingformat:<p>&lt service name &gt ; arg1 = val1; arg2 = val2; ...<p>Where &lt service name &gt  is not optional, and each optional argument pairwhich follows is separated by a semi-colon. The keys for these argumentsis implementation specific, except for two standard-defined keys:<OL><LI>login: provides the login user name to the Provider.<LI>passwd: provides a password to the Provider.</OL>Applications use the <EM>getName()</EM> method to get the name of thisJtapiPeer object instance. It has a <EM> name </EM> parameter, whichis the same name used as an argument to <EM>JtapiPeerFactory.getJtapiPeer()</EM> method.</P><BR><BR><H2><A NAME="SECURITY">Security in the Java Telephony API</A><HR></H2><P>JTAPI peer implementations use the Java "sandbox" model for controllingaccess to sensitive operations.  Callers of JTAPI methods are categorizedas "trusted" or "untrusted", using criteria determined by the runtimesystem.  Trusted callers are allowed full access to JTAPI functionality.Untrusted callers are limited to operations that cannot compromise thesystem's integrity.</P><P>JTAPI may be used to access telephony servers or implementations thatprovide their own security mechanisms.  These mechanisms remain in place;parameters such as user name and password are provided through parameterson the  JtapiPeer.getProvider() method.</P> </FONT></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -