Module bus.socket

Class AbstractPlugin<T>

java.lang.Object
org.miaixz.bus.socket.plugin.AbstractPlugin<T>
All Implemented Interfaces:
Monitor, Plugin<T>
Direct Known Subclasses:
BlackListPlugin, BufferPageMonitorPlugin, HeartPlugin, IdleStatePlugin, MonitorPlugin, RateLimiterPlugin, SocketOptionPlugin, SslPlugin, StreamMonitorPlugin

public abstract class AbstractPlugin<T> extends Object implements Plugin<T>
抽象插件
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • AbstractPlugin

      public AbstractPlugin()
  • Method Details

    • toHex

      public static String toHex(byte b)
      将字节转换成16进制显示
      Parameters:
      b - byte
      Returns:
      String
    • toHexString

      public static String toHexString(byte[] bytes)
      以16进制 打印字节数组
      Parameters:
      bytes - byte[]
    • process

      public boolean process(Session session, T data)
      Description copied from interface: Plugin
      对请求消息进行预处理,并决策是否进行后续的Handler处理 若返回false,则当前消息将被忽略。 若返回true,该消息会正常秩序Handler.process
      Specified by:
      process in interface Plugin<T>
      Parameters:
      session - 会话
      data - 待处理的业务消息
      Returns:
      the true/false
    • stateEvent

      public void stateEvent(Status status, Session session, Throwable throwable)
      Description copied from interface: Plugin
      监听状态机事件
      Specified by:
      stateEvent in interface Plugin<T>
      Parameters:
      status - 状态
      session - 会话
      throwable - 异常
      See Also:
    • shouldAccept

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

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

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

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

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