String attributeName = qualifier.getQualifiedAttributeName(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, applicationId, targetModuleName);
WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext, attributeName);
if (applicationContext == null) {
throw new ConfigurationException("No root web application context associated with module '" + targetModuleName + "'");
}
final String beanName = getBeanName(request);
final Object bean = applicationContext.getBean(beanName, Filter.class);
if (!(bean instanceof Filter)) {
throw new ConfigurationException("Delegate bean '" + beanName + "' from module '" + targetModuleName + "' is not an instance of " + Filter.class.getName());
}
return ObjectUtils.cast(bean, Filter.class);
}