how to reload configuration object at runtime in spring mvc

1k views Asked by At

i have a configuration class FTPSchedullingConfiguration which is initialise at app instantiation and get data from table for Starting a scheduler on given Scheduling Expression.

And also my question are not Duplicate as Reloading/Refreshing Spring configuration file without restarting the servlet container like this because i have no any XML File, my application is based on annotation and here Every classes are compiled in .class formate so we can`t change any code at runtime.

@Configuration
@EnableScheduling
public class FTPSchedullingConfiguration {

@Autowired
private FTPTransferServiceInterface ftpTransferServiceInterface;

@Bean
public String getCronFTPTransferValue()
{
    return ftpTransferServiceInterface.getFTPTransferById((long) 1).getTransferCroneTime();
}

 @Scheduled(cron="#{@getCronFTPTransferValue}")
 public void ftpTransfer() {
    ftpTransferServiceInterface.transferFTPRecording();
 }
}

But when i change the Schedule Expression of table then no changing on scheduled time. if i restart server then changed Expression load.

by using updateFTP(),

@RequestMapping(value= {"/updateFTPTransfer"})
private String updateFTP(...){
  ftpTransferServiceInterface.updateFTP(ftpDomain);
    //here i want to change the value of @Scheduled 
}

my actual need like when i changed Expression value in table by updateFTP(...){...} at that time also my schedulling value changed (OR) Refreshed FTPSchedullingConfiguration class.

Thanks in Advance.

0

There are 0 answers