Skip to content

Instantly share code, notes, and snippets.

@keesun
Created January 18, 2012 15:36
Show Gist options
  • Select an option

  • Save keesun/1633571 to your computer and use it in GitHub Desktop.

Select an option

Save keesun/1633571 to your computer and use it in GitHub Desktop.
Spring 3.1's Configurer Pattern
@Configuration
@EnableHello
public class AppConfig implements NameConfigurer {
@Override
public void configure(Hello hello) {
hello.setName("Thank you very much, Toby.");
}
}
@Retention(value = RetentionPolicy.RUNTIME)
@Import(HelloConfig.class)
public @interface EnableHello {
}
@Configuration
public class HelloConfig {
@Autowired NameConfigurer configurer;
@Bean
public Hello hello() {
Hello h = new Hello();
configurer.configure(h);
return h;
}
}
public interface NameConfigurer {
void configure(Hello hello);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment