I have couple of params let's say value1 and value2 which i need to store throughout the lifecycle of an application, can this be achieved? I have two different modules in module1 i have a utility class which comprises of value1 and value2 and this module added as a dependency in module2. I will get the values of value1 and value2 from external service call(i don't want to hit them everytime to get these values). If i create a method in utility class which return these values and mark it as @Caheable will it be there forever(till we retart or redeploy the application) or is there any internal time limit on cacheable. Would u pls suggest some way of storing this?
I have tried this way (How to reinitialize a Spring Bean?), created a Config class(annotated with @Configuration) and created
Module1 - Config.java
@Bean("utilitybean")
public Utility getValues(){
return new Utility("dummyvalue1","dummyvalue2");
}
here using this approach to destroy the bean and create with value1 and value2(methodname-regiter) How to reinitialize a Spring Bean?
public Utility getNewValues(){
return getValues();
}
Module2 - Test.Java
In module2 i have autowired the class
@Autowired
private Config config;
//service call to get the new values
once i get the new values i am calling config.regiter to re-register with new values.
But when i am calling config.getNewValues().. i am still getting the old values.
(i think this is happening bcoz of two different contexts)
Would u pls suggest any other way to store these values throughout the lifecycle of an application?
NOTE: there are 2 other modules which will utilize these new values for other service calls