* Returns named Spring bean from <code>ServletContext</code>. Throws
* <code>ApplicationConfigurationException</code> if Spring context is not present or named bean is not present in context
*/
public static Object getSpringBean(ServletContext servletContext, String beanName)
{
WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
if (context == null)
{
throw new ApplicationConfigurationException(
"No spring root context found using "
+ "WebApplicationContextUtils.getWebApplicationContext(servletContext). This is probably an application configuration error");
}
Object bean = context.getBean(beanName);
if (bean == null)
{
throw new ApplicationConfigurationException("No spring bean " + beanName
+ " found. This is probably an application configuration error");
}