Prevent @Bean method from being called during @PreDestroy

This commit is contained in:
Dave Syer 2013-11-20 11:19:54 +00:00
parent 6d4d495003
commit faf02a21ab
1 changed files with 6 additions and 2 deletions

View File

@ -55,16 +55,20 @@ public class MongoRepositoriesAutoConfiguration {
@Autowired
private MongoProperties config;
private Mongo mongo;
@PreDestroy
public void close() throws UnknownHostException {
mongo().close();
if (this.mongo != null) {
this.mongo.close();
}
}
@Bean
@ConditionalOnMissingBean(Mongo.class)
Mongo mongo() throws UnknownHostException {
return this.config.mongo();
this.mongo = this.config.mongo();
return this.mongo;
}
@Bean