Reputation: 622
Right now I have an InitialReferenceLoaderImpl
which is annotated by @ApplicationScope
and the function is annotated by @PostConstruct
, in this class I'm loading my Application Properties
from the SQL table, but the problem is, If users change something on Application Properties
table, it does not get reflected directly, User needs to restart the server, which I don't want.
I want the user to hit the /refresh
URL so that Application Properties
can be reloaded.
Sorry for the confusing explanation.
Upvotes: 0
Views: 49
Reputation: 622
I've solved my problem by using Bean.refresh()
, The solution I was seeking, was I wanted a /refresh
end-point which will refresh my bean to do that I followed the following steps -
I Autowired the ConfigurableApplicationContext
@Autowired
private ConfigurableApplicationContext context;
In the endpoint I initialized the bean -
ReferenceClass bean = context.getBean(ReferenceClass.class);
Refreshed is using .refresh()
bean.refresh();
That's it, it solved my issue, once the user hits the /refresh
endpoint it refreshes my bean.
Upvotes: 0