use of org.springframework.web.context.WebApplicationContext in project spring-framework by spring-projects.
the class StandaloneMockMvcBuilderTests method applicationContextAttribute.
// SPR-12553
@Test
public void applicationContextAttribute() {
TestStandaloneMockMvcBuilder builder = new TestStandaloneMockMvcBuilder(new PlaceholderController());
builder.addPlaceholderValue("sys.login.ajax", "/foo");
WebApplicationContext wac = builder.initWebAppContext();
assertEquals(wac, WebApplicationContextUtils.getRequiredWebApplicationContext(wac.getServletContext()));
}
use of org.springframework.web.context.WebApplicationContext in project spring-framework by spring-projects.
the class MultipartFilter method lookupMultipartResolver.
/**
* Look for a MultipartResolver bean in the root web application context.
* Supports a "multipartResolverBeanName" filter init param; the default
* bean name is "filterMultipartResolver".
* <p>This can be overridden to use a custom MultipartResolver instance,
* for example if not using a Spring web application context.
* @return the MultipartResolver instance, or {@code null} if none found
*/
protected MultipartResolver lookupMultipartResolver() {
WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
String beanName = getMultipartResolverBeanName();
if (wac != null && wac.containsBean(beanName)) {
if (logger.isDebugEnabled()) {
logger.debug("Using MultipartResolver '" + beanName + "' for MultipartFilter");
}
return wac.getBean(beanName, MultipartResolver.class);
} else {
return this.defaultMultipartResolver;
}
}
use of org.springframework.web.context.WebApplicationContext in project spring-framework by spring-projects.
the class DelegatingFilterProxy method doFilter.
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws ServletException, IOException {
// Lazily initialize the delegate if necessary.
Filter delegateToUse = this.delegate;
if (delegateToUse == null) {
synchronized (this.delegateMonitor) {
if (this.delegate == null) {
WebApplicationContext wac = findWebApplicationContext();
if (wac == null) {
throw new IllegalStateException("No WebApplicationContext found: " + "no ContextLoaderListener or DispatcherServlet registered?");
}
this.delegate = initDelegate(wac);
}
delegateToUse = this.delegate;
}
}
// Let the delegate perform the actual doFilter operation.
invokeDelegate(delegateToUse, request, response, filterChain);
}
use of org.springframework.web.context.WebApplicationContext in project spring-framework by spring-projects.
the class SpringBeanFacesELResolver method getValue.
@Override
public Object getValue(ELContext elContext, Object base, Object property) throws ELException {
if (base == null) {
String beanName = property.toString();
WebApplicationContext wac = getWebApplicationContext(elContext);
if (wac.containsBean(beanName)) {
elContext.setPropertyResolved(true);
return wac.getBean(beanName);
}
}
return null;
}
use of org.springframework.web.context.WebApplicationContext in project spring-framework by spring-projects.
the class SpringBeanFacesELResolver method isReadOnly.
@Override
public boolean isReadOnly(ELContext elContext, Object base, Object property) throws ELException {
if (base == null) {
String beanName = property.toString();
WebApplicationContext wac = getWebApplicationContext(elContext);
if (wac.containsBean(beanName)) {
return true;
}
}
return false;
}
Aggregations