Skip to content

Instantly share code, notes, and snippets.

@cbeams
Created April 19, 2011 15:15
Show Gist options
  • Save cbeams/928339 to your computer and use it in GitHub Desktop.
Save cbeams/928339 to your computer and use it in GitHub Desktop.
@Configuration
@Import(MyFrameworkConfiguration.class)
public class UserConfig implements MyFrameworkInitializer {
@Bean
public FooCallback fooCallback() {
return new FooCallback() {
public void doWithFoo(Foo foo) {
foo.setAwesome(true);
}
};
}
}
public interface MyFrameworkInitializer {
FooCallback fooCallback();
}
@Configuration
public class MyFrameworkConfiguration {
@Autowired(optional=true)
private FooCallback fooCallback;
@PostConstruct
public void initialize() {
if (fooCallback != null) {
fooCallback.doWithFoo(foo());
}
}
@Bean
public Foo foo() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment