Croway opened a new pull request, #25301: URL: https://github.com/apache/camel/pull/25301
# CAMEL-24309: AiToolRegistry listener SPI for tool registration changes Sub-task of [CAMEL-24308](https://issues.apache.org/jira/browse/CAMEL-24308) (camel-mcp-server). JIRA: [CAMEL-24309](https://issues.apache.org/jira/browse/CAMEL-24309) ## Changes Adds a listener SPI to the `camel-ai-tool` registry so adapters can react to tools appearing/disappearing instead of polling — the prerequisite for the MCP server's `tools/list_changed` notification. - New `AiToolRegistryListener` interface with `toolRegistered(String tag, AiToolSpec spec)` / `toolDeregistered(String tag, AiToolSpec spec)`; `tag == null` denotes the default (untagged) pool, and a multi-tag endpoint fires one event per tag. - `AiToolRegistry.addListener/removeListener`; callbacks fire **outside** the registry lock (so a listener can safely re-read the registry), only on actual state changes (idempotent re-put of the same spec and removal of an absent spec fire nothing, a rejected duplicate-name registration fires nothing), and a throwing listener is logged without affecting the registration or other listeners. - Javadoc documents the subscribe-then-snapshot idiom for observing current state without missing concurrent events. Existing adapters (langchain4j-agent, spring-ai-chat) re-query the registry per exchange and are unaffected. ## Testing - `AiToolRegistryListenerTest` — registry-level semantics (8 tests: event on put/remove, default pool null tag, no event on no-op or rejected mutations, listener isolation, removeListener). - `AiToolRegistryListenerLifecycleTest` — events driven by real `ai-tool` route lifecycle (4 tests: start/stop, suspend/resume, multi-tag, untagged default pool). All 12 new tests pass; full `camel-ai-tool` module test run is green. --- _This PR was written by Claude Code on behalf of Federico Mariani (@Croway)._ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
