title: Spring register objects destroy method
body: <p>I'm currently converting XML spring config to Java annotations, and I've ran into a little bit of an annoying situation.</p>
  
  <p>I need to create 3 beans, which use the same class internally, but need to be seperate instances. However, these internal beans need to register their shutdown method with Spring.</p>
  
  <p>I can't think how to do this without creating 9 beans in java (which is fine, but it seems a little bit wrong to be polluting the class like this)</p>
  
  <p>In XML config it looks something like this:</p>
  
  <pre><code>&lt;bean class="outer1"&gt;
      &lt;constructor-arg&gt;
          &lt;bean class="middle"&gt;
              &lt;constructor-arg&gt;
                  &lt;bean class="inner" /&gt;
              &lt;/constructor-arg&gt;
          &lt;/bean&gt;
      &lt;/constructor-arg&gt;
  &lt;/bean&gt;
  &lt;bean class="outer2"&gt;
      &lt;constructor-arg&gt;
          &lt;bean class="middle"&gt;
              &lt;constructor-arg&gt;
                  &lt;bean class="inner" /&gt;
              &lt;/constructor-arg&gt;
          &lt;/bean&gt;
      &lt;/constructor-arg&gt;
  &lt;/bean&gt;
  &lt;bean class="outer3"&gt;
      &lt;constructor-arg&gt;
          &lt;bean class="middle"&gt;
              &lt;constructor-arg&gt;
                  &lt;bean class="inner" /&gt;
              &lt;/constructor-arg&gt;
          &lt;/bean&gt;
      &lt;/constructor-arg&gt;
  &lt;/bean&gt;
  </code></pre>