|
21 | 21 | */ |
22 | 22 | class ActorProxyImpl implements ActorProxy, InvocationHandler { |
23 | 23 |
|
| 24 | + private static final String UNDEFINED_CLASS_NAME = "io.dapr.actors.Undefined"; |
| 25 | + |
24 | 26 | /** |
25 | 27 | * Actor's identifier for this Actor instance. |
26 | 28 | */ |
@@ -136,29 +138,33 @@ public Object invoke(Object proxy, Method method, Object[] args) { |
136 | 138 | throw new UnsupportedOperationException("Actor methods can only have zero or one arguments."); |
137 | 139 | } |
138 | 140 |
|
| 141 | + ActorMethod actorMethodAnnotation = method.getDeclaredAnnotation(ActorMethod.class); |
| 142 | + String methodName = method.getName(); |
| 143 | + if ((actorMethodAnnotation != null) && !actorMethodAnnotation.name().isEmpty()) { |
| 144 | + methodName = actorMethodAnnotation.name(); |
| 145 | + } |
| 146 | + |
139 | 147 | if (method.getParameterCount() == 0) { |
140 | 148 | if (method.getReturnType().equals(Mono.class)) { |
141 | | - ActorMethod actorMethodAnnotation = method.getDeclaredAnnotation(ActorMethod.class); |
142 | | - if (actorMethodAnnotation == null) { |
143 | | - return invokeMethod(method.getName()); |
| 149 | + if ((actorMethodAnnotation == null) || UNDEFINED_CLASS_NAME.equals(actorMethodAnnotation.returns().getName())) { |
| 150 | + return invokeMethod(methodName); |
144 | 151 | } |
145 | 152 |
|
146 | | - return invokeMethod(method.getName(), actorMethodAnnotation.returns()); |
| 153 | + return invokeMethod(methodName, actorMethodAnnotation.returns()); |
147 | 154 | } |
148 | 155 |
|
149 | | - return invokeMethod(method.getName(), method.getReturnType()).block(); |
| 156 | + return invokeMethod(methodName, method.getReturnType()).block(); |
150 | 157 | } |
151 | 158 |
|
152 | 159 | if (method.getReturnType().equals(Mono.class)) { |
153 | | - ActorMethod actorMethodAnnotation = method.getDeclaredAnnotation(ActorMethod.class); |
154 | | - if (actorMethodAnnotation == null) { |
155 | | - return invokeMethod(method.getName(), args[0]); |
| 160 | + if ((actorMethodAnnotation == null) || UNDEFINED_CLASS_NAME.equals(actorMethodAnnotation.returns().getName())) { |
| 161 | + return invokeMethod(methodName, args[0]); |
156 | 162 | } |
157 | 163 |
|
158 | | - return invokeMethod(method.getName(), args[0], actorMethodAnnotation.returns()); |
| 164 | + return invokeMethod(methodName, args[0], actorMethodAnnotation.returns()); |
159 | 165 | } |
160 | 166 |
|
161 | | - return invokeMethod(method.getName(), args[0], method.getReturnType()).block(); |
| 167 | + return invokeMethod(methodName, args[0], method.getReturnType()).block(); |
162 | 168 | } |
163 | 169 |
|
164 | 170 | /** |
|
0 commit comments