forked from fafeidou/fast-cloud-nacos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
qinfuxiang
committed
Nov 22, 2021
1 parent
dfc78e3
commit 4b23521
Showing
4 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
5 changes: 2 additions & 3 deletions
5
...les/auto-configure/src/main/java/fast/boot/autoconfigure/annotation/EnableHelloWorld.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,14 +1,13 @@ | ||
package fast.boot.autoconfigure.annotation; | ||
|
||
import org.springframework.context.annotation.Import; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
@Documented | ||
//@Import(HelloWorldConfiguration.class) | ||
//@Import(HelloWorldImportSelector.class) | ||
@Import(HelloWorldImportBeanDefinitionRegistrar.class) | ||
//@Import(HelloWorldImportBeanDefinitionRegistrar.class) | ||
//@Import(HelloWorldBeanFactoryPostProcessor.class) | ||
public @interface EnableHelloWorld { | ||
} |
29 changes: 29 additions & 0 deletions
29
.../fast/boot/autoconfigure/configuration/HelloWorldBeanDefinitionRegistryPostProcessor.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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package fast.boot.autoconfigure.configuration; | ||
|
||
import org.springframework.beans.BeansException; | ||
import org.springframework.beans.factory.config.BeanDefinitionHolder; | ||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; | ||
import org.springframework.beans.factory.support.BeanDefinitionBuilder; | ||
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils; | ||
import org.springframework.beans.factory.support.BeanDefinitionRegistry; | ||
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor; | ||
|
||
/** | ||
* @author qinfuxiang | ||
*/ | ||
public class HelloWorldBeanDefinitionRegistryPostProcessor implements BeanDefinitionRegistryPostProcessor { | ||
|
||
@Override | ||
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { | ||
BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(HelloWorldConfiguration.class); | ||
// registry.registerBeanDefinition(HelloWorldConfiguration.class.getName(), bdb.getBeanDefinition()); | ||
BeanDefinitionHolder holder = new BeanDefinitionHolder(bdb.getBeanDefinition(), HelloWorldConfiguration.class.getName(), | ||
null); | ||
BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry); | ||
} | ||
|
||
@Override | ||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { | ||
|
||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...c/main/java/fast/boot/autoconfigure/configuration/HelloWorldBeanFactoryPostProcessor.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package fast.boot.autoconfigure.configuration; | ||
|
||
import org.springframework.beans.BeansException; | ||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor; | ||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; | ||
import org.springframework.beans.factory.support.BeanDefinitionBuilder; | ||
|
||
/** | ||
* @author qinfuxiang | ||
*/ | ||
public class HelloWorldBeanFactoryPostProcessor implements BeanFactoryPostProcessor { | ||
@Override | ||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { | ||
BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(HelloWorldConfiguration.class); | ||
beanFactory.registerSingleton(HelloWorldConfiguration.class.getName(), bdb.getBeanDefinition()); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
fast-boot-examples/auto-configure/src/main/resources/META-INF/spring.factories
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ | ||
fast.boot.autoconfigure.configuration.HelloWorldBeanDefinitionRegistryPostProcessor |