title: Is there way to reload autowired instance or replace autowired behavior in spring
body: <p>Currently I have a bean that is created in @Configuration which downloads json documents from web and creates a model object. Using this bean (autowired), lot of other beans are initialized on startup</p>
  
  <p>I need a way to reload the bean whenever the json documents changes in the web.</p>
  
  <p>What is the best way to do it?</p>
  
  <p>Code:</p>
  
  <pre><code>@Configuration
  @ComponentScan(basePackages = "com.wellmanage.prism")
  public class PrismConfig {
  
  ...
  @Bean
  public Model model(@Qualifier("prismRestTemplate") RestTemplate restTemplate) {
  
      LOG.info("model()");
      MetadataReader metadataReader = new MetadataReader();
      String prismFormatJson = null;
      if (!isHasLatestTransformedJson()) {
          prismFormatJson = metadataReader.transformToPrismJson(restTemplate, environment);
          setLastGoodPrismConfiguration(prismFormatJson);
      } else {
          prismFormatJson = getLastGoodPrismConfiguration();
      }
      if (model != null) {
          return model;
      } else {
          return metadataReader.createModelForPrism(prismFormatJson);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>@Configuration
  @ComponentScan(basePackages = "com.wellmanage.prism")
  public class PrismDataSourceConfig implements DataSourceConfig {
  
  private final Logger LOG = LoggerFactory.getLogger(PrismDataSourceConfig.class);
  
  @Autowired
  private Environment environment;
  
  @Autowired
  private Model model;
  
  @Primary
  @Bean(name = "itdb_dataSource")
  public DataSource getDataSource() {
  
      LOG.info("getDataSource()");
      return getDataSource("itdb");
  }
  
  @Bean(name = "dataSourceMap")
  public Map&lt;String, DataSource&gt; getDataSourceMap() {
  
      LOG.info("getDataSourceMap()");
  
      Map&lt;String, DataSource&gt; dataSourceMap = Maps.newHashMap();
      getDatabases().forEach((name, database) -&gt; {
          Endpoint endpoint = getEndpoint(name);
          DataSource dataSource = createDataSource(endpoint);
          dataSourceMap.put(name, dataSource);
      });
  
      return dataSourceMap;
  }
  
  @Bean(name = "jdbcTemplateMap")
  public Map&lt;String, JdbcTemplate&gt; getJdbcTemplateMap() {
  
      LOG.info("getDataSource()");
  
      Map&lt;String, JdbcTemplate&gt; jdbcTemplateMap = Maps.newHashMap();
      getDataSourceMap().forEach((name, datasource) -&gt; {
          JdbcTemplate jdbcTemplate = new JdbcTemplate(datasource);
          jdbcTemplateMap.put(name, jdbcTemplate);
      });
  
      return jdbcTemplateMap;
  }
  
  @Override
  public Environment getEnvironment() {
  
      return environment;
  }
  
  @Override
  public Model getModel() {
  
      return model;
  }
  </code></pre>
  
  <p>}</p>