From 70d79b5ba540932cf8ae765dd05174c427019e26 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Wed, 24 Feb 2021 14:05:47 -0500 Subject: [PATCH] Javadocs for HandlerAdapter --- .../listener/adapter/HandlerAdapter.java | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/adapter/HandlerAdapter.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/adapter/HandlerAdapter.java index 3fec9b38..343bce63 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/adapter/HandlerAdapter.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/adapter/HandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 the original author or authors. + * Copyright 2015-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,16 +38,31 @@ public class HandlerAdapter { private final DelegatingInvocableHandler delegatingHandler; + /** + * Construct an instance with the provided method. + * @param invokerHandlerMethod the method. + */ public HandlerAdapter(InvocableHandlerMethod invokerHandlerMethod) { this.invokerHandlerMethod = invokerHandlerMethod; this.delegatingHandler = null; } + /** + * Construct an instance with the provided delegating handler. + * @param delegatingHandler the handler. + */ public HandlerAdapter(DelegatingInvocableHandler delegatingHandler) { this.invokerHandlerMethod = null; this.delegatingHandler = delegatingHandler; } + /** + * Invoke the appropriate method for the payload. + * @param message the message. + * @param providedArgs additional arguments. + * @return the invocation result. + * @throws Exception if one occurs. + */ public InvocationResult invoke(Message message, Object... providedArgs) throws Exception { // NOSONAR if (this.invokerHandlerMethod != null) { return new InvocationResult(this.invokerHandlerMethod.invoke(message, providedArgs), @@ -67,6 +82,11 @@ public class HandlerAdapter { } } + /** + * Get the method signature for the payload type via {@link Method#toGenericString()}. + * @param payload the payload. + * @return the method signature. + */ public String getMethodAsString(Object payload) { if (this.invokerHandlerMethod != null) { return this.invokerHandlerMethod.getMethod().toGenericString(); @@ -76,6 +96,12 @@ public class HandlerAdapter { } } + /** + * Get the method for the payload type. + * @param payload the payload. + * @return the method. + * @since 2.2.3 + */ public Method getMethodFor(Object payload) { if (this.invokerHandlerMethod != null) { return this.invokerHandlerMethod.getMethod(); @@ -100,6 +126,10 @@ public class HandlerAdapter { } } + /** + * Get the bean from the handler method. + * @return the bean. + */ public Object getBean() { if (this.invokerHandlerMethod != null) { return this.invokerHandlerMethod.getBean(); @@ -109,6 +139,13 @@ public class HandlerAdapter { } } + /** + * Build an {@link InvocationResult} for the result and inbound payload. + * @param result the result. + * @param inboundPayload the payload. + * @return the invocation result. + * @since 2.1.7 + */ @Nullable public InvocationResult getInvocationResultFor(Object result, Object inboundPayload) { if (this.invokerHandlerMethod != null) {