use of org.springframework.beans.factory.NoSuchBeanDefinitionException in project cxf by apache.
the class ConfigurerImpl method configureBean.
public synchronized void configureBean(String bn, Object beanInstance, boolean checkWildcards) {
if (null == appContexts) {
return;
}
if (null == bn) {
bn = getBeanName(beanInstance);
}
if (null == bn) {
return;
}
if (checkWildcards) {
configureWithWildCard(bn, beanInstance);
}
final String beanName = bn;
setBeanWiringInfoResolver(new BeanWiringInfoResolver() {
public BeanWiringInfo resolveWiringInfo(Object instance) {
if (!"".equals(beanName)) {
return new BeanWiringInfo(beanName);
}
return null;
}
});
for (ApplicationContext appContext : appContexts) {
if (appContext.containsBean(bn)) {
this.setBeanFactory(appContext.getAutowireCapableBeanFactory());
}
}
try {
// this can leak memory
if (beanFactory instanceof AbstractBeanFactory) {
((AbstractBeanFactory) beanFactory).getMergedBeanDefinition(bn);
}
super.configureBean(beanInstance);
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Successfully performed injection.");
}
} catch (NoSuchBeanDefinitionException ex) {
// incorrect bean ids
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "NO_MATCHING_BEAN_MSG", beanName);
}
}
}
use of org.springframework.beans.factory.NoSuchBeanDefinitionException in project engine by craftercms.
the class BeanDefinitionUtils method createBeanDefinitionFromOriginal.
/**
* Creates a bean definition for the specified bean name. If the parent context of the current context contains a
* bean definition with the same name, the definition is created as a bean copy of the parent definition. This
* method is useful for config parsers that want to create a bean definition from configuration but also want to
* retain the default properties of the original bean.
*
* @param applicationContext the current application context
* @param beanName
* @return the bean definition
*/
public static BeanDefinition createBeanDefinitionFromOriginal(ApplicationContext applicationContext, String beanName) {
ApplicationContext parentContext = applicationContext.getParent();
BeanDefinition parentDefinition = null;
if (parentContext != null && parentContext.getAutowireCapableBeanFactory() instanceof ConfigurableListableBeanFactory) {
ConfigurableListableBeanFactory parentBeanFactory = (ConfigurableListableBeanFactory) parentContext.getAutowireCapableBeanFactory();
try {
parentDefinition = parentBeanFactory.getBeanDefinition(beanName);
} catch (NoSuchBeanDefinitionException e) {
}
}
if (parentDefinition != null) {
return new GenericBeanDefinition(parentDefinition);
} else {
return new GenericBeanDefinition();
}
}
use of org.springframework.beans.factory.NoSuchBeanDefinitionException in project leopard by tanhaichao.
the class LeopardHandlerMapping method initApplicationContext.
@Override
protected void initApplicationContext(ApplicationContext context) throws BeansException {
try {
Redis redis = (Redis) context.getBean("sessionRedis");
StoreRedisImpl.setRedis(redis);
} catch (NoSuchBeanDefinitionException e) {
logger.warn("没有配置sessionRedis,不启用分布式session.");
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
super.initApplicationContext(context);
requestMappingInfoBuilder = new RequestMappingInfoBuilderImpl(context);
}
use of org.springframework.beans.factory.NoSuchBeanDefinitionException in project jersey by jersey.
the class AutowiredInjectResolver method getBeanFromSpringContext.
private Object getBeanFromSpringContext(String beanName, Injectee injectee, final boolean required) {
try {
DependencyDescriptor dependencyDescriptor = createSpringDependencyDescriptor(injectee);
Set<String> autowiredBeanNames = new HashSet<>(1);
autowiredBeanNames.add(beanName);
return ctx.getAutowireCapableBeanFactory().resolveDependency(dependencyDescriptor, null, autowiredBeanNames, null);
} catch (NoSuchBeanDefinitionException e) {
if (required) {
LOGGER.warning(e.getMessage());
throw e;
}
return null;
}
}
use of org.springframework.beans.factory.NoSuchBeanDefinitionException in project spring-framework by spring-projects.
the class MockHttpServletRequestBuilder method getFlashMapManager.
private FlashMapManager getFlashMapManager(MockHttpServletRequest request) {
FlashMapManager flashMapManager = null;
try {
ServletContext servletContext = request.getServletContext();
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
flashMapManager = wac.getBean(DispatcherServlet.FLASH_MAP_MANAGER_BEAN_NAME, FlashMapManager.class);
} catch (IllegalStateException ex) {
// ignore
} catch (NoSuchBeanDefinitionException ex) {
// ignore
}
return (flashMapManager != null ? flashMapManager : new SessionFlashMapManager());
}
Aggregations