org.mobicents.mgcp.stack
Class TransactionHandler

java.lang.Object
  extended by org.mobicents.mgcp.stack.TransactionHandler
All Implemented Interfaces:
java.lang.Runnable, TransactionHandlerManagement
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, TransactionHandlerManagement

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

    Nested Class Summary
    protected  class TransactionHandler.ActionPerform
               
    protected  class TransactionHandler.ScheduleCommandSend
               
    protected  class TransactionHandler.ScheduleRequestReceival
               
    protected  class TransactionHandler.ScheduleResponseReceival
               
     
    Field Summary
    protected  java.util.LinkedList<TransactionHandler.ActionPerform> actionToPerform
               
    protected  jain.protocol.ip.mgcp.JainMgcpCommandEvent commandEvent
              Used to hold parsed command event
    protected  EndpointHandler endpointHandler
               
    static int LONGTRAN_TIMER_TIMEOUT
               
    static java.lang.String MGCP_VERSION
               
    static java.lang.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 java.lang.String SINGLE_CHAR_SPACE
               
    protected  java.lang.Object source
               
    protected  JainMgcpStackImpl stack
               
    static int THIST_TIMER_TIMEOUT
               
    protected static java.util.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, java.net.InetAddress remoteAddress, int port)
              Creates a new instance of TransactionHandle.
     
    Method Summary
     void clearEndpointHandler()
               
    abstract  jain.protocol.ip.mgcp.JainMgcpCommandEvent decodeCommand(java.lang.String message)
              Decodes MGCP command message into jain mgcp command event object.
    abstract  jain.protocol.ip.mgcp.JainMgcpResponseEvent decodeResponse(java.lang.String message)
              Decodes MGCP response message into jain mgcp response event object.
    abstract  java.lang.String encode(jain.protocol.ip.mgcp.JainMgcpCommandEvent event)
              Encodes command event object into MGCP command message.
    abstract  java.lang.String encode(jain.protocol.ip.mgcp.JainMgcpResponseEvent event)
              Encodes response event object into MGCP response message.
     EndpointHandler getEndpointHandler()
               
     java.lang.String getEndpointId()
               
     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
    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(java.lang.String msg)
               
     void receiveResponse(java.lang.String message)
              Used by stack for relaying received MGCP response messages to the application.
    protected  void release(boolean removeEndpointHandler)
              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 setEndpointHandler(EndpointHandler handler)
               
     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 java.lang.String NEW_LINE
    See Also:
    Constant Field Values

    SINGLE_CHAR_SPACE

    public static final java.lang.String SINGLE_CHAR_SPACE
    See Also:
    Constant Field Values

    MGCP_VERSION

    public static final java.lang.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 java.util.Timer transactionHandlerTimer
    Expiration timer


    utilsFactory

    protected UtilsFactory utilsFactory

    endpointHandler

    protected EndpointHandler endpointHandler

    retransmision

    protected boolean retransmision

    source

    protected java.lang.Object source

    actionToPerform

    protected java.util.LinkedList<TransactionHandler.ActionPerform> actionToPerform
    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

    setEndpointHandler

    public void setEndpointHandler(EndpointHandler handler)
    Specified by:
    setEndpointHandler in interface TransactionHandlerManagement

    getEndpointHandler

    public EndpointHandler getEndpointHandler()

    release

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


    clearEndpointHandler

    public void clearEndpointHandler()
    Specified by:
    clearEndpointHandler in interface TransactionHandlerManagement

    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 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

    public 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

    public 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

    public 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

    getProvisionalResponse

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

    run

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

    sendProvisionalResponse

    protected void sendProvisionalResponse()

    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)

    markRetransmision

    public void markRetransmision()

    receiveRequest

    public void receiveRequest(java.lang.String msg)

    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.

    getEndpointId

    public java.lang.String getEndpointId()


    Copyright © 2009. All Rights Reserved.