style: update workflows and github actions

pull/95/head
yanglbme 4 years ago
parent a9eb7171bb
commit 9a554e968f

@ -13,5 +13,5 @@ jobs:
with:
github_token: ${{ github.token }}
source_ref: ${{ github.ref }}
target_branch: "main"
target_branch: main
commit_message_template: "[Automated] Merged {source_ref} into {target_branch}"

@ -20,6 +20,6 @@ jobs:
uses: creyD/prettier_action@v3.3
with:
prettier_options: --write **/*.{md}
commit_message: "style: prettify code"
commit_message: "style: prettify code or document"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

@ -77,10 +77,10 @@ public class StaticTextSqlNode implements SqlNode {
- `org.apache.ibatis.scripting.xmltags.DynamicContext#appendSql`
```JAVA
public void appendSql(String sql) {
sqlBuilder.add(sql);
}
```java
public void appendSql(String sql) {
sqlBuilder.add(sql);
}
```
- 解析`trim`标签
@ -102,7 +102,7 @@ public class StaticTextSqlNode implements SqlNode {
![image-20191219152655746](../../../images/mybatis/image-20191219152655746.png)
```JAVA
```java
@Override
public boolean apply(DynamicContext context) {
if (evaluator.evaluateBoolean(test, context.getBindings())) {
@ -116,7 +116,7 @@ public class StaticTextSqlNode implements SqlNode {
- `evaluator.evaluateBoolean(test, context.getBindings())`方法
```JAVA
```java
/**
* @param expression 判断语句,ID != null
* @param parameterObject 参数列表
@ -135,7 +135,7 @@ public class StaticTextSqlNode implements SqlNode {
```
```JAVA
```java
/**
* 取值
* @param expression 判断语句,ID=NULL

@ -24,7 +24,7 @@
- 实体对象
```JAVA
```java
public class HsLog {
private Integer id;
@ -50,7 +50,7 @@
- DAO
```JAVA
```java
public interface HsLogDao {
List<HsLog> findAll();
@ -61,7 +61,7 @@
- 实现类
```JAVA
```java
public class HsLogDaoImpl extends JdbcDaoSupport implements HsLogDao {
@ -154,7 +154,7 @@
- 运行方法
```JAVA
```java
public class SpringJDBCSourceCode {
public static void main(String[] args) {
@ -251,7 +251,7 @@
- `org.springframework.jdbc.datasource.DataSourceUtils#releaseConnection`
```JAVA
```java
public static void releaseConnection(@Nullable Connection con, @Nullable DataSource dataSource) {
try {
doReleaseConnection(con, dataSource);
@ -289,7 +289,7 @@ public static void doReleaseConnection(@Nullable Connection con, @Nullable DataS
链接数
```JAVA
```java
/**
* Increase the reference count by one because the holder has been requested
* (i.e. someone requested the resource held by it).
@ -412,7 +412,7 @@ public void setDataSource(@Nullable DataSource dataSource) {
}
```
```JAVA
```java
@Override
public List<T> extractData(ResultSet rs) throws SQLException {
List<T> results = (this.rowsExpected > 0 ? new ArrayList<>(this.rowsExpected) : new ArrayList<>());

@ -525,7 +525,7 @@ public class RMIClientSourceCode {
1. 调用父类的`afterPropertiesSet`方法判断`serviceUrl`是否为空
2. 执行`prepare()`方法
```JAVA
```java
public void prepare() throws RemoteLookupFailureException {
// Cache RMI stub on initialization?
if (this.lookupStubOnStartup) {
@ -553,7 +553,7 @@ public class RMIClientSourceCode {
#### org.springframework.remoting.rmi.RmiClientInterceptor#lookupStub
```JAVA
```java
protected Remote lookupStub() throws RemoteLookupFailureException {
try {
Remote stub = null;
@ -625,7 +625,7 @@ protected Remote lookupStub() throws RemoteLookupFailureException {
- 通过类图我们可以知道`RmiProxyFactoryBean`实现了`MethodInterceptor`,具体实现方法在`org.springframework.remoting.rmi.RmiClientInterceptor#invoke`
```JAVA
```java
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
// 获取remote
@ -649,7 +649,7 @@ protected Remote lookupStub() throws RemoteLookupFailureException {
```
```JAVA
```java
protected Remote getStub() throws RemoteLookupFailureException {
if (!this.cacheStub || (this.lookupStubOnStartup && !this.refreshStubOnConnectFailure)) {
// 如果缓存stub存在直接获取,否则创建
@ -668,7 +668,7 @@ protected Remote lookupStub() throws RemoteLookupFailureException {
- `org.springframework.remoting.rmi.RmiClientInterceptor#doInvoke(org.aopalliance.intercept.MethodInvocation, org.springframework.remoting.rmi.RmiInvocationHandler)`
```JAVA
```java
@Nullable
protected Object doInvoke(MethodInvocation methodInvocation, RmiInvocationHandler invocationHandler)
throws RemoteException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
@ -693,7 +693,7 @@ protected Remote lookupStub() throws RemoteLookupFailureException {
- `org.springframework.remoting.rmi.RmiInvocationWrapper#invoke`
```JAVA
```java
/**
* Delegates the actual invocation handling to the RMI exporter.
*
@ -712,7 +712,7 @@ protected Remote lookupStub() throws RemoteLookupFailureException {
- 继续跟踪`org.springframework.remoting.rmi.RmiBasedExporter#invoke`
```JAVA
```java
@Override
protected Object invoke(RemoteInvocation invocation, Object targetObject)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
@ -723,7 +723,7 @@ protected Remote lookupStub() throws RemoteLookupFailureException {
- 继续跟踪`org.springframework.remoting.support.RemoteInvocationBasedExporter#invoke`
```JAVA
```java
protected Object invoke(RemoteInvocation invocation, Object targetObject)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
@ -761,7 +761,7 @@ protected Remote lookupStub() throws RemoteLookupFailureException {
![image-20200226083247784](../../../images/spring/image-20200226083247784.png)
```JAVA
```java
public class DefaultRemoteInvocationExecutor implements RemoteInvocationExecutor {
@Override
@ -776,7 +776,7 @@ public class DefaultRemoteInvocationExecutor implements RemoteInvocationExecutor
}
```
```JAVA
```java
public Object invoke(Object targetObject)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {

@ -86,7 +86,7 @@ public class JSONController {
- `org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#initCorsConfiguration`
```JAVA
```java
@Override
protected CorsConfiguration initCorsConfiguration(Object handler, Method method, RequestMappingInfo mappingInfo) {
// 重新创建,为什么不作为参数传递: 还有别的实现方法
@ -244,7 +244,7 @@ public class JSONController {
- 实现**BeanDefinitionParser** 接口的都有一个**parse**方法直接看方法.
- 通过查看我们可以知道最终目的获取 xml 标签中的属性,对 **CorsConfiguration**进行初始化,最后 Spring 中注册
```JAVA
```java
public class CorsBeanDefinitionParser implements BeanDefinitionParser {
@Override
@ -341,7 +341,7 @@ public class CorsBeanDefinitionParser implements BeanDefinitionParser {
- 跨域信息
```JAVA
```java
/**
* 允许请求源
*/
@ -511,7 +511,7 @@ public class CorsBeanDefinitionParser implements BeanDefinitionParser {
![image-20200123093733129](../../../images/springMVC/clazz/image-20200123093733129.png)
```JAVA
```java
@Override
@SuppressWarnings("resource")
public boolean processRequest(@Nullable CorsConfiguration config, HttpServletRequest request,

@ -505,7 +505,7 @@ public class DeclarativeTransactionTest {
- `tm.getTransaction`
```JAVA
```java
@Override
public final TransactionStatus getTransaction(@Nullable TransactionDefinition definition)
throws TransactionException {
@ -577,7 +577,7 @@ public class DeclarativeTransactionTest {
- `org.springframework.jdbc.datasource.DataSourceTransactionManager#doGetTransaction`
```JAVA
```java
@Override
protected Object doGetTransaction() {
DataSourceTransactionObject txObject = new DataSourceTransactionObject();
@ -594,7 +594,7 @@ public class DeclarativeTransactionTest {
- `org.springframework.transaction.support.AbstractPlatformTransactionManager#suspend`
```JAVA
```java
@Nullable
protected final SuspendedResourcesHolder suspend(@Nullable Object transaction)
throws TransactionException {
@ -642,7 +642,7 @@ public class DeclarativeTransactionTest {
- `prepareTransactionInfo`简单的`new`对象并且绑定线程
```JAVA
```java
protected TransactionInfo prepareTransactionInfo(@Nullable PlatformTransactionManager tm,
@Nullable TransactionAttribute txAttr, String joinpointIdentification,
@Nullable TransactionStatus status) {
@ -1654,7 +1654,7 @@ static Object unwrapResourceIfNecessary(Object resource) {
- `ScopedProxyUnwrapper.unwrapIfNecessary`
```JAVA
```java
private static class ScopedProxyUnwrapper {
public static Object unwrapIfNecessary(Object resource) {

@ -30,7 +30,7 @@ public class DemoApplicationListener implements ApplicationListener {
</beans>
```
```JAVA
```java
public class ListenerSourceCode {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("Listener-demo.xml");
@ -68,7 +68,7 @@ public class ListenerSourceCode {
## 注册
```JAVA
```java
protected void registerListeners() {
// Register statically specified listeners first.
// 读取 ApplicationListener

@ -399,7 +399,7 @@ public AbstractBeanDefinition parseBeanDefinitionElement(
- 将 xml 标签的数据读取到内存中设置给`AbstractBeanDefinition`
```JAVA
```java
public AbstractBeanDefinition parseBeanDefinitionAttributes(Element ele, String beanName,
@Nullable BeanDefinition containingBean, AbstractBeanDefinition bd) {
@ -971,7 +971,7 @@ public Object parseIdRefElement(Element ele) {
- `org.springframework.beans.factory.xml.BeanDefinitionParserDelegate#parseValueElement`
```JAVA
```java
public Object parseValueElement(Element ele, @Nullable String defaultTypeName) {
// It's a literal value.
// 获取 xml 中的文本变量

@ -80,11 +80,11 @@ public class BeanFactoryPostProcessorSourceCode {
- `org.springframework.context.support.AbstractApplicationContext#refresh`
```JAVA
```java
invokeBeanFactoryPostProcessors(beanFactory);
```
```JAVA
```java
protected void invokeBeanFactoryPostProcessors(ConfigurableListableBeanFactory beanFactory) {
PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(beanFactory, getBeanFactoryPostProcessors());
@ -100,7 +100,7 @@ public class BeanFactoryPostProcessorSourceCode {
- `org.springframework.context.support.PostProcessorRegistrationDelegate#invokeBeanFactoryPostProcessors(org.springframework.beans.factory.config.ConfigurableListableBeanFactory, java.util.List<org.springframework.beans.factory.config.BeanFactoryPostProcessor>)`
```JAVA
```java
public static void invokeBeanFactoryPostProcessors(
ConfigurableListableBeanFactory beanFactory, List<BeanFactoryPostProcessor> beanFactoryPostProcessors) {
@ -373,13 +373,13 @@ public class DemoInstantiationAwareBeanPostProcessor implements InstantiationAwa
在`org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#createBean(java.lang.String, org.springframework.beans.factory.support.RootBeanDefinition, java.lang.Object[])`中有如下代码
```JAVA
```java
Object bean = resolveBeforeInstantiation(beanName, mbdToUse);
```
- `org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#resolveBeforeInstantiation`
```JAVA
```java
@Nullable
protected Object resolveBeforeInstantiation(String beanName, RootBeanDefinition mbd) {
Object bean = null;
@ -405,7 +405,7 @@ public class DemoInstantiationAwareBeanPostProcessor implements InstantiationAwa
- `org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#applyBeanPostProcessorsBeforeInstantiation`
```JAVA
```java
@Nullable
protected Object applyBeanPostProcessorsBeforeInstantiation(Class<?> beanClass, String beanName) {
for (BeanPostProcessor bp : getBeanPostProcessors()) {

@ -30,7 +30,7 @@ public interface BeanNameGenerator {
- 调用工具类方法进行生成
```JAVA
```java
@Override
public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
return BeanDefinitionReaderUtils.generateBeanName(definition, registry);

@ -315,7 +315,7 @@ public class DatePropertyEditor extends PropertyEditorSupport {
![image-20200117142800671](../../../images/spring/image-20200117142800671.png)
```JAVA
```java
@Nullable
private Object convertForProperty(
@Nullable Object value, String propertyName, BeanWrapper bw, TypeConverter converter) {
@ -332,7 +332,7 @@ public class DatePropertyEditor extends PropertyEditorSupport {
```
```JAVA
```java
private Object doConvertTextValue(@Nullable Object oldValue, String newTextValue, PropertyEditor editor) {
try {
editor.setValue(oldValue);
@ -352,7 +352,7 @@ public class DatePropertyEditor extends PropertyEditorSupport {
- 调用用例编写的方法
```JAVA
```java
@Override
public void setAsText(String text) throws IllegalArgumentException {
System.out.println(text);

@ -271,7 +271,7 @@ public class XSDDemo {
- `org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver#getHandlerMappings`跟踪这个方法
```JAVA
```java
/**
* Load the specified NamespaceHandler mappings lazily.
*
@ -358,7 +358,7 @@ public class XSDDemo {
![image-20200109090456547](../../../images/spring/image-20200109090456547.png)
```JAVA
```java
public DefaultNamespaceHandlerResolver(@Nullable ClassLoader classLoader) {
this(classLoader, DEFAULT_HANDLER_MAPPINGS_LOCATION);
}
@ -382,7 +382,7 @@ public class XSDDemo {
```
```JAVA
```java
/**
* Load the specified NamespaceHandler mappings lazily.
*
@ -628,7 +628,7 @@ public class UserNamespaceHandler extends NamespaceHandlerSupport {
执行`com.huifer.source.spring.parser.UserBeanDefinitionParser#doParse`
```JAVA
```java
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
// 获取 userName 标签属性值

@ -99,7 +99,7 @@
2. `org.springframework.context.support.AbstractMessageSource#getMessageInternal`
```JAVA
```java
@Nullable
protected String getMessageInternal(@Nullable String code, @Nullable Object[] args, @Nullable Locale locale) {
if (code == null) {

@ -92,7 +92,7 @@ public MutablePropertyValues(@Nullable PropertyValues original) {
### PropertyValue 的构造方法
```JAVA
```java
public PropertyValue(PropertyValue original) {
Assert.notNull(original, "Original must not be null");
this.name = original.getName();

@ -529,7 +529,7 @@ protected void beforeSingletonCreation(String beanName) {
- `org.springframework.beans.factory.support.FactoryBeanRegistrySupport#postProcessObjectFromFactoryBean`
```JAVA
```java
protected Object postProcessObjectFromFactoryBean(Object object, String beanName) throws BeansException {
return object;
}
@ -582,7 +582,7 @@ protected void afterSingletonCreation(String beanName) {
- 代码现在进入的很深了,回到 doGetBean
- `org.springframework.beans.factory.support.AbstractBeanFactory#doGetBean`
```JAVA
```java
protected <T> T doGetBean(final String name, @Nullable final Class<T> requiredType,
@Nullable final Object[] args, boolean typeCheckOnly) throws BeansException {
// 转换beanName
@ -1183,7 +1183,7 @@ public Object getSingleton(String beanName, ObjectFactory<?> singletonFactory) {
- 两个核心方法
```JAVA
```java
// Give BeanPostProcessors a chance to return a proxy instead of the target bean instance.
Object bean = resolveBeforeInstantiation(beanName, mbdToUse);
Object beanInstance = doCreateBean(beanName, mbdToUse, args);
@ -1870,7 +1870,7 @@ public void overrideDefaultEditor(Class<?> requiredType, PropertyEditor property
- `registerCustomEditor`
```JAVA
```java
@Override
public void registerCustomEditor(@Nullable Class<?> requiredType, @Nullable String propertyPath, PropertyEditor propertyEditor) {
if (requiredType == null && propertyPath == null) {

@ -368,7 +368,7 @@ public class DemoService {
- `org.springframework.context.annotation.AnnotationBeanNameGenerator#buildDefaultBeanName(org.springframework.beans.factory.config.BeanDefinition, org.springframework.beans.factory.support.BeanDefinitionRegistry)`
- `org.springframework.context.annotation.AnnotationBeanNameGenerator#buildDefaultBeanName(org.springframework.beans.factory.config.BeanDefinition)`
```JAVA
```java
protected String buildDefaultBeanName(BeanDefinition definition) {
// 获取bean class name
String beanClassName = definition.getBeanClassName();
@ -381,7 +381,7 @@ public class DemoService {
```
```JAVA
```java
@Configuration
public class BeanConfig {
@Scope(value =ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@ -496,7 +496,7 @@ static void processCommonDefinitionAnnotations(AnnotatedBeanDefinition abd, Anno
#### org.springframework.context.annotation.AnnotationConfigUtils#applyScopedProxyMode
```JAVA
```java
static BeanDefinitionHolder applyScopedProxyMode(
ScopeMetadata metadata, BeanDefinitionHolder definition, BeanDefinitionRegistry registry) {

@ -59,7 +59,7 @@ public class JmsBootstrapConfiguration {
#### afterSingletonsInstantiated
```JAVA
```java
@Override
public void afterSingletonsInstantiated() {
// Remove resolved singleton classes from cache
@ -108,7 +108,7 @@ public class JmsBootstrapConfiguration {
- 关注最后一行`this.registrar.afterPropertiesSet()`
```JAVA
```java
@Override
public void afterPropertiesSet() {
registerAllEndpoints();
@ -131,7 +131,7 @@ public class JmsBootstrapConfiguration {
#### postProcessAfterInitialization
```JAVA
```java
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof AopInfrastructureBean || bean instanceof JmsListenerContainerFactory ||
@ -169,7 +169,7 @@ public class JmsBootstrapConfiguration {
```
```JAVA
```java
protected void processJmsListener(JmsListener jmsListener, Method mostSpecificMethod, Object bean) {
Method invocableMethod = AopUtils.selectInvocableMethod(mostSpecificMethod, bean.getClass());
@ -302,7 +302,7 @@ public class JmsBootstrapConfiguration {
- 关键接口`JmsListenerContainerFactory<C extends MessageListenerContainer>`
```JAVA
```java
public interface JmsListenerContainerFactory<C extends MessageListenerContainer> {
/**

@ -67,7 +67,7 @@
- 真正的转换过程
```JAVA
```java
@Override
protected Object convertFromInternal(Message<?> message, Class<?> targetClass, @Nullable Object conversionHint) {
Charset charset = getContentTypeCharset(getMimeType(message.getHeaders()));
@ -79,7 +79,7 @@
### toMessage
```JAVA
```java
@Override
@Nullable
public final Message<?> toMessage(Object payload, @Nullable MessageHeaders headers) {
@ -88,7 +88,7 @@
```
```JAVA
```java
@Override
@Nullable
public final Message<?> toMessage(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) {
@ -128,7 +128,7 @@
- `org.springframework.messaging.converter.StringMessageConverter#convertToInternal`
```JAVA
```java
@Override
@Nullable
protected Object convertToInternal(
@ -147,7 +147,7 @@
- 创建**Message**对象
```JAVA
```java
@SuppressWarnings("unchecked")
public static <T> Message<T> createMessage(@Nullable T payload, MessageHeaders messageHeaders) {
Assert.notNull(payload, "Payload must not be null");
@ -162,7 +162,7 @@
```
```JAVA
```java
@SuppressWarnings("unchecked")
public Message<T> build() {
if (this.originalMessage != null && !this.headerAccessor.isModified()) {

@ -58,7 +58,7 @@ public final HandlerExecutionChain getHandler(HttpServletRequest request) throws
- `getHandlerInternal`方法是一个抽象方法
```JAVA
```java
@Nullable
protected abstract Object getHandlerInternal(HttpServletRequest request) throws Exception;
```
@ -346,7 +346,7 @@ public Map<String, String> decodePathVariables(HttpServletRequest request, Map<S
- 回到`org.springframework.web.servlet.handler.AbstractHandlerMethodMapping#getHandlerInternal`
```JAVA
```java
String lookupPath = getUrlPathHelper().getLookupPathForRequest(request);
```
@ -391,7 +391,7 @@ protected HandlerMethod lookupHandlerMethod(String lookupPath, HttpServletReques
List<T> directPathMatches = this.mappingRegistry.getMappingsByUrl(lookupPath);
```
```JAVA
```java
@Nullable
public List<T> getMappingsByUrl(String urlPath) {
return this.urlLookup.get(urlPath);

@ -74,7 +74,7 @@ public class DemoController {
- `org.springframework.web.servlet.handler.AbstractHandlerMethodMapping#registerHandlerMethod`
```JAVA
```java
protected void registerHandlerMethod(Object handler, Method method, T mapping) {
this.mappingRegistry.register(mapping, handler, method);
}

@ -263,7 +263,7 @@ private <T> List<T> createSpringFactoriesInstances(Class<T> type, Class<?>[] par
- 最终输出内容类:`org.springframework.boot.SpringBootBanner`
```JAVA
```java
class SpringBootBanner implements Banner {
private static final String[] BANNER = { "", " . ____ _ __ _ _",
@ -297,7 +297,7 @@ private <T> List<T> createSpringFactoriesInstances(Class<T> type, Class<?>[] par
### createApplicationContext
```JAVA
```java
protected ConfigurableApplicationContext createApplicationContext() {
// 获取上下文类
Class<?> contextClass = this.applicationContextClass;
@ -327,7 +327,7 @@ private <T> List<T> createSpringFactoriesInstances(Class<T> type, Class<?>[] par
- `this.applicationContextClass` 初始化方法
```JAVA
```java
public SpringApplication(ResourceLoader resourceLoader, Class<?>... primarySources) {
this.resourceLoader = resourceLoader;
Assert.notNull(primarySources, "PrimarySources must not be null");
@ -342,7 +342,7 @@ private <T> List<T> createSpringFactoriesInstances(Class<T> type, Class<?>[] par
- `org.springframework.boot.WebApplicationType#deduceFromClasspath`
```JAVA
```java
static WebApplicationType deduceFromClasspath() {
if (ClassUtils.isPresent(WEBFLUX_INDICATOR_CLASS, null) && !ClassUtils.isPresent(WEBMVC_INDICATOR_CLASS, null)
&& !ClassUtils.isPresent(JERSEY_INDICATOR_CLASS, null)) {
@ -364,7 +364,7 @@ private <T> List<T> createSpringFactoriesInstances(Class<T> type, Class<?>[] par
### prepareContext
```JAVA
```java
private void prepareContext(ConfigurableApplicationContext context, ConfigurableEnvironment environment,
SpringApplicationRunListeners listeners, ApplicationArguments applicationArguments, Banner printedBanner) {
// 上下文中设置环境
@ -631,7 +631,7 @@ private int load(Object source) {
- 两种 runner 启动`ApplicationRunner` 和 `CommandLineRunner`
```JAVA
```java
private void callRunners(ApplicationContext context, ApplicationArguments args) {
List<Object> runners = new ArrayList<>();
runners.addAll(context.getBeansOfType(ApplicationRunner.class).values());
@ -649,7 +649,7 @@ private int load(Object source) {
```
```JAVA
```java
private void callRunner(ApplicationRunner runner, ApplicationArguments args) {
try {
(runner).run(args);

@ -575,7 +575,7 @@ private List<String> filter(List<String> configurations, AutoConfigurationMetada
- 在这里有一个关注点 循环方法`getAutoConfigurationImportFilters()`
```JAVA
```java
protected List<AutoConfigurationImportFilter> getAutoConfigurationImportFilters() {
return SpringFactoriesLoader.loadFactories(AutoConfigurationImportFilter.class, this.beanClassLoader);
}

@ -20,7 +20,7 @@
## ConfigurationPropertiesScan
```JAVA
```java
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@ -39,7 +39,7 @@ public @interface ConfigurationPropertiesScan {}
## EnableConfigurationProperties
```JAVA
```java
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@ -88,7 +88,7 @@ public @interface EnableConfigurationProperties {
### registerInfrastructureBeans
```JAVA
```java
static void registerInfrastructureBeans(BeanDefinitionRegistry registry) {
// 属性绑定后置处理器
ConfigurationPropertiesBindingPostProcessor.register(registry);
@ -102,7 +102,7 @@ public @interface EnableConfigurationProperties {
#### ConfigurationPropertiesBindingPostProcessor.register(registry)
```JAVA
```java
public static void register(BeanDefinitionRegistry registry) {
Assert.notNull(registry, "Registry must not be null");
// 是否存在
@ -119,7 +119,7 @@ public @interface EnableConfigurationProperties {
#### ConfigurationPropertiesBeanDefinitionValidator.register(registry)
```JAVA
```java
static void register(BeanDefinitionRegistry registry) {
Assert.notNull(registry, "Registry must not be null");
if (!registry.containsBeanDefinition(BEAN_NAME)) {
@ -145,7 +145,7 @@ public @interface EnableConfigurationProperties {
- 源码开始,先找出刚才的对象`org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration`
```JAVA
```java
@Configuration(proxyBeanMethods = false)
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
@ConditionalOnClass(ServletRequest.class)
@ -158,7 +158,7 @@ public @interface EnableConfigurationProperties {
public class ServletWebServerFactoryAutoConfiguration {}
```
```JAVA
```java
/**
* 找出 {@link EnableConfigurationProperties} 注解标记的中的属性值,并且返回值不是void
* @param metadata
@ -196,7 +196,7 @@ public @interface EnableConfigurationProperties {
### postProcessBeforeInitialization
```JAVA
```java
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
// 绑定
@ -272,7 +272,7 @@ public @interface EnableConfigurationProperties {
- `org.springframework.boot.context.properties.ConfigurationPropertiesBean#create`
```JAVA
```java
private static ConfigurationPropertiesBean create(String name, Object instance, Class<?> type, Method factory) {
// 找注解
ConfigurationProperties annotation = findAnnotation(instance, type, factory, ConfigurationProperties.class);
@ -365,7 +365,7 @@ BindResult<?> bind(ConfigurationPropertiesBean propertiesBean) {
##### findProperty
```JAVA
```java
private ConfigurationProperty findProperty(ConfigurationPropertyName name, Context context) {
if (name.isEmpty()) {
return null;
@ -384,7 +384,7 @@ BindResult<?> bind(ConfigurationPropertiesBean propertiesBean) {
- `org.springframework.boot.context.properties.source.SpringConfigurationPropertySource#getConfigurationProperty`
```JAVA
```java
@Override
public ConfigurationProperty getConfigurationProperty(ConfigurationPropertyName name) {
PropertyMapping[] mappings = getMapper().map(name);
@ -393,7 +393,7 @@ BindResult<?> bind(ConfigurationPropertiesBean propertiesBean) {
```
```JAVA
```java
protected final ConfigurationProperty find(PropertyMapping[] mappings, ConfigurationPropertyName name) {
for (PropertyMapping candidate : mappings) {
@ -409,7 +409,7 @@ BindResult<?> bind(ConfigurationPropertiesBean propertiesBean) {
```
```JAVA
```java
private ConfigurationProperty find(PropertyMapping mapping) {
// 需要读取的配置信息的key
String propertySourceName = mapping.getPropertySourceName();

@ -116,7 +116,7 @@ protected void addPropertySources(ConfigurableEnvironment environment, ResourceL
- `org.springframework.boot.context.config.ConfigFileApplicationListener.Loader#load(org.springframework.boot.context.config.ConfigFileApplicationListener.Profile, org.springframework.boot.context.config.ConfigFileApplicationListener.DocumentFilterFactory, org.springframework.boot.context.config.ConfigFileApplicationListener.DocumentConsumer)`
```JAVA
```java
private void load(Profile profile, DocumentFilterFactory filterFactory, DocumentConsumer consumer) {
getSearchLocations().forEach(
// 本地路径
@ -196,7 +196,7 @@ private void load(Profile profile, DocumentFilterFactory filterFactory, Document
### asDocuments
```JAVA
```java
/**
* 将 {@link PropertySource} 转换成 {@link Document}
* @param loaded

@ -57,7 +57,7 @@ public @interface EnableAutoConfiguration {
## getAutoConfigurationMetadata()
```JAVA
```java
@Override
public void process(AnnotationMetadata annotationMetadata, DeferredImportSelector deferredImportSelector) {
Assert.state(deferredImportSelector instanceof AutoConfigurationImportSelector,
@ -87,7 +87,7 @@ public @interface EnableAutoConfiguration {
- `org.springframework.boot.autoconfigure.AutoConfigurationMetadataLoader#loadMetadata(java.lang.ClassLoader)`
```JAVA
```java
static AutoConfigurationMetadata loadMetadata(ClassLoader classLoader, String path) {
try {
@ -141,7 +141,7 @@ public @interface EnableAutoConfiguration {
先说注解
```JAVA
```java
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(RedisOperations.class)
@EnableConfigurationProperties(RedisProperties.class)
@ -155,7 +155,7 @@ public @interface EnableAutoConfiguration {
- `org.springframework.boot.autoconfigure.data.redis.RedisProperties`
- 部分 redis 配置属性
```JAVA
```java
@ConfigurationProperties(prefix = "spring.redis")
public class RedisProperties {
@ -228,7 +228,7 @@ public class RedisProperties {
### getAutoConfigurationEntry
```JAVA
```java
protected AutoConfigurationEntry getAutoConfigurationEntry(AutoConfigurationMetadata autoConfigurationMetadata,
AnnotationMetadata annotationMetadata) {
if (!isEnabled(annotationMetadata)) {
@ -302,7 +302,7 @@ public class RedisProperties {
- new 两个对象直接做数据转换,去重
```JAVA
```java
protected final <T> List<T> removeDuplicates(List<T> list) {
return new ArrayList<>(new LinkedHashSet<>(list));
}
@ -311,7 +311,7 @@ public class RedisProperties {
### getExclusions
```JAVA
```java
protected Set<String> getExclusions(AnnotationMetadata metadata, AnnotationAttributes attributes) {
Set<String> excluded = new LinkedHashSet<>();
// 获取属性 exclude 值转换成list
@ -327,7 +327,7 @@ public class RedisProperties {
### getExcludeAutoConfigurationsProperty
```JAVA
```java
private List<String> getExcludeAutoConfigurationsProperty() {
if (getEnvironment() instanceof ConfigurableEnvironment) {
Binder binder = Binder.get(getEnvironment());
@ -345,7 +345,7 @@ public class RedisProperties {
- 修改启动类
```JAVA
```java
@SpringBootApplication(excludeName = { "org.sourcehot.service.HelloServiceAutoConfiguration" })
```
@ -354,7 +354,7 @@ public class RedisProperties {
### checkExcludedClasses
```JAVA
```java
private void checkExcludedClasses(List<String> configurations, Set<String> exclusions) {
List<String> invalidExcludes = new ArrayList<>(exclusions.size());
for (String exclusion : exclusions) {
@ -377,7 +377,7 @@ public class RedisProperties {
### filter
```JAVA
```java
private List<String> filter(List<String> configurations, AutoConfigurationMetadata autoConfigurationMetadata) {
long startTime = System.nanoTime();
String[] candidates = StringUtils.toStringArray(configurations);
@ -430,7 +430,7 @@ public class RedisProperties {
### fireAutoConfigurationImportEvents
```JAVA
```java
private void fireAutoConfigurationImportEvents(List<String> configurations, Set<String> exclusions) {
// 获取自动配置的监听器列表
List<AutoConfigurationImportListener> listeners = getAutoConfigurationImportListeners();
@ -456,7 +456,7 @@ public class RedisProperties {
- `org.springframework.boot.autoconfigure.AutoConfigurationImportListener#onAutoConfigurationImportEvent` 在执行自动配置时触发 , 实现类只有 **`ConditionEvaluationReportAutoConfigurationImportListener`**
```JAVA
```java
@Override
public void onAutoConfigurationImportEvent(AutoConfigurationImportEvent event) {
if (this.beanFactory != null) {
@ -482,7 +482,7 @@ public class RedisProperties {
- 后续的一些行为相对简单,直接放个源码了.
```JAVA
```java
@Override
public void process(AnnotationMetadata annotationMetadata, DeferredImportSelector deferredImportSelector) {
Assert.state(deferredImportSelector instanceof AutoConfigurationImportSelector,

@ -97,7 +97,7 @@ public static void registerGlobalNacosProperties(AnnotationAttributes attributes
- 贴出注解上的信息
```JAVA
```java
NacosProperties globalProperties() default @NacosProperties(username = USERNAME_PLACEHOLDER, password = PASSWORD_PLACEHOLDER, endpoint = ENDPOINT_PLACEHOLDER, namespace = NAMESPACE_PLACEHOLDER, accessKey = ACCESS_KEY_PLACEHOLDER, secretKey = SECRET_KEY_PLACEHOLDER, serverAddr = SERVER_ADDR_PLACEHOLDER, contextPath = CONTEXT_PATH_PLACEHOLDER, clusterName = CLUSTER_NAME_PLACEHOLDER, encode = ENCODE_PLACEHOLDER);
```
@ -527,7 +527,7 @@ public void createServiceIfAbsent(String namespaceId, String serviceName, boolea
- 在了解 map 结构后不难理解下面这个获取 Service 的方法了
```JAVA
```java
public Service getService(String namespaceId, String serviceName) {
if (serviceMap.get(namespaceId) == null) {
return null;

Loading…
Cancel
Save