title: Recommended way to access Spring beans in Apache Tomcat webapp?
body: <p>I'm developing a web application on Apache Tomcat 6 with Hibernate and Spring, I'm using different XML configuration files to define my Spring beans (like the Hibernate DAO, Quartz scheduler and some other stuff). All these files are loaded at Tomcat start up via web.xml (ContextLoaderListener).</p>
  
  <p>Now I'm not sure what is the recommended way to get access to my beans.</p>
  
  <p>Should I write on class which provides the BeanFactory for all classes which should use a bean, or is it the better way to load the BeanFactory in each class.</p>
  
  <pre><code>BeanFactory bf = (BeanFactory) ContextLoader.getCurrentWebApplicationContext();
  </code></pre>