org.mobicents.mgcp.stack
Class TransactionHandler

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

public abstract class TransactionHandler
extends java.lang.Object
implements java.lang.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
    static int LONGTRAN_TIMER_TIMEOUT
               
    protected  jain.protocol.ip.mgcp.JainMgcpResponseEvent responseEvent
              Used to hold parsed response event *
    protected  JainMgcpStackImpl stack
               
     
    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, java.net.InetAddress remoteAddress, int port)
              Creates a new instance of TransactionHandle.
     
    Method Summary
    protected abstract  jain.protocol.ip.mgcp.JainMgcpCommandEvent decodeCommand(java.lang.String message)
              Decodes MGCP command message into jain mgcp command event object.
    protected abstract  jain.protocol.ip.mgcp.JainMgcpResponseEvent decodeResponse(java.lang.String message)
              Decodes MGCP response message into jain mgcp response event object.
    protected abstract  java.lang.String encode(jain.protocol.ip.mgcp.JainMgcpCommandEvent event)
              Encodes command event object into MGCP command message.
    protected abstract  java.lang.String encode(jain.protocol.ip.mgcp.JainMgcpResponseEvent event)
              Encodes response event object into MGCP response message.
     int getLocalTID()
              Returns the transaction handle sent from MGCP provider to listener.
    protected  java.lang.Object getObjectSource(int tid)
              constructs the object source for a command
     int getRemoteTID()
              Returns the transaction handle sent from application to the MGCP provider.
     boolean isCommand()
               
     void receiveCommand(java.lang.String message)
              Used by stack for transmitting received MGCP command message to the application.
     void receiveResponse(java.lang.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()
               
     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

    LONGTRAN_TIMER_TIMEOUT

    public static final int LONGTRAN_TIMER_TIMEOUT
    See Also:
    Constant Field Values

    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 *

    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,
                              java.net.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

    protected abstract java.lang.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

    protected abstract java.lang.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

    protected abstract jain.protocol.ip.mgcp.JainMgcpCommandEvent decodeCommand(java.lang.String message)
                                                                         throws java.text.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:
    java.text.ParseException

    decodeResponse

    protected abstract jain.protocol.ip.mgcp.JainMgcpResponseEvent decodeResponse(java.lang.String message)
                                                                           throws java.text.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:
    java.text.ParseException

    run

    public void run()
    Specified by:
    run in interface java.lang.Runnable

    receiveCommand

    public void receiveCommand(java.lang.String message)
    Used by stack for transmitting received MGCP command message to the application.

    Parameters:
    message - receive MGCP command message.

    receiveResponse

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

    Parameters:
    message - receive MGCP response message.

    getObjectSource

    protected java.lang.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)


    Copyright © 2008. All Rights Reserved.