Class AbstractProcessor<T>

java.lang.Object
org.aoju.bus.socket.process.AbstractProcessor<T>
All Implemented Interfaces:
NetMonitor, MessageProcessor<T>

public abstract class AbstractProcessor<T> extends Object implements MessageProcessor<T>, NetMonitor
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • AbstractProcessor

      public AbstractProcessor()
  • Method Details

    • afterRead

      public final void afterRead(AioSession session, int readSize)
      Description copied from interface: NetMonitor
      监控触发本次读回调Session的已读数据字节数
      Specified by:
      afterRead in interface NetMonitor
      Parameters:
      session - 当前执行read的AioSession对象
      readSize - 已读数据长度
    • afterWrite

      public final void afterWrite(AioSession session, int writeSize)
      Description copied from interface: NetMonitor
      监控触发本次写回调session的已写数据字节数
      Specified by:
      afterWrite in interface NetMonitor
      Parameters:
      session - 本次执行write回调的AIOSession对象
      writeSize - 本次输出的数据长度
    • beforeRead

      public final void beforeRead(AioSession session)
      Description copied from interface: NetMonitor
      即将开始读取数据
      Specified by:
      beforeRead in interface NetMonitor
      Parameters:
      session - 当前会话对象
    • beforeWrite

      public final void beforeWrite(AioSession session)
      Description copied from interface: NetMonitor
      即将开始写数据
      Specified by:
      beforeWrite in interface NetMonitor
      Parameters:
      session - 当前会话对象
    • shouldAccept

      public final AsynchronousSocketChannel shouldAccept(AsynchronousSocketChannel channel)
      Description copied from interface: NetMonitor
      监控已接收到的连接
      Specified by:
      shouldAccept in interface NetMonitor
      Parameters:
      channel - 当前已经建立连接的通道对象
      Returns:
      非null:接受该连接,null:拒绝该连接
    • process

      public final void process(AioSession session, T msg)
      Description copied from interface: MessageProcessor
      处理接收到的消息
      Specified by:
      process in interface MessageProcessor<T>
      Parameters:
      session - 通信会话
      msg - 待处理的业务消息
    • process0

      public abstract void process0(AioSession session, T msg)
      处理接收到的消息
      Parameters:
      session - 会话
      msg - 消息
      See Also:
    • stateEvent

      public final void stateEvent(AioSession session, SocketStatus socketStatus, Throwable throwable)
      Description copied from interface: MessageProcessor
      状态机事件,当枚举事件发生时由框架触发该方法
      Specified by:
      stateEvent in interface MessageProcessor<T>
      Parameters:
      session - 本次触发状态机的AioSession对象
      socketStatus - 状态枚举
      throwable - 异常对象,如果存在的话
      See Also:
    • stateEvent0

      public abstract void stateEvent0(AioSession session, SocketStatus socketStatus, Throwable throwable)
      Parameters:
      session - 会话
      socketStatus - 状态
      throwable - 线程
      See Also:
    • addPlugin

      public final void addPlugin(Plugin<T> plugin)