List of usage examples for org.springframework.context ApplicationContext containsBeanDefinition
boolean containsBeanDefinition(String beanName);
From source file:com.graby.store.base.remote.RemotingAnnotationHandlerMapping.java
/** * Checks for presence of the {@link org.springframework.web.bind.annotation.RequestMapping} * annotation on the handler class and on any of its methods. *///from w ww. j av a 2 s. c om protected String[] determineUrlsForHandler(String beanName) { ApplicationContext context = getApplicationContext(); Class<?> handlerType = context.getType(beanName); RemotingService mapping = AnnotationUtils.findAnnotation(handlerType, RemotingService.class); if (mapping == null && context instanceof ConfigurableApplicationContext && context.containsBeanDefinition(beanName)) { ConfigurableApplicationContext cac = (ConfigurableApplicationContext) context; BeanDefinition bd = cac.getBeanFactory().getMergedBeanDefinition(beanName); if (bd instanceof AbstractBeanDefinition) { AbstractBeanDefinition abd = (AbstractBeanDefinition) bd; if (abd.hasBeanClass()) { Class<?> beanClass = abd.getBeanClass(); mapping = AnnotationUtils.findAnnotation(beanClass, RemotingService.class); } } } if (mapping != null) { this.cachedMappings.put(handlerType, mapping); Set<String> urls = new LinkedHashSet<String>(); String path = mapping.serviceUrl(); if (path != null) { addUrlsForPath(urls, path); return StringUtils.toStringArray(urls); } else { return null; } } else { return null; } }
From source file:org.impalaframework.spring.module.graph.GraphDelegatingApplicationContext.java
private boolean containsBeanDefintion(ApplicationContext applicationContext, String name) { boolean containsBeanDefinition = applicationContext.containsBeanDefinition(maybeDeferenceFactoryBean(name)); return containsBeanDefinition; }
From source file:org.impalaframework.spring.service.bean.BaseExistingBeanExposingFactoryBean.java
private ApplicationContext maybeFindApplicationContext() { ApplicationContext currentContext = this.applicationContext; final String beanName = getBeanNameToSearchFor(); if (getIncludeCurrentBeanFactory()) { if (currentContext.containsBeanDefinition(beanName)) { return currentContext; }/* ww w . j a va2s . c o m*/ } ApplicationContext parentContext = applicationContext.getParent(); if (parentContext instanceof GraphDelegatingApplicationContext) { return ((GraphDelegatingApplicationContext) parentContext).getContainingApplicationContext(beanName); } else if (parentContext != null) { return BeanFactoryUtils.maybeFindApplicationContext(parentContext, beanName); } return null; }