Skip to content

Instantly share code, notes, and snippets.

@keesun
Created January 18, 2012 15:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keesun/1633483 to your computer and use it in GitHub Desktop.
Save keesun/1633483 to your computer and use it in GitHub Desktop.
Spring 3.1's @import & ImportBeanDefinitionRegistrar
@Retention(value = RetentionPolicy.RUNTIME)
@Import(HeloIBDR.class)
public @interface EnableHello {
String name();
}
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