Skip to content

Commit 70d79b5

Browse files
committed
Javadocs for HandlerAdapter
1 parent b95de43 commit 70d79b5

File tree

1 file changed

+38
-1
lines changed
  • spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/adapter

1 file changed

+38
-1
lines changed

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/adapter/HandlerAdapter.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2020 the original author or authors.
2+
* Copyright 2015-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,16 +38,31 @@ public class HandlerAdapter {
3838

3939
private final DelegatingInvocableHandler delegatingHandler;
4040

41+
/**
42+
* Construct an instance with the provided method.
43+
* @param invokerHandlerMethod the method.
44+
*/
4145
public HandlerAdapter(InvocableHandlerMethod invokerHandlerMethod) {
4246
this.invokerHandlerMethod = invokerHandlerMethod;
4347
this.delegatingHandler = null;
4448
}
4549

50+
/**
51+
* Construct an instance with the provided delegating handler.
52+
* @param delegatingHandler the handler.
53+
*/
4654
public HandlerAdapter(DelegatingInvocableHandler delegatingHandler) {
4755
this.invokerHandlerMethod = null;
4856
this.delegatingHandler = delegatingHandler;
4957
}
5058

59+
/**
60+
* Invoke the appropriate method for the payload.
61+
* @param message the message.
62+
* @param providedArgs additional arguments.
63+
* @return the invocation result.
64+
* @throws Exception if one occurs.
65+
*/
5166
public InvocationResult invoke(Message<?> message, Object... providedArgs) throws Exception { // NOSONAR
5267
if (this.invokerHandlerMethod != null) {
5368
return new InvocationResult(this.invokerHandlerMethod.invoke(message, providedArgs),
@@ -67,6 +82,11 @@ else if (this.delegatingHandler.hasDefaultHandler()) {
6782
}
6883
}
6984

85+
/**
86+
* Get the method signature for the payload type via {@link Method#toGenericString()}.
87+
* @param payload the payload.
88+
* @return the method signature.
89+
*/
7090
public String getMethodAsString(Object payload) {
7191
if (this.invokerHandlerMethod != null) {
7292
return this.invokerHandlerMethod.getMethod().toGenericString();
@@ -76,6 +96,12 @@ public String getMethodAsString(Object payload) {
7696
}
7797
}
7898

99+
/**
100+
* Get the method for the payload type.
101+
* @param payload the payload.
102+
* @return the method.
103+
* @since 2.2.3
104+
*/
79105
public Method getMethodFor(Object payload) {
80106
if (this.invokerHandlerMethod != null) {
81107
return this.invokerHandlerMethod.getMethod();
@@ -100,6 +126,10 @@ public Type getReturnTypeFor(Object payload) {
100126
}
101127
}
102128

129+
/**
130+
* Get the bean from the handler method.
131+
* @return the bean.
132+
*/
103133
public Object getBean() {
104134
if (this.invokerHandlerMethod != null) {
105135
return this.invokerHandlerMethod.getBean();
@@ -109,6 +139,13 @@ public Object getBean() {
109139
}
110140
}
111141

142+
/**
143+
* Build an {@link InvocationResult} for the result and inbound payload.
144+
* @param result the result.
145+
* @param inboundPayload the payload.
146+
* @return the invocation result.
147+
* @since 2.1.7
148+
*/
112149
@Nullable
113150
public InvocationResult getInvocationResultFor(Object result, Object inboundPayload) {
114151
if (this.invokerHandlerMethod != null) {

0 commit comments

Comments
 (0)