&#64;Nullable publicBeanDefinitionHolderparseBeanDefinitionElement(Element ele,&#64;NullableBeanDefinition containingBean){// 获取 id 属性String id &#61; ele.getAttribute(ID_ATTRIBUTE);// 获取 name 属性String nameAttr &#61; ele.getAttribute(NAME_ATTRIBUTE);List<String> aliases &#61;newArrayList<>();if(StringUtils.hasLength(nameAttr)){// 解析 name 属性中的值String[] nameArr &#61;StringUtils.tokenizeToStringArray(nameAttr, MULTI_VALUE_ATTRIBUTE_DELIMITERS);aliases.addAll(Arrays.asList(nameArr));}String beanName &#61; id;if(!StringUtils.hasText(beanName)&&!aliases.isEmpty()){beanName &#61; aliases.remove(0);if(logger.isTraceEnabled()){logger.trace("No XML &#39;id&#39; specified - using &#39;"&#43; beanName &#43;"&#39; as bean name and "&#43; aliases &#43;" as aliases");}}if(containingBean &#61;&#61;null){// 检查 bean 名称和 bean 别名是否唯一checkNameUniqueness(beanName, aliases, ele);}// 重点方法// 解析 bean 元素到 BeanDefinition 中AbstractBeanDefinition beanDefinition &#61;parseBeanDefinitionElement(ele, beanName, containingBean);if(beanDefinition !&#61;null){// 如果 beanName 为空&#xff0c;通过 beanDefinition 信息生成一个 beanNameif(!StringUtils.hasText(beanName)){try{if(containingBean !&#61;null){beanName &#61;BeanDefinitionReaderUtils.generateBeanName(beanDefinition,this.readerContext.getRegistry(),true);}else{beanName &#61;this.readerContext.generateBeanName(beanDefinition);// Register an alias for the plain bean class name, if still possible,// if the generator returned the class name plus a suffix.// This is expected for Spring 1.2/2.0 backwards compatibility.String beanClassName &#61; beanDefinition.getBeanClassName();if(beanClassName !&#61;null&&beanName.startsWith(beanClassName)&& beanName.length()> beanClassName.length()&&!this.readerContext.getRegistry().isBeanNameInUse(beanClassName)){aliases.add(beanClassName);}}if(logger.isTraceEnabled()){logger.trace("Neither XML &#39;id&#39; nor &#39;name&#39; specified - "&#43;"using generated bean name ["&#43; beanName &#43;"]");}}catch(Exception ex){error(ex.getMessage(), ele);returnnull;}}String[] aliasesArray &#61;StringUtils.toStringArray(aliases);returnnewBeanDefinitionHolder(beanDefinition, beanName, aliasesArray);}returnnull; }
Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ...
[详细]