reload the datasource in localsessionfactory

Description

Hi Team,

I am using LocalsessionFactory where it takes apache BasicDataSource, I have requirement like password which we are setting while creating BasicDataSource needs to be pulled from a webservice. This localSessionFactory is all part of the @configuration , so it all gets loaded at application/server startup. Is there a way where we can reload the datasource/sessionfactory with new password, in case password is changed without restarting the applicaition or server.

 

@Bean
public LocalSessionFactoryBean sessionFactory() throws SQLException {
LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
sessionFactory.setDataSource(dataSource());
sessionFactory.setPackagesToScan("com.arun.model");
sessionFactory.setAnnotatedPackages("com.arun.model");
sessionFactory.setHibernateProperties(hibernateProperties());
return sessionFactory;
}

 

public DataSource dataSource() throws SQLException {

 

 

@Autowired
private SessionFactory sessionFactory;

Environment

None

Assignee

Unassigned

Reporter

Arunprasad