Class SyncMcpLoggingMethodCallback
java.lang.Object
org.springaicommunity.mcp.method.logging.AbstractMcpLoggingMethodCallback
org.springaicommunity.mcp.method.logging.SyncMcpLoggingMethodCallback
- All Implemented Interfaces:
Consumer<io.modelcontextprotocol.spec.McpSchema.LoggingMessageNotification>
public final class SyncMcpLoggingMethodCallback
extends AbstractMcpLoggingMethodCallback
implements Consumer<io.modelcontextprotocol.spec.McpSchema.LoggingMessageNotification>
Class for creating Consumer callbacks around logging consumer methods.
This class provides a way to convert methods annotated with
McpLogging into
callback functions that can be used to handle logging message notifications. It
supports methods with either a single LoggingMessageNotification parameter or three
parameters (LoggingLevel, String, String).- Author:
- Christian Tzolov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for creating SyncMcpLoggingConsumerMethodCallback instances.Nested classes/interfaces inherited from class org.springaicommunity.mcp.method.logging.AbstractMcpLoggingMethodCallback
AbstractMcpLoggingMethodCallback.AbstractBuilder<T extends AbstractMcpLoggingMethodCallback.AbstractBuilder<T,R>, R>, AbstractMcpLoggingMethodCallback.McpLoggingConsumerMethodException -
Field Summary
Fields inherited from class org.springaicommunity.mcp.method.logging.AbstractMcpLoggingMethodCallback
bean, method -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(io.modelcontextprotocol.spec.McpSchema.LoggingMessageNotification notification) Accept the logging message notification and process it.builder()Create a new builder.protected voidvalidateReturnType(Method method) Validates that the method return type is compatible with the logging consumer callback.Methods inherited from class org.springaicommunity.mcp.method.logging.AbstractMcpLoggingMethodCallback
buildArgs, validateMethod, validateParameters
-
Method Details
-
accept
public void accept(io.modelcontextprotocol.spec.McpSchema.LoggingMessageNotification notification) Accept the logging message notification and process it.This method builds the arguments for the method call and invokes the method.
- Specified by:
acceptin interfaceConsumer<io.modelcontextprotocol.spec.McpSchema.LoggingMessageNotification>- Parameters:
notification- The logging message notification, must not be null- Throws:
AbstractMcpLoggingMethodCallback.McpLoggingConsumerMethodException- if there is an error invoking the logging consumer methodIllegalArgumentException- if the notification is null
-
validateReturnType
Validates that the method return type is compatible with the logging consumer callback.- Specified by:
validateReturnTypein classAbstractMcpLoggingMethodCallback- Parameters:
method- The method to validate- Throws:
IllegalArgumentException- if the return type is not compatible
-
builder
Create a new builder.- Returns:
- A new builder instance
-