0

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.

Daksharaj kamal
  • 526
  • 1
  • 4
  • 11

1 Answers1

0

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 -

  1. I Autowired the ConfigurableApplicationContext
    @Autowired
    private ConfigurableApplicationContext context;

  2. In the endpoint I initialized the bean -
    ReferenceClass bean = context.getBean(ReferenceClass.class);

  3. Refreshed is using .refresh()
    bean.refresh();

That's it, it solved my issue, once the user hits the /refresh endpoint it refreshes my bean.

Daksharaj kamal
  • 526
  • 1
  • 4
  • 11