1
1
/*
2
- * Copyright 2015-2020 the original author or authors.
2
+ * Copyright 2015-2021 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -38,16 +38,31 @@ public class HandlerAdapter {
38
38
39
39
private final DelegatingInvocableHandler delegatingHandler ;
40
40
41
+ /**
42
+ * Construct an instance with the provided method.
43
+ * @param invokerHandlerMethod the method.
44
+ */
41
45
public HandlerAdapter (InvocableHandlerMethod invokerHandlerMethod ) {
42
46
this .invokerHandlerMethod = invokerHandlerMethod ;
43
47
this .delegatingHandler = null ;
44
48
}
45
49
50
+ /**
51
+ * Construct an instance with the provided delegating handler.
52
+ * @param delegatingHandler the handler.
53
+ */
46
54
public HandlerAdapter (DelegatingInvocableHandler delegatingHandler ) {
47
55
this .invokerHandlerMethod = null ;
48
56
this .delegatingHandler = delegatingHandler ;
49
57
}
50
58
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
+ */
51
66
public InvocationResult invoke (Message <?> message , Object ... providedArgs ) throws Exception { // NOSONAR
52
67
if (this .invokerHandlerMethod != null ) {
53
68
return new InvocationResult (this .invokerHandlerMethod .invoke (message , providedArgs ),
@@ -67,6 +82,11 @@ else if (this.delegatingHandler.hasDefaultHandler()) {
67
82
}
68
83
}
69
84
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
+ */
70
90
public String getMethodAsString (Object payload ) {
71
91
if (this .invokerHandlerMethod != null ) {
72
92
return this .invokerHandlerMethod .getMethod ().toGenericString ();
@@ -76,6 +96,12 @@ public String getMethodAsString(Object payload) {
76
96
}
77
97
}
78
98
99
+ /**
100
+ * Get the method for the payload type.
101
+ * @param payload the payload.
102
+ * @return the method.
103
+ * @since 2.2.3
104
+ */
79
105
public Method getMethodFor (Object payload ) {
80
106
if (this .invokerHandlerMethod != null ) {
81
107
return this .invokerHandlerMethod .getMethod ();
@@ -100,6 +126,10 @@ public Type getReturnTypeFor(Object payload) {
100
126
}
101
127
}
102
128
129
+ /**
130
+ * Get the bean from the handler method.
131
+ * @return the bean.
132
+ */
103
133
public Object getBean () {
104
134
if (this .invokerHandlerMethod != null ) {
105
135
return this .invokerHandlerMethod .getBean ();
@@ -109,6 +139,13 @@ public Object getBean() {
109
139
}
110
140
}
111
141
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
+ */
112
149
@ Nullable
113
150
public InvocationResult getInvocationResultFor (Object result , Object inboundPayload ) {
114
151
if (this .invokerHandlerMethod != null ) {
0 commit comments