Class TransactionAwareMessageHandlerAbstract

java.lang.Object
io.github.lunasaw.sip.common.transmit.event.message.TransactionAwareMessageHandlerAbstract
All Implemented Interfaces:
RequestHandler, MessageHandler, org.springframework.beans.factory.InitializingBean

public abstract class TransactionAwareMessageHandlerAbstract extends Object implements MessageHandler, org.springframework.beans.factory.InitializingBean
事务感知的消息处理器抽象基类 继承原有MessageHandlerAbstract,增强事务管理能力
Author:
weidian, luna (enhanced)
  • Constructor Details

    • TransactionAwareMessageHandlerAbstract

      public TransactionAwareMessageHandlerAbstract()
  • Method Details

    • parseRequest

      public static <T> T parseRequest(javax.sip.RequestEvent event, String charset, Class<T> clazz)
      解析请求内容为对象(静态方法保持兼容)
    • parseRequest

      public static String parseRequest(javax.sip.RequestEvent event, String charset)
      解析请求内容为字符串(静态方法保持兼容)
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • handForEvt

      public void handForEvt(javax.sip.RequestEvent event)
      Description copied from interface: MessageHandler
      处理消息
      Specified by:
      handForEvt in interface MessageHandler
    • getRootType

      public String getRootType()
      Description copied from interface: MessageHandler
      处理标签
      Specified by:
      getRootType in interface MessageHandler
      Returns:
    • getMethod

      public String getMethod()
      Description copied from interface: MessageHandler
      获取处理方法
      Specified by:
      getMethod in interface MessageHandler
      Returns:
    • getCmdType

      public String getCmdType()
      Description copied from interface: MessageHandler
      处理消息类型
      Specified by:
      getCmdType in interface MessageHandler
      Returns:
    • setXmlStr

      public void setXmlStr(String xmlStr)
      Description copied from interface: MessageHandler
      当前接受到的原始消息
      Specified by:
      setXmlStr in interface MessageHandler
    • getDeviceSession

      public DeviceSession getDeviceSession(javax.sip.RequestEvent event)
      获取设备会话(子类可重写)
    • responseAck

      public void responseAck(javax.sip.RequestEvent event)
      事务感知的ACK响应(优先使用事务上下文)
      Specified by:
      responseAck in interface MessageHandler
      Parameters:
      event - 请求事件
    • responseAck

      public void responseAck(javax.sip.RequestEvent event, javax.sip.ServerTransaction serverTransaction)
      事务感知的ACK响应(使用预创建的事务)
      Specified by:
      responseAck in interface MessageHandler
      Parameters:
      event - 请求事件
      serverTransaction - 预创建的服务器事务(可为null)
    • responseError

      public void responseError(javax.sip.RequestEvent event)
      事务感知的错误响应
      Specified by:
      responseError in interface MessageHandler
      Parameters:
      event - 请求事件
    • responseError

      public void responseError(javax.sip.RequestEvent event, Integer code, String error)
      事务感知的自定义错误响应
      Specified by:
      responseError in interface MessageHandler
    • getCurrentTransactionContext

      protected SipTransactionContext.TransactionContextInfo getCurrentTransactionContext()
      获取当前事务上下文信息
    • hasValidTransactionContext

      protected boolean hasValidTransactionContext()
      检查当前是否有有效的事务上下文
    • getCurrentTransactionInfo

      protected String getCurrentTransactionInfo()
      获取当前事务上下文的详细信息(用于日志和调试)
    • logTransactionContextStatus

      protected void logTransactionContextStatus(String operation)
      记录事务上下文状态(用于调试)
    • executeWithTransactionContext

      protected void executeWithTransactionContext(String operation, Runnable action)
      安全执行需要事务上下文的操作
    • handleWithTransactionContext

      protected void handleWithTransactionContext(javax.sip.RequestEvent event, String operation)
      事务感知的消息处理模板方法 子类可以重写此方法来利用事务上下文进行处理
    • doHandleWithContext

      protected void doHandleWithContext(javax.sip.RequestEvent event)
      子类实现的具体处理逻辑(在事务上下文中执行) 子类可以重写此方法来实现具体的业务逻辑
    • getHandlerStatusInfo

      public String getHandlerStatusInfo()
      获取处理器状态信息