Spring Framework WebApplicationContext - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework WebApplicationContext class.

This code example shows how to use the following methods:containsBean, getBean
 
	@Override 
	public Object getAttribute(String name) {
		if ((this.explicitAttributes == null || !this.explicitAttributes.contains(name)) &&
				(this.exposedContextBeanNames == null || this.exposedContextBeanNames.contains(name)) &&
				this.webApplicationContext.containsBean(name)) {
			return this.webApplicationContext.getBean(name);
		} 
		else { 
			return super.getAttribute(name);
		} 
	} 
 
	@Override 
	public void setAttribute(String name, Object value) {
		super.setAttribute(name, value);
		if (this.explicitAttributes == null) {
			this.explicitAttributes = new HashSet<String>(8);
		} 
		this.explicitAttributes.add(name);
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:containsBean, getBean
	 * @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; 
		} 
	} 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:containsBean, getBean
				WebApplicationContext wac = (WebApplicationContext) base; 
				String beanName = property.toString(); 
				if (logger.isTraceEnabled()) { 
					logger.trace("Attempting to resolve property '" + beanName + "' in root WebApplicationContext"); 
				} 
				if (wac.containsBean(beanName)) { 
					if (logger.isDebugEnabled()) { 
						logger.debug("Successfully resolved property '" + beanName + "' in root WebApplicationContext"); 
					} 
					elContext.setPropertyResolved(true); 
					try { 
						return wac.getBean(beanName); 
					} 
					catch (BeansException ex) { 
						throw new ELException(ex); 
					} 
				} 
				else { 
					// Mimic standard JSF/JSP behavior when base is a Map by returning null. 
					return null; 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getServletContext
	 * Protected constructor. Not intended for direct instantiation. 
	 * @see MockMvcBuilders#webAppContextSetup(WebApplicationContext) 
	 */ 
	protected DefaultMockMvcBuilder(WebApplicationContext webAppContext) { 
		Assert.notNull(webAppContext, "WebApplicationContext is required"); 
		Assert.notNull(webAppContext.getServletContext(), "WebApplicationContext must have a ServletContext"); 
		this.webAppContext = webAppContext; 
	} 
 
 
	@Override 
	protected WebApplicationContext initWebAppContext() { 
		return this.webAppContext; 
	} 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBean
 */ 
public class SpringBeanPreparerFactory extends AbstractSpringPreparerFactory { 
 
	@Override 
	protected ViewPreparer getPreparer(String name, WebApplicationContext context) throws TilesException { 
		return context.getBean(name, ViewPreparer.class); 
	} 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBean
 */ 
public class SpringBeanPreparerFactory extends AbstractSpringPreparerFactory { 
 
	@Override 
	protected ViewPreparer getPreparer(String name, WebApplicationContext context) throws TilesException { 
		return context.getBean(name, ViewPreparer.class); 
	} 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getServletContext
public class MockMvcBuilders { 
 
	/** 
	 * Build a {@link MockMvc} using the given, fully initialized, i.e. 
	 * refreshed, {@link WebApplicationContext}. The {@link DispatcherServlet} 
	 * will use the context to discover Spring MVC infrastructure and 
	 * application controllers in it. The context must have been configured with 
	 * a {@link ServletContext}. 
	 */ 
	public static DefaultMockMvcBuilder webAppContextSetup(WebApplicationContext context) { 
		return new DefaultMockMvcBuilder(context); 
	} 
 
	/** 
	 * Build a {@link MockMvc} by registering one or more {@code @Controller}'s 
	 * instances and configuring Spring MVC infrastructure programmatically. 
	 * This allows full control over the instantiation and initialization of 
	 * controllers, and their dependencies, similar to plain unit tests while 
	 * also making it possible to test one controller at a time. 
	 * 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getServletContext
	 */ 
	@Override 
	protected void initApplicationContext(ApplicationContext context) { 
		super.initApplicationContext(context); 
		if (this.servletContext == null && context instanceof WebApplicationContext) { 
			this.servletContext = ((WebApplicationContext) context).getServletContext(); 
			if (this.servletContext != null) { 
				initServletContext(this.servletContext); 
			} 
		} 
	} 
 
	/** 
	 * Subclasses may override this for custom initialization based 
	 * on the ServletContext that this application object runs in. 
	 * <p>The default implementation is empty. Called by 
	 * {@link #initApplicationContext(org.springframework.context.ApplicationContext)} 
	 * as well as {@link #setServletContext(javax.servlet.ServletContext)}. 
	 * @param servletContext the ServletContext that this application object runs in 
	 * (never {@code null}) 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBean
		if (logger.isDebugEnabled()) { 
			logger.debug("Using PersistenceManagerFactory '" + getPersistenceManagerFactoryBeanName() + 
					"' for OpenPersistenceManagerInViewFilter"); 
		} 
		WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); 
		return wac.getBean(getPersistenceManagerFactoryBeanName(), PersistenceManagerFactory.class); 
	} 
 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getServletContext
 
		ApplicationContext context = testContext.getApplicationContext(); 
 
		if (context instanceof WebApplicationContext) { 
			WebApplicationContext wac = (WebApplicationContext) context; 
			ServletContext servletContext = wac.getServletContext(); 
			Assert.state(servletContext instanceof MockServletContext, String.format( 
				"The WebApplicationContext for test context %s must be configured with a MockServletContext.", 
				testContext)); 
 
			if (logger.isDebugEnabled()) { 
				logger.debug(String.format( 
					"Setting up MockHttpServletRequest, MockHttpServletResponse, ServletWebRequest, and RequestContextHolder for test context %s.", 
					testContext)); 
			} 
 
			MockServletContext mockServletContext = (MockServletContext) servletContext; 
			MockHttpServletRequest request = new MockHttpServletRequest(mockServletContext); 
			MockHttpServletResponse response = new MockHttpServletResponse(); 
			ServletWebRequest servletWebRequest = new ServletWebRequest(request, response); 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Spring Framework WebApplicationContext Methods: