title: How do I reference other beans from within a configuration class in spring?
body: <p>I have various swing actions in a swing/spring application.  They are annotated as @Component so they should be visible after component autoscanning.  I have a configuration class where I am defining a bean for a menu for the main frame/window.  The method to create/return the menu object has to reference the actions as necessary.  In a Beans.xml setting, I would just do something like:</p>
  
  <pre><code>&lt;bean id="mainMenu" class="javax.swing.JMenu"&gt;
       &lt;constructor-arg id="0" value="Schedule" /&gt;
       &lt;constructor-arg id="1"&gt;
            &lt;value type="int"&gt;0&lt;/value&gt;
       &lt;/constructor&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Then, in the setter for the bean in the main form, I would autowire before the setter and add the items.  In swing there's no way to as a property set the menu items - you have to add them.  In a beans.xml setting, I can though reference a bean by id or type in another bean's creation.  How do I do that in my configuration class?  Like this is my configuration class:</p>
  
  <pre><code>@Configuration
  @ComponentScan("net.draconia.ngucc.usher")
  public class BeanConfiguration
  {
      private Action mActCreateSchedule, mActEditSchedule, mActExit, mActRemoveSchedule;
      private JMenu mMnuSchedule;
  
      @Bean("scheduleMenu")
      public JMenu getScheduleMenu()
      {
          if(mMnuSchedule == null)
              {
              mMnuSchedule = new JMenu("Schedule");
              mMnuSchedule.setMnemonic(KeyEvent.VK_S);
  
              mMnuSchedule.add(getCreateScheduleAction());
              mMnuSchedule.add(getEditScheduleAction());
              mMnuSchedule.add(getRemoveScheduleAction());
              mMnuSchedule.addSeparator();
              mMnuSchedule.add(getExitAction());
              }
      }
  }
  </code></pre>
  
  <p>I want to be able to instead of the get functions, or maybe have get functions to access the items - in the get functions then there would be something like return((CreateSchedule)(getBean(CreateSchedule.class))) (I think I have enough/right number of parentheses there haha).  I'd just need access to an application context.  Can I somehow autowire one(an application context) in the configuration class or how would I possibly get access to a getBean to access those component scanned beans?</p>
  
  <p>Thank you in advance!</p>