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

Status

Assignee

Unassigned

Reporter

Arunprasad

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Priority

Major
Configure