1、新增Condition

2、新增TypeFilter
3、删除无用的模块
master
xuchengsheng 2023-11-18 17:25:55 +08:00
parent 2e02c2acb5
commit 90dadf8279
14 changed files with 102 additions and 43 deletions

View File

@ -65,9 +65,14 @@
- [Resource](spring-resources/spring-resource/README.md) - [Resource](spring-resources/spring-resource/README.md)
- [ResourceLoader](spring-resources/spring-resource-resourceLoader/README.md) - [ResourceLoader](spring-resources/spring-resource-resourceLoader/README.md)
- [DocumentLoader](spring-resources/spring-resource-documentLoader/README.md) - [DocumentLoader](spring-resources/spring-resource-documentLoader/README.md)
- 元数据 - 元数据与过滤
- [MetadataReader](spring-metadata/spring-metadata-metadataReader/README.md) - [MetadataReader](spring-metadata/spring-metadata-metadataReader/README.md)
- [AnnotationMetadata](spring-metadata/spring-metadata-annotationMetadata/README.md) - [AnnotationMetadata](spring-metadata/spring-metadata-annotationMetadata/README.md)
- TypeFilter
- 条件注册
- Condition
- ConditionContext
- ConfigurationCondition
- Bean定义与注册 - Bean定义与注册
- [BeanDefinition](spring-beans/spring-bean-beanDefinition/README.md) - [BeanDefinition](spring-beans/spring-bean-beanDefinition/README.md)
- [BeanDefinitionHolder](spring-beans/spring-bean-beanDefinitionHolder/README.md) - [BeanDefinitionHolder](spring-beans/spring-bean-beanDefinitionHolder/README.md)
@ -82,12 +87,6 @@
- ImportBeanDefinitionRegistrar - ImportBeanDefinitionRegistrar
- ImportSelector - ImportSelector
- DeferredImportSelector - DeferredImportSelector
- Bean定义过滤
- TypeFilter
- ConditionEvaluator
- Condition
- ConditionContext
- ConfigurationCondition
- 属性编辑与类型转换 - 属性编辑与类型转换
- PropertyEditor - PropertyEditor
- ConversionService - ConversionService

View File

@ -28,6 +28,7 @@
<module>spring-resources</module> <module>spring-resources</module>
<module>spring-metadata</module> <module>spring-metadata</module>
<module>spring-beans</module> <module>spring-beans</module>
<module>spring-condition</module>
</modules> </modules>
<dependencies> <dependencies>

View File

@ -21,6 +21,7 @@
<module>spring-bean-groovyBeanDefinitionReader</module> <module>spring-bean-groovyBeanDefinitionReader</module>
<module>spring-bean-annotatedBeanDefinitionReader</module> <module>spring-bean-annotatedBeanDefinitionReader</module>
<module>spring-bean-classPathBeanDefinitionScanner</module> <module>spring-bean-classPathBeanDefinitionScanner</module>
<module>spring-bean-importBeanDefinitionRegistrar</module>
</modules> </modules>
</project> </project>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>spring-beans</artifactId>
<groupId>com.xcs.spring</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-bean-importBeanDefinitionRegistrar</artifactId>
</project>

View File

@ -0,0 +1,18 @@
package com.xcs.spring;
import com.xcs.spring.bean.MyBean;
import com.xcs.spring.config.MyConfiguration;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
* @author xcs
* @date 20231117 1448
**/
public class ImportBeanDefinitionRegistrarDemo {
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MyConfiguration.class);
MyBean bean = context.getBean(MyBean.class);
System.out.println("bean = " + bean);
}
}

View File

@ -0,0 +1,8 @@
package com.xcs.spring.bean;
/**
* @author xcs
* @date 20231117 1453
**/
public class MyBean {
}

View File

@ -0,0 +1,13 @@
package com.xcs.spring.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
/**
* @author xcs
* @date 20231117 1452
**/
@Configuration
@Import(MyImportBeanDefinitionRegistrar.class)
public class MyConfiguration {
}

View File

@ -0,0 +1,23 @@
package com.xcs.spring.config;
import com.xcs.spring.bean.MyBean;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;
/**
* @author xcs
* @date 20231117 1452
**/
public class MyImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
// 注册一个名为 "myBean" 的简单Bean
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MyBean.class);
GenericBeanDefinition definition = (GenericBeanDefinition) builder.getBeanDefinition();
registry.registerBeanDefinition("myBean", definition);
}
}

14
spring-condition/pom.xml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>spring-reading</artifactId>
<groupId>com.xcs.spring</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-condition</artifactId>
</project>

View File

@ -15,6 +15,7 @@
<modules> <modules>
<module>spring-metadata-metadataReader</module> <module>spring-metadata-metadataReader</module>
<module>spring-metadata-annotationMetadata</module> <module>spring-metadata-annotationMetadata</module>
<module>spring-metadata-typeFilter</module>
</modules> </modules>
</project> </project>

View File

@ -3,13 +3,13 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>spring-resources</artifactId> <artifactId>spring-metadata</artifactId>
<groupId>com.xcs.spring</groupId> <groupId>com.xcs.spring</groupId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>spring-resource-propertiesPersister</artifactId> <artifactId>spring-metadata-typeFilter</artifactId>
<properties> <properties>
<maven.compiler.source>11</maven.compiler.source> <maven.compiler.source>11</maven.compiler.source>

View File

@ -1,24 +0,0 @@
package com.xcs.spring;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.ResourcePropertiesPersister;
import org.springframework.util.PropertiesPersister;
import java.io.IOException;
import java.util.Properties;
/**
* @author xcs
* @date 20231109 1538
**/
public class PropertiesPersisterDemo {
public static void main(String[] args) throws IOException {
Properties loadProperties = new Properties();
PropertiesPersister propertiesPersister = ResourcePropertiesPersister.INSTANCE;
propertiesPersister.load(loadProperties, new ClassPathResource("bean-definitions.properties").getInputStream());
System.out.println("loadProperties = " + loadProperties);
}
}

View File

@ -1,4 +0,0 @@
myBean.(class)=com.xcs.spring.bean.MyBean
myBean.message=hello world
myBean.(lazy-init)=true
myBean.(scope)=prototype

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE>
<mapper namespace="com.ehome.academy.academy.service.persist.mapper.AgentVideoCategoryMapper">
</mapper>