Class DingTalkChannelRegistry

java.lang.Object
io.agentscope.extensions.channel.dingtalk.DingTalkChannelRegistry

public final class DingTalkChannelRegistry extends Object
Process-wide lookup table from channelId to DingTalkChannel instance. Used by DingTalkCallbackController to dispatch URL-routed requests onto the correct channel.

Channels running in http callback mode register themselves in DingTalkChannel.start() and remove on DingTalkChannel.stop(). The controller obtains the same singleton via instance() (no Spring wiring required), since the channel is created by ChannelFactory's static factory and the controller by Spring's component scan — neither knows about the other ahead of time.

Thread-safe: backed by a ConcurrentHashMap.

  • Method Details

    • instance

      public static DingTalkChannelRegistry instance()
      Returns the process-wide singleton instance.
    • register

      public void register(DingTalkChannel channel)
      Registers a channel under its channel id. Re-registering the same instance is a no-op; a different instance already holding the id fails fast — silently replacing it would divert the running channel's callbacks without a trace.
    • unregister

      public void unregister(String channelId, DingTalkChannel expected)
      Removes the registration for channelId only when it currently maps to expected, so a stale instance shutting down cannot detach a successor's registration.
    • get

      public DingTalkChannel get(String channelId)
      Returns the channel registered for channelId, or null if none.