17
17
package org .springframework .graphql .data .method .annotation .support ;
18
18
19
19
import java .lang .reflect .Method ;
20
- import java .lang .reflect .Type ;
21
- import java .util .Arrays ;
22
20
import java .util .Collection ;
23
21
import java .util .Collections ;
24
22
import java .util .LinkedHashSet ;
28
26
import java .util .concurrent .Callable ;
29
27
import java .util .concurrent .Executor ;
30
28
import java .util .function .Predicate ;
31
- import java .util .stream .Collectors ;
32
29
33
30
import graphql .schema .DataFetcher ;
34
31
import org .apache .commons .logging .Log ;
@@ -258,13 +255,12 @@ protected Set<M> detectHandlerMethods() {
258
255
continue ;
259
256
}
260
257
Class <?> beanClass = context .getType (beanName );
261
- findHandlerMethods (beanName , beanClass ).forEach ((info ) -> registerHandlerMethod (info , results ));
258
+ findHandlerMethods (beanName , beanClass ).forEach ((info ) -> addHandlerMethod (info , results ));
262
259
}
260
+
263
261
return results ;
264
262
}
265
263
266
- protected abstract HandlerMethod getHandlerMethod (M mappingInfo );
267
-
268
264
private Collection <M > findHandlerMethods (Object handler , @ Nullable Class <?> handlerClass ) {
269
265
if (handlerClass == null ) {
270
266
return Collections .emptyList ();
@@ -274,34 +270,20 @@ private Collection<M> findHandlerMethods(Object handler, @Nullable Class<?> hand
274
270
Map <Method , M > map = MethodIntrospector .selectMethods (
275
271
userClass , (Method method ) -> getMappingInfo (method , handler , userClass ));
276
272
277
- Collection <M > mappingInfos = map .values ();
278
-
279
- if (this .logger .isTraceEnabled () && !mappingInfos .isEmpty ()) {
280
- this .logger .trace (formatMappings (userClass , mappingInfos ));
281
- }
282
-
283
- return mappingInfos ;
273
+ return map .values ();
284
274
}
285
275
286
276
@ Nullable
287
277
protected abstract M getMappingInfo (Method method , Object handler , Class <?> handlerType );
288
278
289
- private String formatMappings (Class <?> handlerType , Collection <M > infos ) {
290
- String formattedType = Arrays .stream (ClassUtils .getPackageName (handlerType ).split ("\\ ." ))
291
- .map ((p ) -> p .substring (0 , 1 ))
292
- .collect (Collectors .joining ("." , "" , "." + handlerType .getSimpleName ()));
293
- return infos .stream ()
294
- .map ((info ) -> {
295
- Method method = getHandlerMethod (info ).getMethod ();
296
- String methodParameters = Arrays .stream (method .getGenericParameterTypes ())
297
- .map (Type ::getTypeName )
298
- .collect (Collectors .joining ("," , "(" , ")" ));
299
- return info + methodParameters ;
300
- })
301
- .collect (Collectors .joining ("\n \t " , "\n \t " + formattedType + ":" + "\n \t " , "" ));
279
+ protected HandlerMethod createHandlerMethod (Method originalMethod , Object handler , Class <?> handlerType ) {
280
+ Method method = AopUtils .selectInvocableMethod (originalMethod , handlerType );
281
+ return (handler instanceof String beanName ) ?
282
+ new HandlerMethod (beanName , obtainApplicationContext ().getAutowireCapableBeanFactory (), method ) :
283
+ new HandlerMethod (handler , method );
302
284
}
303
285
304
- private void registerHandlerMethod (M info , Set <M > results ) {
286
+ private void addHandlerMethod (M info , Set <M > results ) {
305
287
Assert .state (this .exceptionResolver != null , "afterPropertiesSet not called" );
306
288
HandlerMethod handlerMethod = getHandlerMethod (info );
307
289
M existing = results .stream ().filter ((o ) -> o .equals (info )).findFirst ().orElse (null );
@@ -315,12 +297,7 @@ private void registerHandlerMethod(M info, Set<M> results) {
315
297
this .exceptionResolver .registerController (handlerMethod .getBeanType ());
316
298
}
317
299
318
- protected HandlerMethod createHandlerMethod (Method originalMethod , Object handler , Class <?> handlerType ) {
319
- Method method = AopUtils .selectInvocableMethod (originalMethod , handlerType );
320
- return (handler instanceof String beanName ) ?
321
- new HandlerMethod (beanName , obtainApplicationContext ().getAutowireCapableBeanFactory (), method ) :
322
- new HandlerMethod (handler , method );
323
- }
300
+ protected abstract HandlerMethod getHandlerMethod (M mappingInfo );
324
301
325
302
protected boolean shouldInvokeAsync (HandlerMethod handlerMethod ) {
326
303
return (this .blockingMethodPredicate .test (handlerMethod ) && this .executor != null &&
0 commit comments