当前位置: 首页>>代码示例>>Java>>正文


Java WebApplicationContext.containsBean方法代码示例

本文整理汇总了Java中org.springframework.web.context.WebApplicationContext.containsBean方法的典型用法代码示例。如果您正苦于以下问题:Java WebApplicationContext.containsBean方法的具体用法?Java WebApplicationContext.containsBean怎么用?Java WebApplicationContext.containsBean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.web.context.WebApplicationContext的用法示例。


在下文中一共展示了WebApplicationContext.containsBean方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: lookupEntityManagerFactory

import org.springframework.web.context.WebApplicationContext; //导入方法依赖的package包/类
/**
 * Look up the EntityManagerFactory that this filter should use.
 * <p>The default implementation looks for a bean with the specified name
 * in Spring's root application context.
 * @return the EntityManagerFactory to use
 * @see #getEntityManagerFactoryBeanName
 */
protected EntityManagerFactory lookupEntityManagerFactory() {
	WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
	String emfBeanName = getEntityManagerFactoryBeanName();
	String puName = getPersistenceUnitName();
	if (StringUtils.hasLength(emfBeanName)) {
		return wac.getBean(emfBeanName, EntityManagerFactory.class);
	}
	else if (!StringUtils.hasLength(puName) && wac.containsBean(DEFAULT_ENTITY_MANAGER_FACTORY_BEAN_NAME)) {
		return wac.getBean(DEFAULT_ENTITY_MANAGER_FACTORY_BEAN_NAME, EntityManagerFactory.class);
	}
	else {
		// Includes fallback search for single EntityManagerFactory bean by type.
		return EntityManagerFactoryUtils.findEntityManagerFactory(wac, puName);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:OpenEntityManagerInViewFilter.java

示例2: getValue

import org.springframework.web.context.WebApplicationContext; //导入方法依赖的package包/类
@Override
public Object getValue(ELContext elContext, Object base, Object property) throws ELException {
	if (base != null) {
		if (base instanceof WebApplicationContext) {
			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;
			}
		}
	}
	else {
		if (WEB_APPLICATION_CONTEXT_VARIABLE_NAME.equals(property)) {
			elContext.setPropertyResolved(true);
			return getWebApplicationContext(elContext);
		}
	}

	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:WebApplicationContextFacesELResolver.java

示例3: getType

import org.springframework.web.context.WebApplicationContext; //导入方法依赖的package包/类
@Override
public Class<?> getType(ELContext elContext, Object base, Object property) throws ELException {
	if (base != null) {
		if (base instanceof WebApplicationContext) {
			WebApplicationContext wac = (WebApplicationContext) base;
			String beanName = property.toString();
			if (logger.isDebugEnabled()) {
				logger.debug("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.getType(beanName);
				}
				catch (BeansException ex) {
					throw new ELException(ex);
				}
			}
			else {
				// Mimic standard JSF/JSP behavior when base is a Map by returning null.
				return null;
			}
		}
	}
	else {
		if (WEB_APPLICATION_CONTEXT_VARIABLE_NAME.equals(property)) {
			elContext.setPropertyResolved(true);
			return WebApplicationContext.class;
		}
	}

	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:WebApplicationContextFacesELResolver.java

示例4: lookupMultipartResolver

import org.springframework.web.context.WebApplicationContext; //导入方法依赖的package包/类
/**
 * 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;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:MultipartFilter.java


注:本文中的org.springframework.web.context.WebApplicationContext.containsBean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。