Skip to content

Commit

Permalink
Support for custom BatchHandlerMethodArgumentResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
dugenkui03 committed Mar 10, 2022
1 parent cfcfeb3 commit d86fcad
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ public class AnnotatedControllerConfigurer
@Nullable
private HandlerMethodArgumentResolverComposite argumentResolvers;

@Nullable
private List<BatchHandlerMethodArgumentResolver> customBatchMethodArgumentResolvers;

@Nullable
private BatchHandlerMethodArgumentResolverComposite batchMethodArgumentResolvers;

Expand Down Expand Up @@ -152,6 +155,22 @@ public void setConversionService(ConversionService conversionService) {
this.conversionService = (FormattingConversionService) conversionService;
}

/**
* Provide resolvers for custom batch method argument types. Custom resolvers
* are ordered after built-in ones.
*/
public void setCustomBatchMethodArgumentResolvers(@Nullable List<BatchHandlerMethodArgumentResolver> customBatchMethodArgumentResolvers) {
this.customBatchMethodArgumentResolvers = customBatchMethodArgumentResolvers;
}

/**
* Return the custom custom batch method argument resolvers, or {@code null}.
*/
@Nullable
public List<BatchHandlerMethodArgumentResolver> getCustomBatchMethodArgumentResolvers() {
return this.customBatchMethodArgumentResolvers;
}

@Override
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
Expand Down Expand Up @@ -222,6 +241,11 @@ private List<BatchHandlerMethodArgumentResolver> getBatchMethodDefaultArgumentRe
if (springSecurityPresent) {
resolvers.add(new PrincipalBatchMethodArgumentResolver());
}

// Custom batch method argument resolvers
if (getCustomBatchMethodArgumentResolvers() != null) {
resolvers.addAll(getCustomBatchMethodArgumentResolvers());
}
return resolvers;
}

Expand Down

0 comments on commit d86fcad

Please sign in to comment.