Created
December 5, 2013 10:32
-
-
Save Qkyrie/7803240 to your computer and use it in GitHub Desktop.
@bean with destroy and init methods
This file contains hidden or 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 Foo { | |
public void init() { | |
// initialization logic | |
} | |
} | |
public class Bar { | |
public void cleanup() { | |
// destruction logic | |
} | |
} | |
@Configuration | |
public class AppConfig { | |
@Bean(initMethod = "init") | |
public Foo foo() { | |
return new Foo(); | |
} | |
@Bean(destroyMethod = "cleanup") | |
public Bar bar() { | |
return new Bar(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment