diff --git a/README-FUTURE.md b/README-FUTURE.md index d9dd9a3..da92555 100644 --- a/README-FUTURE.md +++ b/README-FUTURE.md @@ -65,9 +65,14 @@ - [Resource](spring-resources/spring-resource/README.md) - [ResourceLoader](spring-resources/spring-resource-resourceLoader/README.md) - [DocumentLoader](spring-resources/spring-resource-documentLoader/README.md) - - 元数据 + - 元数据与过滤 - [MetadataReader](spring-metadata/spring-metadata-metadataReader/README.md) - [AnnotationMetadata](spring-metadata/spring-metadata-annotationMetadata/README.md) + - TypeFilter + - 条件注册 + - Condition + - ConditionContext + - ConfigurationCondition - Bean定义与注册 - [BeanDefinition](spring-beans/spring-bean-beanDefinition/README.md) - [BeanDefinitionHolder](spring-beans/spring-bean-beanDefinitionHolder/README.md) @@ -82,12 +87,6 @@ - ImportBeanDefinitionRegistrar - ImportSelector - DeferredImportSelector - - Bean定义过滤 - - TypeFilter - - ConditionEvaluator - - Condition - - ConditionContext - - ConfigurationCondition - 属性编辑与类型转换 - PropertyEditor - ConversionService @@ -95,7 +94,7 @@ - 表达式语言(SpEL) - Expression - ExpressionParser - - EvaluationContext + - EvaluationContext - PropertyAccessor - MethodResolver - TypeLocator diff --git a/pom.xml b/pom.xml index fba3b08..25adbc3 100644 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,7 @@ spring-resources spring-metadata spring-beans + spring-condition diff --git a/spring-beans/pom.xml b/spring-beans/pom.xml index 1d922a5..0919d6f 100644 --- a/spring-beans/pom.xml +++ b/spring-beans/pom.xml @@ -21,6 +21,7 @@ spring-bean-groovyBeanDefinitionReader spring-bean-annotatedBeanDefinitionReader spring-bean-classPathBeanDefinitionScanner + spring-bean-importBeanDefinitionRegistrar \ No newline at end of file diff --git a/spring-beans/spring-bean-importBeanDefinitionRegistrar/pom.xml b/spring-beans/spring-bean-importBeanDefinitionRegistrar/pom.xml new file mode 100644 index 0000000..8bbd23b --- /dev/null +++ b/spring-beans/spring-bean-importBeanDefinitionRegistrar/pom.xml @@ -0,0 +1,14 @@ + + + + spring-beans + com.xcs.spring + 0.0.1-SNAPSHOT + + + 4.0.0 + spring-bean-importBeanDefinitionRegistrar + + \ No newline at end of file diff --git a/spring-beans/spring-bean-importBeanDefinitionRegistrar/src/main/java/com/xcs/spring/ImportBeanDefinitionRegistrarDemo.java b/spring-beans/spring-bean-importBeanDefinitionRegistrar/src/main/java/com/xcs/spring/ImportBeanDefinitionRegistrarDemo.java new file mode 100644 index 0000000..a7cdcd4 --- /dev/null +++ b/spring-beans/spring-bean-importBeanDefinitionRegistrar/src/main/java/com/xcs/spring/ImportBeanDefinitionRegistrarDemo.java @@ -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 2023年11月17日 14时48分 + **/ +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); + } +} diff --git a/spring-beans/spring-bean-importBeanDefinitionRegistrar/src/main/java/com/xcs/spring/bean/MyBean.java b/spring-beans/spring-bean-importBeanDefinitionRegistrar/src/main/java/com/xcs/spring/bean/MyBean.java new file mode 100644 index 0000000..47a7d50 --- /dev/null +++ b/spring-beans/spring-bean-importBeanDefinitionRegistrar/src/main/java/com/xcs/spring/bean/MyBean.java @@ -0,0 +1,8 @@ +package com.xcs.spring.bean; + +/** + * @author xcs + * @date 2023年11月17日 14时53分 + **/ +public class MyBean { +} diff --git a/spring-beans/spring-bean-importBeanDefinitionRegistrar/src/main/java/com/xcs/spring/config/MyConfiguration.java b/spring-beans/spring-bean-importBeanDefinitionRegistrar/src/main/java/com/xcs/spring/config/MyConfiguration.java new file mode 100644 index 0000000..dfbb28a --- /dev/null +++ b/spring-beans/spring-bean-importBeanDefinitionRegistrar/src/main/java/com/xcs/spring/config/MyConfiguration.java @@ -0,0 +1,13 @@ +package com.xcs.spring.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; + +/** + * @author xcs + * @date 2023年11月17日 14时52分 + **/ +@Configuration +@Import(MyImportBeanDefinitionRegistrar.class) +public class MyConfiguration { +} diff --git a/spring-beans/spring-bean-importBeanDefinitionRegistrar/src/main/java/com/xcs/spring/config/MyImportBeanDefinitionRegistrar.java b/spring-beans/spring-bean-importBeanDefinitionRegistrar/src/main/java/com/xcs/spring/config/MyImportBeanDefinitionRegistrar.java new file mode 100644 index 0000000..8bb467c --- /dev/null +++ b/spring-beans/spring-bean-importBeanDefinitionRegistrar/src/main/java/com/xcs/spring/config/MyImportBeanDefinitionRegistrar.java @@ -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 2023年11月17日 14时52分 + **/ +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); + } +} \ No newline at end of file diff --git a/spring-condition/pom.xml b/spring-condition/pom.xml new file mode 100644 index 0000000..5b1d392 --- /dev/null +++ b/spring-condition/pom.xml @@ -0,0 +1,14 @@ + + + + spring-reading + com.xcs.spring + 0.0.1-SNAPSHOT + + + 4.0.0 + spring-condition + + \ No newline at end of file diff --git a/spring-metadata/pom.xml b/spring-metadata/pom.xml index 4efecd6..1ccdba0 100644 --- a/spring-metadata/pom.xml +++ b/spring-metadata/pom.xml @@ -15,6 +15,7 @@ spring-metadata-metadataReader spring-metadata-annotationMetadata + spring-metadata-typeFilter \ No newline at end of file diff --git a/spring-resources/spring-resource-propertiesPersister/pom.xml b/spring-metadata/spring-metadata-typeFilter/pom.xml similarity index 81% rename from spring-resources/spring-resource-propertiesPersister/pom.xml rename to spring-metadata/spring-metadata-typeFilter/pom.xml index 4259227..ba3710d 100644 --- a/spring-resources/spring-resource-propertiesPersister/pom.xml +++ b/spring-metadata/spring-metadata-typeFilter/pom.xml @@ -3,13 +3,13 @@ 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"> - spring-resources + spring-metadata com.xcs.spring 0.0.1-SNAPSHOT 4.0.0 - spring-resource-propertiesPersister + spring-metadata-typeFilter 11 diff --git a/spring-resources/spring-resource-propertiesPersister/src/main/java/com/xcs/spring/PropertiesPersisterDemo.java b/spring-resources/spring-resource-propertiesPersister/src/main/java/com/xcs/spring/PropertiesPersisterDemo.java deleted file mode 100644 index 02c3fd9..0000000 --- a/spring-resources/spring-resource-propertiesPersister/src/main/java/com/xcs/spring/PropertiesPersisterDemo.java +++ /dev/null @@ -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 2023年11月09日 15时38分 - **/ -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); - } -} diff --git a/spring-resources/spring-resource-propertiesPersister/src/main/resources/bean-definitions.properties b/spring-resources/spring-resource-propertiesPersister/src/main/resources/bean-definitions.properties deleted file mode 100644 index 6b16993..0000000 --- a/spring-resources/spring-resource-propertiesPersister/src/main/resources/bean-definitions.properties +++ /dev/null @@ -1,4 +0,0 @@ -myBean.(class)=com.xcs.spring.bean.MyBean -myBean.message=hello world -myBean.(lazy-init)=true -myBean.(scope)=prototype \ No newline at end of file diff --git a/spring-resources/spring-resource-propertiesPersister/src/main/resources/beans.xml b/spring-resources/spring-resource-propertiesPersister/src/main/resources/beans.xml deleted file mode 100644 index bffb38f..0000000 --- a/spring-resources/spring-resource-propertiesPersister/src/main/resources/beans.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - -