-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pref(hydrogen): Make
UniformHandler
register bean only once other t…
…han with `@ControllerAdvice` component scan by default. [*] `AopContextHolder.getHandlerMetaData` support for automatic identification of aop.
- Loading branch information
Showing
8 changed files
with
65 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 9 additions & 4 deletions
13
Milkomeda/src/main/java/com/github/yizzuide/milkomeda/hydrogen/uniform/UniformConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,38 @@ | ||
package com.github.yizzuide.milkomeda.hydrogen.uniform; | ||
|
||
import com.github.yizzuide.milkomeda.universe.polyfill.SpringMvcPolyfill; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; | ||
import org.springframework.web.servlet.HandlerExceptionResolver; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; | ||
|
||
/** | ||
* UniformConfig | ||
* | ||
* @author yizzuide | ||
* @since 3.0.0 | ||
* @version 3.0.1 | ||
* @see WebMvcConfigurationSupport#handlerExceptionResolver(org.springframework.web.accept.ContentNegotiationManager) | ||
* #see ExceptionHandlerExceptionResolver#initExceptionHandlerAdviceCache() | ||
* #see ExceptionHandlerExceptionResolver#getExceptionHandlerMethod(org.springframework.web.method.HandlerMethod, java.lang.Exception) | ||
* Create at 2020/03/25 22:46 | ||
*/ | ||
@Configuration | ||
@EnableConfigurationProperties(UniformProperties.class) | ||
@ConditionalOnProperty(prefix = "milkomeda.hydrogen.uniform", name = "enable", havingValue = "true") | ||
public class UniformConfig { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean(name = "uniformHandler") | ||
public UniformHandler uniformHandler() { | ||
return new UniformHandler(); | ||
} | ||
|
||
@Autowired | ||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") | ||
public void configParamResolve(RequestMappingHandlerAdapter adapter) { | ||
public void configParamResolve(HandlerExceptionResolver handlerExceptionResolver) { | ||
SpringMvcPolyfill.addDynamicExceptionAdvice(handlerExceptionResolver, "uniformHandler"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters