Java Code Examples for org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#afterPropertiesSet()
The following examples show how to use
org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#afterPropertiesSet() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebMvcConfigurationSupport.java From spring-analysis-note with MIT License | 6 votes |
/** * A method available to subclasses for adding default * {@link HandlerExceptionResolver HandlerExceptionResolvers}. * <p>Adds the following exception resolvers: * <ul> * <li>{@link ExceptionHandlerExceptionResolver} for handling exceptions through * {@link org.springframework.web.bind.annotation.ExceptionHandler} methods. * <li>{@link ResponseStatusExceptionResolver} for exceptions annotated with * {@link org.springframework.web.bind.annotation.ResponseStatus}. * <li>{@link DefaultHandlerExceptionResolver} for resolving known Spring exception types * </ul> */ protected final void addDefaultHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers, ContentNegotiationManager mvcContentNegotiationManager) { ExceptionHandlerExceptionResolver exceptionHandlerResolver = createExceptionHandlerExceptionResolver(); exceptionHandlerResolver.setContentNegotiationManager(mvcContentNegotiationManager); exceptionHandlerResolver.setMessageConverters(getMessageConverters()); exceptionHandlerResolver.setCustomArgumentResolvers(getArgumentResolvers()); exceptionHandlerResolver.setCustomReturnValueHandlers(getReturnValueHandlers()); if (jackson2Present) { exceptionHandlerResolver.setResponseBodyAdvice( Collections.singletonList(new JsonViewResponseBodyAdvice())); } if (this.applicationContext != null) { exceptionHandlerResolver.setApplicationContext(this.applicationContext); } exceptionHandlerResolver.afterPropertiesSet(); exceptionResolvers.add(exceptionHandlerResolver); ResponseStatusExceptionResolver responseStatusResolver = new ResponseStatusExceptionResolver(); responseStatusResolver.setMessageSource(this.applicationContext); exceptionResolvers.add(responseStatusResolver); exceptionResolvers.add(new DefaultHandlerExceptionResolver()); }
Example 2
Source File: WebMvcConfigurationSupport.java From java-technology-stack with MIT License | 6 votes |
/** * A method available to subclasses for adding default * {@link HandlerExceptionResolver HandlerExceptionResolvers}. * <p>Adds the following exception resolvers: * <ul> * <li>{@link ExceptionHandlerExceptionResolver} for handling exceptions through * {@link org.springframework.web.bind.annotation.ExceptionHandler} methods. * <li>{@link ResponseStatusExceptionResolver} for exceptions annotated with * {@link org.springframework.web.bind.annotation.ResponseStatus}. * <li>{@link DefaultHandlerExceptionResolver} for resolving known Spring exception types * </ul> */ protected final void addDefaultHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) { ExceptionHandlerExceptionResolver exceptionHandlerResolver = createExceptionHandlerExceptionResolver(); exceptionHandlerResolver.setContentNegotiationManager(mvcContentNegotiationManager()); exceptionHandlerResolver.setMessageConverters(getMessageConverters()); exceptionHandlerResolver.setCustomArgumentResolvers(getArgumentResolvers()); exceptionHandlerResolver.setCustomReturnValueHandlers(getReturnValueHandlers()); if (jackson2Present) { exceptionHandlerResolver.setResponseBodyAdvice( Collections.singletonList(new JsonViewResponseBodyAdvice())); } if (this.applicationContext != null) { exceptionHandlerResolver.setApplicationContext(this.applicationContext); } exceptionHandlerResolver.afterPropertiesSet(); exceptionResolvers.add(exceptionHandlerResolver); ResponseStatusExceptionResolver responseStatusResolver = new ResponseStatusExceptionResolver(); responseStatusResolver.setMessageSource(this.applicationContext); exceptionResolvers.add(responseStatusResolver); exceptionResolvers.add(new DefaultHandlerExceptionResolver()); }
Example 3
Source File: WebMvcConfigurationSupport.java From lams with GNU General Public License v2.0 | 6 votes |
/** * A method available to subclasses for adding default {@link HandlerExceptionResolver}s. * <p>Adds the following exception resolvers: * <ul> * <li>{@link ExceptionHandlerExceptionResolver} * for handling exceptions through @{@link ExceptionHandler} methods. * <li>{@link ResponseStatusExceptionResolver} * for exceptions annotated with @{@link ResponseStatus}. * <li>{@link DefaultHandlerExceptionResolver} * for resolving known Spring exception types * </ul> */ protected final void addDefaultHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) { ExceptionHandlerExceptionResolver exceptionHandlerResolver = createExceptionHandlerExceptionResolver(); exceptionHandlerResolver.setContentNegotiationManager(mvcContentNegotiationManager()); exceptionHandlerResolver.setMessageConverters(getMessageConverters()); exceptionHandlerResolver.setCustomArgumentResolvers(getArgumentResolvers()); exceptionHandlerResolver.setCustomReturnValueHandlers(getReturnValueHandlers()); if (jackson2Present) { exceptionHandlerResolver.setResponseBodyAdvice( Collections.<ResponseBodyAdvice<?>>singletonList(new JsonViewResponseBodyAdvice())); } exceptionHandlerResolver.setApplicationContext(this.applicationContext); exceptionHandlerResolver.afterPropertiesSet(); exceptionResolvers.add(exceptionHandlerResolver); ResponseStatusExceptionResolver responseStatusResolver = new ResponseStatusExceptionResolver(); responseStatusResolver.setMessageSource(this.applicationContext); exceptionResolvers.add(responseStatusResolver); exceptionResolvers.add(new DefaultHandlerExceptionResolver()); }
Example 4
Source File: WebMvcConfigurationSupport.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * A method available to subclasses for adding default {@link HandlerExceptionResolver}s. * <p>Adds the following exception resolvers: * <ul> * <li>{@link ExceptionHandlerExceptionResolver} * for handling exceptions through @{@link ExceptionHandler} methods. * <li>{@link ResponseStatusExceptionResolver} * for exceptions annotated with @{@link ResponseStatus}. * <li>{@link DefaultHandlerExceptionResolver} * for resolving known Spring exception types * </ul> */ protected final void addDefaultHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) { ExceptionHandlerExceptionResolver exceptionHandlerExceptionResolver = new ExceptionHandlerExceptionResolver(); exceptionHandlerExceptionResolver.setContentNegotiationManager(mvcContentNegotiationManager()); exceptionHandlerExceptionResolver.setMessageConverters(getMessageConverters()); if (jackson2Present) { List<ResponseBodyAdvice<?>> interceptors = new ArrayList<ResponseBodyAdvice<?>>(); interceptors.add(new JsonViewResponseBodyAdvice()); exceptionHandlerExceptionResolver.setResponseBodyAdvice(interceptors); } exceptionHandlerExceptionResolver.setApplicationContext(this.applicationContext); exceptionHandlerExceptionResolver.afterPropertiesSet(); exceptionResolvers.add(exceptionHandlerExceptionResolver); ResponseStatusExceptionResolver responseStatusExceptionResolver = new ResponseStatusExceptionResolver(); responseStatusExceptionResolver.setMessageSource(this.applicationContext); exceptionResolvers.add(responseStatusExceptionResolver); exceptionResolvers.add(new DefaultHandlerExceptionResolver()); }
Example 5
Source File: AbstractControllerTest.java From entando-core with GNU Lesser General Public License v3.0 | 6 votes |
protected ExceptionHandlerExceptionResolver createExceptionResolver() { final ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); messageSource.setBasename("rest/messages"); messageSource.setUseCodeAsDefaultMessage(true); ExceptionHandlerExceptionResolver exceptionResolver = new ExceptionHandlerExceptionResolver() { @Override protected ServletInvocableHandlerMethod getExceptionHandlerMethod(HandlerMethod handlerMethod, Exception exception) { Method method = new ExceptionHandlerMethodResolver(RestExceptionHandler.class).resolveMethod(exception); RestExceptionHandler validationHandler = new RestExceptionHandler(); validationHandler.setMessageSource(messageSource); return new ServletInvocableHandlerMethod(validationHandler, method); } }; exceptionResolver.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); exceptionResolver.afterPropertiesSet(); return exceptionResolver; }
Example 6
Source File: SecKillCommandApplicationTest.java From seckill with Apache License 2.0 | 4 votes |
private ExceptionHandlerExceptionResolver withExceptionControllerAdvice() { final ExceptionHandlerExceptionResolver exceptionResolver = new InvocationExceptionHandlerExceptionResolver(); exceptionResolver.afterPropertiesSet(); return exceptionResolver; }
Example 7
Source File: SecKillRecoveryApplicationTest.java From seckill with Apache License 2.0 | 4 votes |
private ExceptionHandlerExceptionResolver withExceptionControllerAdvice() { final ExceptionHandlerExceptionResolver exceptionResolver = new InvocationExceptionHandlerExceptionResolver(); exceptionResolver.afterPropertiesSet(); return exceptionResolver; }
Example 8
Source File: SecKillPromotionBootstrapTest.java From seckill with Apache License 2.0 | 4 votes |
private ExceptionHandlerExceptionResolver withExceptionControllerAdvice() { final ExceptionHandlerExceptionResolver exceptionResolver = new InvocationExceptionHandlerExceptionResolver(); exceptionResolver.afterPropertiesSet(); return exceptionResolver; }
Example 9
Source File: SecKillStartedPromotionTest.java From seckill with Apache License 2.0 | 4 votes |
private ExceptionHandlerExceptionResolver withExceptionControllerAdvice() { final ExceptionHandlerExceptionResolver exceptionResolver = new InvocationExceptionHandlerExceptionResolver(); exceptionResolver.afterPropertiesSet(); return exceptionResolver; }
Example 10
Source File: SecKillAdminApplicationTest.java From seckill with Apache License 2.0 | 4 votes |
private ExceptionHandlerExceptionResolver withExceptionControllerAdvice() { final ExceptionHandlerExceptionResolver exceptionResolver = new InvocationExceptionHandlerExceptionResolver(); exceptionResolver.afterPropertiesSet(); return exceptionResolver; }