I have a property that i need to change on the fly.
As beans are created and autowired on startup, even if i change the bean during runtime is not taking into effect.
Ex:
Class serviceA {
Instant instant;
}
@Configuration
Class config {
@Bean
Instant instant() {
return instant.now();
}
}
Now if i have a request header to use a time(sent as header in rest call) i need to use that time to create a instant and use it instead of the above bean.
Is there a way to refresh a aingle bean (Instant in this case) as this is autowired in multiple classes and i want to refresh only those classes to update the instant dependency.
I dont think this is advisable to update the autowired beans during runtime, any ither suggestions or better appeochaes to handle this?
Or if i can use Instant bean how do i refresh the instant bean and also where it is injeced?
Appreciate in advance.