I need change properties in my application at runtime. For example I have a service which send a e-mail with resset password. Request is valid 12 hours. But I want to change this time to 24 or more at runtime. I need to give the opportunity to this action for admin.
My property file has
hours.expired=12
My service
private int hoursExpiredPassword;
public void setHoursExpiredPassword(int hoursExpiredPassword) {
this.hoursExpiredPassword = hoursExpiredPassword;
}
@Override
public ERequests checkRequest(String number, Date date) {
PasswordResetRequest findedObject = passwordResetRequestDao.getObjectByElement(PasswordResetRequest.class, "requestId", number);
if (findedObject == null){
return ERequests.BAD_REQUEST;
}else{
long result = getDateDiff(findedObject.getRequestDate(),date,TimeUnit.HOURS);
if(result >= hoursExpiredPassword){
return ERequests.EXPIRED_REQUEST;
}
}
return ERequests.CORRECT_REQUEST;
}
my spring xml configuration
<bean id="passwordResetRequestService" class="pl.lublin.example.services.servicesDAO.PasswordResetRequestService">
<property name="passwordResetRequestDao" ref="passwordResetRequestDao"></property>
<property name="hoursExpiredPassword" value="${hours.expired}"></property>
</bean>
Could I change this value in someway at runtime?