I am loading keystore
in Spring WS via JPA
from database.
@Bean(name = "keyStore")
@Primary
KeyStoreFactoryBean keyStore() throws Exception {
try {
KeyStore keyStore = keyService.keyStore();
KeyStoreFactoryBean keyStoreFactory = new KeyStoreFactoryBean();
keyStoreFactory.setPassword(keyStore.getPassword());
keyStoreFactory.setLocation(keyStore.asResource());
keyStoreFactory.afterPropertiesSet();
return keyStoreFactory;
} catch (Exception e) {
throw e;
}
}
This code works, but if I update keystore record in database, KeyStoreFactoryBean
is not reloaded (obviously). I aware of scope
anotation for beans but not sure what scope
is best for this situation?
How to "reload" this bean everytime database record is changed?