1

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?

Neil Stockton
  • 11,383
  • 3
  • 34
  • 29
jnemecz
  • 3,171
  • 8
  • 41
  • 77
  • Sounds like you want to have DB Change Notifications. This is probably database dependent. Here is an [example](http://stackoverflow.com/questions/13258976/how-to-refresh-jpa-entities-when-backend-database-changes-asynchronously) – Glenn Dec 23 '16 at 17:57
  • You mention JPA then promptly don't show any usage of JPA API – Neil Stockton Dec 23 '16 at 18:46

0 Answers0