1717package org .springframework .graphql .data .method .annotation .support ;
1818
1919import java .lang .reflect .Method ;
20- import java .lang .reflect .Type ;
21- import java .util .Arrays ;
2220import java .util .Collection ;
2321import java .util .Collections ;
2422import java .util .LinkedHashSet ;
2826import java .util .concurrent .Callable ;
2927import java .util .concurrent .Executor ;
3028import java .util .function .Predicate ;
31- import java .util .stream .Collectors ;
3229
3330import graphql .schema .DataFetcher ;
3431import org .apache .commons .logging .Log ;
@@ -258,13 +255,12 @@ protected Set<M> detectHandlerMethods() {
258255 continue ;
259256 }
260257 Class <?> beanClass = context .getType (beanName );
261- findHandlerMethods (beanName , beanClass ).forEach ((info ) -> registerHandlerMethod (info , results ));
258+ findHandlerMethods (beanName , beanClass ).forEach ((info ) -> addHandlerMethod (info , results ));
262259 }
260+
263261 return results ;
264262 }
265263
266- protected abstract HandlerMethod getHandlerMethod (M mappingInfo );
267-
268264 private Collection <M > findHandlerMethods (Object handler , @ Nullable Class <?> handlerClass ) {
269265 if (handlerClass == null ) {
270266 return Collections .emptyList ();
@@ -274,34 +270,20 @@ private Collection<M> findHandlerMethods(Object handler, @Nullable Class<?> hand
274270 Map <Method , M > map = MethodIntrospector .selectMethods (
275271 userClass , (Method method ) -> getMappingInfo (method , handler , userClass ));
276272
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 ();
284274 }
285275
286276 @ Nullable
287277 protected abstract M getMappingInfo (Method method , Object handler , Class <?> handlerType );
288278
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 );
302284 }
303285
304- private void registerHandlerMethod (M info , Set <M > results ) {
286+ private void addHandlerMethod (M info , Set <M > results ) {
305287 Assert .state (this .exceptionResolver != null , "afterPropertiesSet not called" );
306288 HandlerMethod handlerMethod = getHandlerMethod (info );
307289 M existing = results .stream ().filter ((o ) -> o .equals (info )).findFirst ().orElse (null );
@@ -315,12 +297,7 @@ private void registerHandlerMethod(M info, Set<M> results) {
315297 this .exceptionResolver .registerController (handlerMethod .getBeanType ());
316298 }
317299
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 );
324301
325302 protected boolean shouldInvokeAsync (HandlerMethod handlerMethod ) {
326303 return (this .blockingMethodPredicate .test (handlerMethod ) && this .executor != null &&
0 commit comments