[#61] Remove Magic String Usage from PersistenceConfiguration (#116)

This commit is contained in:
apldev3 2019-03-28 09:53:50 -04:00 committed by GitHub
parent bc717c9241
commit 267001226e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View File

@ -34,7 +34,7 @@ public class DeviceHealthManagerImpl implements DeviceHealthManager {
private AlertManager alertManager;
@Autowired
@Qualifier("general_db_man_bean")
@Qualifier(PersistenceConfiguration.DEVICE_STATE_MANAGER_BEAN_NAME)
private DeviceStateManager deviceStateManager;
@Autowired

View File

@ -18,6 +18,12 @@ import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
@Configuration
@Import({ HibernateConfiguration.class })
public class PersistenceConfiguration {
/**
* The bean name to retrieve the default/general implementation of {@link DeviceStateManager}.
*/
public static final String DEVICE_STATE_MANAGER_BEAN_NAME = "general_db_man_bean";
@Autowired
private LocalSessionFactoryBean sessionFactory;
@ -140,7 +146,7 @@ public class PersistenceConfiguration {
*
* @return {@link DeviceStateManager}
*/
@Bean(name = "general_db_man_bean")
@Bean(name = DEVICE_STATE_MANAGER_BEAN_NAME)
public DeviceStateManager generalDeviceStateManager() {
DBDeviceStateManager manager = new DBDeviceStateManager(sessionFactory.getObject());
setDbManagerRetrySettings(manager);

View File

@ -46,7 +46,7 @@ public class DeviceHealthManagerImplTest {
private AlertManager alertManager;
@Mock
@Qualifier("general_db_man_bean")
@Qualifier(PersistenceConfiguration.DEVICE_STATE_MANAGER_BEAN_NAME)
private DeviceStateManager deviceStateManager;
@Mock