List of usage examples for org.springframework.beans.factory.support AbstractBeanDefinition getMethodOverrides
public MethodOverrides getMethodOverrides()
From source file:org.jdal.beans.CustomBeanDefinitionParser.java
/** * Parse bean like a real bean definition. * @param ele element//from www.j av a2 s . c o m * @param parserContext parserContext * @param builder builder */ protected void parseBeanDefinition(Element ele, ParserContext parserContext, BeanDefinitionBuilder builder) { BeanDefinitionParserDelegate delegate = parserContext.getDelegate(); AbstractBeanDefinition bd = builder.getRawBeanDefinition(); XmlReaderContext reader = parserContext.getReaderContext(); try { delegate.parseBeanDefinitionAttributes(ele, beanName, null, bd); bd.setDescription(DomUtils.getChildElementValueByTagName(ele, "description")); delegate.parseMetaElements(ele, bd); delegate.parseLookupOverrideSubElements(ele, bd.getMethodOverrides()); delegate.parseReplacedMethodSubElements(ele, bd.getMethodOverrides()); delegate.parseConstructorArgElements(ele, bd); delegate.parsePropertyElements(ele, bd); delegate.parseQualifierElements(ele, bd); } catch (NoClassDefFoundError err) { reader.error("Class that bean class [" + this.beanClass + "] depends on not found", ele, err); } catch (Throwable ex) { reader.error("Unexpected failure during bean definition parsing", ele, ex); } }
From source file:org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.java
/** * Parse the bean definition itself, without regard to name or aliases. May return * {@code null} if problems occurred during the parsing of the bean definition. *///from w ww . ja va 2s .c om @Nullable public AbstractBeanDefinition parseBeanDefinitionElement(Element ele, String beanName, @Nullable BeanDefinition containingBean) { this.parseState.push(new BeanEntry(beanName)); String className = null; if (ele.hasAttribute(CLASS_ATTRIBUTE)) { className = ele.getAttribute(CLASS_ATTRIBUTE).trim(); } String parent = null; if (ele.hasAttribute(PARENT_ATTRIBUTE)) { parent = ele.getAttribute(PARENT_ATTRIBUTE); } try { AbstractBeanDefinition bd = createBeanDefinition(className, parent); parseBeanDefinitionAttributes(ele, beanName, containingBean, bd); bd.setDescription(DomUtils.getChildElementValueByTagName(ele, DESCRIPTION_ELEMENT)); parseMetaElements(ele, bd); parseLookupOverrideSubElements(ele, bd.getMethodOverrides()); parseReplacedMethodSubElements(ele, bd.getMethodOverrides()); parseConstructorArgElements(ele, bd); parsePropertyElements(ele, bd); parseQualifierElements(ele, bd); bd.setResource(this.readerContext.getResource()); bd.setSource(extractSource(ele)); return bd; } catch (ClassNotFoundException ex) { error("Bean class [" + className + "] not found", ele, ex); } catch (NoClassDefFoundError err) { error("Class that bean class [" + className + "] depends on not found", ele, err); } catch (Throwable ex) { error("Unexpected failure during bean definition parsing", ele, ex); } finally { this.parseState.pop(); } return null; }
From source file:org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.java
/** * Parse the BeanDefinition itself, without regard to name or aliases. *//* w w w . j av a2 s . c om*/ protected BeanDefinition parseBeanDefinitionElement(Element ele, String beanName) throws BeanDefinitionStoreException { String className = null; if (ele.hasAttribute(CLASS_ATTRIBUTE)) { className = ele.getAttribute(CLASS_ATTRIBUTE).trim(); } String parent = null; if (ele.hasAttribute(PARENT_ATTRIBUTE)) { parent = ele.getAttribute(PARENT_ATTRIBUTE); } try { ConstructorArgumentValues cargs = parseConstructorArgElements(ele, beanName); MutablePropertyValues pvs = parsePropertyElements(ele, beanName); AbstractBeanDefinition bd = BeanDefinitionReaderUtils.createBeanDefinition(className, parent, cargs, pvs, getBeanDefinitionReader().getBeanClassLoader()); if (ele.hasAttribute(DEPENDS_ON_ATTRIBUTE)) { String dependsOn = ele.getAttribute(DEPENDS_ON_ATTRIBUTE); bd.setDependsOn(StringUtils.tokenizeToStringArray(dependsOn, BEAN_NAME_DELIMITERS)); } if (ele.hasAttribute(FACTORY_METHOD_ATTRIBUTE)) { bd.setFactoryMethodName(ele.getAttribute(FACTORY_METHOD_ATTRIBUTE)); } if (ele.hasAttribute(FACTORY_BEAN_ATTRIBUTE)) { bd.setFactoryBeanName(ele.getAttribute(FACTORY_BEAN_ATTRIBUTE)); } String dependencyCheck = ele.getAttribute(DEPENDENCY_CHECK_ATTRIBUTE); if (DEFAULT_VALUE.equals(dependencyCheck)) { dependencyCheck = getDefaultDependencyCheck(); } bd.setDependencyCheck(getDependencyCheck(dependencyCheck)); String autowire = ele.getAttribute(AUTOWIRE_ATTRIBUTE); if (DEFAULT_VALUE.equals(autowire)) { autowire = getDefaultAutowire(); } bd.setAutowireMode(getAutowireMode(autowire)); if (ele.hasAttribute(INIT_METHOD_ATTRIBUTE)) { String initMethodName = ele.getAttribute(INIT_METHOD_ATTRIBUTE); if (!"".equals(initMethodName)) { bd.setInitMethodName(initMethodName); } } else { if (getDefaultInitMethod() != null) { bd.setInitMethodName(getDefaultInitMethod()); bd.setEnforceInitMethod(false); } } if (ele.hasAttribute(DESTROY_METHOD_ATTRIBUTE)) { String destroyMethodName = ele.getAttribute(DESTROY_METHOD_ATTRIBUTE); if (!"".equals(destroyMethodName)) { bd.setDestroyMethodName(destroyMethodName); } } else { if (getDefaultDestroyMethod() != null) { bd.setDestroyMethodName(getDefaultDestroyMethod()); bd.setEnforceDestroyMethod(false); } } parseLookupOverrideSubElements(ele, beanName, bd.getMethodOverrides()); parseReplacedMethodSubElements(ele, beanName, bd.getMethodOverrides()); bd.setResourceDescription(getResource().getDescription()); if (ele.hasAttribute(ABSTRACT_ATTRIBUTE)) { bd.setAbstract(TRUE_VALUE.equals(ele.getAttribute(ABSTRACT_ATTRIBUTE))); } if (ele.hasAttribute(SINGLETON_ATTRIBUTE)) { bd.setSingleton(TRUE_VALUE.equals(ele.getAttribute(SINGLETON_ATTRIBUTE))); } String lazyInit = ele.getAttribute(LAZY_INIT_ATTRIBUTE); if (DEFAULT_VALUE.equals(lazyInit) && bd.isSingleton()) { // Just apply default to singletons, as lazy-init has no meaning for prototypes. lazyInit = getDefaultLazyInit(); } bd.setLazyInit(TRUE_VALUE.equals(lazyInit)); return bd; } catch (BeanDefinitionStoreException ex) { throw ex; } catch (ClassNotFoundException ex) { throw new BeanDefinitionStoreException(getResource(), beanName, "Bean class [" + className + "] not found", ex); } catch (NoClassDefFoundError err) { throw new BeanDefinitionStoreException(getResource(), beanName, "Class that bean class [" + className + "] depends on not found", err); } catch (Throwable ex) { throw new BeanDefinitionStoreException(getResource(), beanName, "Unexpected failure during bean definition parsing", ex); } }