title: Spring, prototypes, and MBeanExporter
body: <p>I am using Spring in conjunction with its <code>MBeanExporter</code>. I have a prototype bean definition which should only be instantiated when a call to <code>ApplicationContext.getBean()</code> is made. However, the <code>MBeanExporter</code> is (incorrectly) instantiating an instance of the prototype bean when bootstrapping the container.</p>
  
  <p>I found <a href="https://jira.springsource.org/browse/SPR-5481" rel="nofollow">this bug report</a> from ages ago, with no notable response.</p>
  
  <p>This seems to me like it must be a common scenario, so I feel like I must be missing something. It's important that my prototype not be instantiated ahead of time, and that I can use <code>MBeanExporter</code> to make my JMX integration simpler. Can anyone explain what I'm doing wrong?</p>
  
  <p>For reference, my spring config looks like this:</p>
  
  <pre><code>&lt;bean id="foo" class="MyPrototypeClassName" scope="prototype"/&gt;
  
  &lt;bean id="namingStrategy" class="org.springframework.jmx.export.naming.IdentityNamingStrategy"/&gt;
  
  &lt;bean id="exporter" class="org.springframework.jmx.export.MBeanExporter"&gt;
      &lt;property name="namingStrategy" ref="namingStrategy"/&gt;
      &lt;property name="autodetect" value="true"/&gt;
  &lt;/bean&gt;
  </code></pre>