JAIN(tm) SIP API

Standard Java(tm) Interface to the Session Initiation Protocol (SIP)

Release 0.6

 
Copyrights

See:
          Description

Packages
jain.protocol.ip This package contains the JAIN IP Factory, which is the central creation point for all high level proprietary JAIN IP objects, for example JainSipStack Objects.
jain.protocol.ip.sip This package contains the main interfaces required to represent JAIN SIP protocol stacks, JAIN SIP applications, as well as the classes and exceptions needed to send and receive JAIN SIP messages.
jain.protocol.ip.sip.header This package contains the classes representing SIP headers.
jain.protocol.ip.sip.message This package contains the Event classes representing SIP Messages.

 

 
Copyrights

Copyright - 2000 Sun Microsystems, Inc. All rights reserved.
901 San Antonio Road, Palo Alto, California 94043, U.S.A.

This product and related documentation are protected by copyright and distributed under licenses restricting its use, copying, distribution, and decompilation. No part of this product or related documentation may be reproduced in any form by any means without prior written authorization of Sun and its licensors, if any.

RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the United States Government is subject to the restrictions set forth in DFARS 252.227-7013 (c)(1)(ii) and FAR 52.227-19.

The product described in this manual may be protected by one or more U.S. patents, foreign patents, or pending applications.

TRADEMARKS

Sun, the Sun logo, Sun Microsystems, Java, Java Compatible, JavaBeans, Solaris,Write Once, Run Anywhere, JDK, Java Development Kit, and JavaStation are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and certain other countries. UNIX is a registered trademark in the United States and other countries, exclusively licensed through X/Open Company, Ltd. All other product names mentioned herein are the trademarks of their respective owners.

THIS PUBLICATION IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.

THIS PUBLICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION HEREIN; THESE CHANGES WILL BE INCORPORATED IN NEW EDITIONS OF THE PUBLICATION. SUN MICROSYSTEMS, INC. MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THIS PUBLICATION AT ANY TIME.



 

This document provides an overview of the JAIN SIP API, which is part of the JAIN SIP 1.0 Specification. It is not a tutorial, readers should have a good understanding of SIP and be comfortable reading the JAIN SIP API. This document, combined with the JAIN SIP API Requirements Specification, the JAIN SIP Reference Implementation (RI) Specification and the JAIN SIP Compatability Test Suite (CTS) Specification (described below) comprise the JAIN SIP 1.0 Specification.


 

The JAIN SIP API Requirements Specification

The Requirements Specification provides a high level overview of JAIN and the JAIN SIP API Specification as well as explaining the JAIN Architecture, and the functionality provided by each of the requirements defined within the document.

 

The JAIN SIP Reference Implementation (RI) Specification

The JAIN SIP Reference Implementation (RI) is a an example Java program that emulates the functions of a SIP stack in order to verify that JAIN SIP applications are compatible with the JAIN SIP specification. The RI can therefore be used to help develop and debug a JAIN SIP application in the absence of an JAIN SIP Compliant SIP Stack. The purpose of the the RI Specification is to outline the requirements for setting up the RI and to list the scope, limitations and restrictions of the RI.

 

The JAIN SIP Technology Compatibility Kit (TCK) Specification

The purpose of the JAIN SIP TCK is to verify that a JAIN SIP implementation is compatible with the JAIN SIP API Specification. The TCK Specification details the test cases which an implementation of JAIN interfaces must pass in order to be considered compliant with the JAIN SIP Specification.


 
 

Overview of JAIN SIP API

The implementation of this API focuses around the JainSipListener and JainSipProvider interfaces.A Listener could be any SIP User application, and would use a Provider to send SIP messages into the network. To send a SIP message, a Listener would send Message Events to a Provider.

The JainSipProvider interface defines the methods required to send SIP messages. This interface also defines the methods required to maintain a list of Event Listeners. An implementation of this interface would listen for SIP messages from the stack and forward these messages as Events to its registered Event Listeners. The SIP messages would be sent as Message Events.

Diagram 1 - Jain SIP message passing

An object implementing the JainSipProvider interface (a Provider) could be vendor specific and would act as a proxy for a ListeningPoint of a SIP Stack. Zero or more Event Listeners could register with a Provider, however the JAIN SIP API provides the ability to limit the number of Event Listeners that may register at any one time.
 
 

Diagram 2 - Listener registration with multiple Providers

The JainSipProvider interface defines the methods required to process any of the Events sent from a Provider. An object implementing the JainSipListener interface (a Listener) would register as an Event Listener of a Provider and would subsequently be able to receive Events from that Provider.

When a received SIP message arrives at the SIP Stack, the Provider forwards the SIP message as Message Events to its registered Listeners. Diagram 4.0 illustrates how an Event is distributed to Listeners.

Diagram 3 - Event Distribution


A JAIN SIP example

The following points illustrate how the JAIN SIP API can be used to send and receive SIP Messages. The example looks at the code of a Jain SIP User application and the steps the User application will use to create a JainSIPProvider for communicating with the proprietary SIP stack.
 
JainIPFactory singleton = JainIPFactory.getInstance();

singleton.setPath("com.dynamicsoft");

JainSipStack myStack = null;

try {

} catch (IPPeerUnavailableException e) {
}

ListeningPoint[] listeningPoints = null;

try {

    listeningPoints = myStack.getListeningPoints();

} catch (ListeningPointUnavailableException e) {

    // Stack has no ListeningPoints

    System.err.println("The underlying stack currently has no ListeningPoints");

}
 
 

    public JainSipListenerImpl(JainSipProvider myProvider) {

        try {

            myProvider.addJainSipListener(this);

        } catch (TooManyListenersException tooManyListeners) {

           System.err.println(tooManyListeners.getMessage());

        }
    }
 

    // Processing of RequestMessage received.

    public void processRequest(RequestMessage request, int transactionId){

        JainSipProvider eventSource = (JainSipProvider)request.getSource();

        // At this stage we only that the event is a RequestMessage
        // therefore we find out the request method.

        String method = request.getMethod();

        if (method.equals(InviteMessage.method)) {

            try {

                eventSource.sendResponse(transactionId, ResponseMessage.OK);

            } catch (TransactionDoesNotExistException e) {

                System.err.println(e.getMessage());

            } catch (SipException e) {

                System.err.println(e.getMessage());

            }

        } else if (method.equals(ByeMessage.method)) {

            try {

                eventSource.sendResponse(transactionId, ResponseMessage.OK);

            } catch (TransactionDoesNotExistException e) {

                System.err.println(e.getMessage());

            } catch (SipException e) {

                System.err.println(e.getMessage());

            }

        } else if (method.equals(AckMessage.method)) {

            processAck(((AckMessage)request), transactionId);

        } else if (method.equals(CancelMessage.method)) {

            processCancel(((CancelMessage)request)), transactionId);

        } else  {

            try {

                eventSource.sendResponse(transactionId, ResponseMessage.METHOD_NOT_ALLOWED);

            } catch (TransactionDoesNotExistException e) {

                System.err.println(e.getMessage());

            } catch (SipException e) {

                System.err.println(e.getMessage());

            }

        }

    }
 

    // Processing of AckMessage received.

    public void processAck(AckMessage ack, int transactionId){

        JainSipProvider eventSource = (JainSipProvider)ack.getSource();

        System.out.println("Received AckMessage on " + eventSource.getListeningPoint());

    }
 

    // Processing of CancelMessage received.

    public void processCancel(CancelMessage cancel, int transactionId){

        JainSipProvider eventSource = (JainSipProvider)cancel.getSource();

        System.out.println("Received CancelMessage on " + eventSource.getListeningPoint());

    }
 

    // Processing of ResponseMessage received.

    public void processResponse(ResponseMessage response, int transactionId){

        JainSipProvider eventSource = (JainSipProvider)response.getSource();

        String reasonPhrase = ResponseMessage.getStandardReasonPhrase(response.getStatusCode());

        System.out.println("Received ResponseMessage with a status \" + reasonPhrase + "\"");

    }
 

     // Processing of transaction timeout.

    public void processTimeout(int transactionId, boolean isServerTransaction){

        System.out.println("Transaction " + transactionId + " timed out");

    }

}



If you have any comments or queries, please mail them to JAIN-SIP-interest@sun.com


Copyright - 2000 Sun Microsystems