org.mobicents.protocols.mgcp.stack
Class TransactionHandler

java.lang.Object
  extended by org.mobicents.protocols.mgcp.stack.TransactionHandler
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
AuditConnectionHandler, AuditEndpointHandler, CreateConnectionHandler, DeleteConnectionHandler, EndpointConfigurationHandler, ModifyConnectionHandler, NotificationRequestHandler, NotifyHandler, RespUnknownHandler, RestartInProgressHandler

public abstract class TransactionHandler
extends Object
implements Runnable

Implements the base gateway control interface. The MGCP implements the media gateway control interface as a set of transactions. The transactions are composed of a command and a mandatory response. There are eight types of command:

  • CreateConnection ModifyConnection DeleteConnection NotificationRequest Notify AuditEndpoint AuditConnection RestartInProgress
  • The first four commands are sent by the Call Agent to a gateway. The Notify command is sent by the gateway to the Call Agent. The gateway may also send a DeleteConnection. The Call Agent may send either of the Audit commands to the gateway. The Gateway may send a RestartInProgress command to the Call Agent. All commands are composed of a Command header, optionally followed by a session description. All responses are composed of a Response header, optionally followed by a session description. Headers and session descriptions are encoded as a set of text lines, separated by a line feed character. The headers are separated from the session description by an empty line. MGCP uses a transaction identifier to correlate commands and responses. The transaction identifier is encoded as a component of the command header and repeated as a component of the response header. Transaction identifiers have values between 1 and 999999999. An MGCP entity shall not reuse a transaction identifier sooner than 3 minutes after completion of the previous command in which the identifier was used.

    Author:
    Oleg Kulikov, Pavel Mitrenko, Amit Bhayani

    Field Summary
    protected  jain.protocol.ip.mgcp.JainMgcpCommandEvent commandEvent
              Used to hold parsed command event
    protected  jain.protocol.ip.mgcp.message.parms.EndpointIdentifier endpoint
               
    static int LONGTRAN_TIMER_TIMEOUT
               
    static String MGCP_VERSION
               
    static String NEW_LINE
               
    protected  int remoteTID
              Transaction handle sent from application to the MGCP provider.
    protected  jain.protocol.ip.mgcp.JainMgcpResponseEvent responseEvent
              Used to hold parsed response event *
    protected  boolean retransmision
               
    protected  boolean sent
              Is this a transaction on a command sent or received?
    static String SINGLE_CHAR_SPACE
               
    protected  Object source
               
    protected  JainMgcpStackImpl stack
               
    static int THIST_TIMER_TIMEOUT
               
    protected static Timer transactionHandlerTimer
              Expiration timer
    protected  UtilsFactory utilsFactory
               
     
    Constructor Summary
    TransactionHandler(JainMgcpStackImpl stack)
              Creates a new instance of TransactionHandle Used by provider to prepare origination transaction for sending command message from an application to the stack.
    TransactionHandler(JainMgcpStackImpl stack, InetAddress remoteAddress, int port)
              Creates a new instance of TransactionHandle.
     
    Method Summary
    abstract  jain.protocol.ip.mgcp.JainMgcpCommandEvent decodeCommand(String msg)
              Decodes MGCP command message into jain mgcp command event object.
    abstract  jain.protocol.ip.mgcp.JainMgcpResponseEvent decodeResponse(String message)
              Decodes MGCP response message into jain mgcp response event object.
    abstract  String encode(jain.protocol.ip.mgcp.JainMgcpCommandEvent event)
              Encodes command event object into MGCP command message.
    abstract  String encode(jain.protocol.ip.mgcp.JainMgcpResponseEvent event)
              Encodes response event object into MGCP response message.
     String getEndpointId()
               
     int getLocalTID()
              Returns the transaction handle sent from MGCP provider to listener.
    protected  Object getObjectSource(int tid)
              constructs the object source for a command
    abstract  jain.protocol.ip.mgcp.JainMgcpResponseEvent getProvisionalResponse()
               
     int getRemoteTID()
              Returns the transaction handle sent from application to the MGCP provider.
     boolean isCommand()
               
     void markRetransmision()
               
     void receiveRequest(jain.protocol.ip.mgcp.message.parms.EndpointIdentifier endpoint, String msg, Integer remoteTID)
               
     void receiveResponse(String message)
              Used by stack for relaying received MGCP response messages to the application.
    protected  void release()
              Release this transaction and frees all allocated resources.
     void run()
               
    protected  void sendProvisionalResponse()
               
     void setCommand(boolean isCommand)
               
     void setCommandEvent(jain.protocol.ip.mgcp.JainMgcpCommandEvent commandEvent)
               
     void setResponseEvent(jain.protocol.ip.mgcp.JainMgcpResponseEvent responseEvent)
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    NEW_LINE

    public static final String NEW_LINE
    See Also:
    Constant Field Values

    SINGLE_CHAR_SPACE

    public static final String SINGLE_CHAR_SPACE
    See Also:
    Constant Field Values

    MGCP_VERSION

    public static final String MGCP_VERSION
    See Also:
    Constant Field Values

    LONGTRAN_TIMER_TIMEOUT

    public static final int LONGTRAN_TIMER_TIMEOUT
    See Also:
    Constant Field Values

    THIST_TIMER_TIMEOUT

    public static final int THIST_TIMER_TIMEOUT
    See Also:
    Constant Field Values

    sent

    protected boolean sent
    Is this a transaction on a command sent or received?


    remoteTID

    protected int remoteTID
    Transaction handle sent from application to the MGCP provider.


    stack

    protected JainMgcpStackImpl stack

    commandEvent

    protected jain.protocol.ip.mgcp.JainMgcpCommandEvent commandEvent
    Used to hold parsed command event


    responseEvent

    protected jain.protocol.ip.mgcp.JainMgcpResponseEvent responseEvent
    Used to hold parsed response event *


    transactionHandlerTimer

    protected static Timer transactionHandlerTimer
    Expiration timer


    utilsFactory

    protected UtilsFactory utilsFactory

    retransmision

    protected boolean retransmision

    source

    protected Object source

    endpoint

    protected jain.protocol.ip.mgcp.message.parms.EndpointIdentifier endpoint
    Constructor Detail

    TransactionHandler

    public TransactionHandler(JainMgcpStackImpl stack)
    Creates a new instance of TransactionHandle Used by provider to prepare origination transaction for sending command message from an application to the stack.

    Parameters:
    stack - the reference to the MGCP stack.

    TransactionHandler

    public TransactionHandler(JainMgcpStackImpl stack,
                              InetAddress remoteAddress,
                              int port)
    Creates a new instance of TransactionHandle. Used by stack to prepare transaction for transmitting message from provider to the application.

    Parameters:
    stack - the reference to the MGCP stack.
    Method Detail

    release

    protected void release()
    Release this transaction and frees all allocated resources.


    getRemoteTID

    public int getRemoteTID()
    Returns the transaction handle sent from application to the MGCP provider.

    Returns:
    the int value wich identifiers the transaction handle.

    getLocalTID

    public int getLocalTID()
    Returns the transaction handle sent from MGCP provider to listener.

    Returns:
    the int value wich identifiers the transaction handle.

    encode

    public abstract String encode(jain.protocol.ip.mgcp.JainMgcpCommandEvent event)
    Encodes command event object into MGCP command message. All descendant classes should implement this method with accordance of the command type.

    Parameters:
    event - the command event object.
    Returns:
    the encoded MGCP message.

    encode

    public abstract String encode(jain.protocol.ip.mgcp.JainMgcpResponseEvent event)
    Encodes response event object into MGCP response message. All descendant classes should implement this method with accordance of the response type.

    Parameters:
    event - the response event object.
    Returns:
    the encoded MGCP message.

    decodeCommand

    public abstract jain.protocol.ip.mgcp.JainMgcpCommandEvent decodeCommand(String msg)
                                                                      throws ParseException
    Decodes MGCP command message into jain mgcp command event object. All descendant classes should implement this method with accordance of the command type.

    Parameters:
    MGCP - message
    Returns:
    jain mgcp command event object.
    Throws:
    ParseException

    decodeResponse

    public abstract jain.protocol.ip.mgcp.JainMgcpResponseEvent decodeResponse(String message)
                                                                        throws ParseException
    Decodes MGCP response message into jain mgcp response event object. All descendant classes should implement this method with accordance of the command type.

    Parameters:
    MGCP - message
    Returns:
    jain mgcp response event object.
    Throws:
    ParseException

    getProvisionalResponse

    public abstract jain.protocol.ip.mgcp.JainMgcpResponseEvent getProvisionalResponse()

    run

    public void run()
    Specified by:
    run in interface Runnable

    sendProvisionalResponse

    protected void sendProvisionalResponse()

    getObjectSource

    protected Object getObjectSource(int tid)
    constructs the object source for a command

    Parameters:
    tid -
    Returns:

    isCommand

    public boolean isCommand()

    setCommand

    public void setCommand(boolean isCommand)

    setCommandEvent

    public void setCommandEvent(jain.protocol.ip.mgcp.JainMgcpCommandEvent commandEvent)

    setResponseEvent

    public void setResponseEvent(jain.protocol.ip.mgcp.JainMgcpResponseEvent responseEvent)

    markRetransmision

    public void markRetransmision()

    receiveRequest

    public void receiveRequest(jain.protocol.ip.mgcp.message.parms.EndpointIdentifier endpoint,
                               String msg,
                               Integer remoteTID)

    receiveResponse

    public void receiveResponse(String message)
    Used by stack for relaying received MGCP response messages to the application.

    Parameters:
    message - receive MGCP response message.

    getEndpointId

    public String getEndpointId()


    Copyright © 2012 TeleStax, Inc.. All Rights Reserved.