title: how to know resource from which a bean is loaded in spring project.
body: <p>I am new to spring framework. I am trying to know the list of xml files that are referenced while loading the beans.</p>
  
  <p>By writing a class that is ApplicationContextAware, i am able to view the list of beans with : </p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration("classpath:spring/sample-testcontext.xml")
  
  public class SampleClass implements ApplicationContextAware {
      @Autowired
      ApplicationContext applicationContext;
  
      @Test
      public void testMethod() {
  
          for (String beanName : applicationContext.getBeanDefinitionNames()) {
              System.out.println("BeanName " + beanName);
          }
      }
  }
  </code></pre>
  
  <p>But i want to know from which configuration files the beans are loaded. </p>
  
  <p>Say "sample-testcontext.xml" contains </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
      xmlns:util="http://www.springframework.org/schema/util"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
          http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"&gt;
  
  
      &lt;beans:import resource="classpath*:spring/sample-testOneMorecontext.xml"/&gt;
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>I want to know list of file names from which beans are loaded as "sample-testOneMorecontext.xml" and "sample-testcontext.xml". </p>