本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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;
}
}