Class DingTalkChannelRegistry
java.lang.Object
io.agentscope.extensions.channel.dingtalk.DingTalkChannelRegistry
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 Summary
Modifier and TypeMethodDescriptionReturns the channel registered forchannelId, ornullif none.static DingTalkChannelRegistryinstance()Returns the process-wide singleton instance.voidregister(DingTalkChannel channel) Registers a channel under its channel id.voidunregister(String channelId, DingTalkChannel expected) Removes the registration forchannelIdonly when it currently maps toexpected, so a stale instance shutting down cannot detach a successor's registration.
-
Method Details
-
instance
Returns the process-wide singleton instance. -
register
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
Removes the registration forchannelIdonly when it currently maps toexpected, so a stale instance shutting down cannot detach a successor's registration. -
get
Returns the channel registered forchannelId, ornullif none.
-