title: How to Inject Spring ReloadableResourceBundleMessageSource
body: <p>In order to programmatically refresh the resource bundle cache, I am using Spring's ReloadableResourceBundleMessageSource.  I am having trouble injecting it into my bean where I want to invoke the clearCache() method.  </p>
  
  <p>I've had to resort to the following:</p>
  
  <pre><code>private ReloadableResourceBundleMessageSource messageSource;
  
  @Autowired
  public void setMessageSource(MessageSource messageSource) {
    this.messageSource = (ReloadableResourceBundleMessageSource((DelegatingMessageSource)messageSource).getParentMessageSource();
  }
  </code></pre>
  
  <p>This works, but there must be a better way.  The message resource is defined as follows:</p>
  
  <pre><code>&lt;bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"&gt;
  &lt;property name="basenames" &gt;
  &lt;list&gt;
     &lt;value&gt;WEB-INF/content/Content&lt;/value&gt;
   &lt;/list&gt;
   &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I don't understand why Spring is injecting a message source of type DelegatingMessageSource.</p>