Created
January 18, 2012 15:18
-
-
Save keesun/1633483 to your computer and use it in GitHub Desktop.
Spring 3.1's @import & ImportBeanDefinitionRegistrar
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
@Retention(value = RetentionPolicy.RUNTIME) | |
@Import(HeloIBDR.class) | |
public @interface EnableHello { | |
String name(); | |
} |
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
public class HeloIBDR implements ImportBeanDefinitionRegistrar { | |
@Override | |
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { | |
BeanDefinition bd = new RootBeanDefinition(Hello.class); | |
bd.getPropertyValues().addPropertyValue("name", "keesun"); | |
registry.registerBeanDefinition("hello", bd); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment