Guest User

Untitled

a guest
May 4th, 2017
607
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @Bean
  2. public BeanPostProcessor beanPostProcessor() {
  3.     return new BeanPostProcessor() {
  4.         @Override
  5.         public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
  6.             return bean;
  7.         }
  8.  
  9.         @Override
  10.         public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
  11.             if (bean instanceof RequestMappingHandlerAdapter) {
  12.                 RequestMappingHandlerAdapter adapter = (RequestMappingHandlerAdapter) bean;
  13.                 List<HandlerMethodArgumentResolver> argumentResolvers = new ArrayList<HandlerMethodArgumentResolver>(adapter.getArgumentResolvers());
  14.                 argumentResolvers.add(0, myCustomArgumentResolver);
  15.                 adapter.setArgumentResolvers(argumentResolvers);
  16.             }
  17.  
  18.             return bean;
  19.         }
  20.     };
  21. }
RAW Paste Data