本文整理匯總了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;
}
}