对于嵌入式的beans标签,想信大家很少使用过,或者接触过,起码,我本人就没用过. 它非常类似于Import标签所提供的功能;
使用如下:
对这个beans没什么太多可讲,解析代码如下:
1 protected void doRegisterBeanDefinitions(Element root) { 2 String profileSpec = root.getAttribute(PROFILE_ATTRIBUTE); 3 // 处理profile属性 4 /* 5 * this is header... 6 * 7 *10 * 11 * web.xml12 * 13 * 14 * 15 * 20 */21 if (StringUtils.hasText(profileSpec)) {22 Assert.state(this.environment != null,23 "Environment must be set for evaluating profiles");24 String[] specifiedProfiles = StringUtils.tokenizeToStringArray(profileSpec,25 BeanDefinitionParserDelegate.MULTI_VALUE_ATTRIBUTE_DELIMITERS);26 if (!this.environment.acceptsProfiles(specifiedProfiles)) {27 return;28 }29 }30 31 // Any nestedSpring.profiles.active 16 * 17 *dev 18 * 19 *elements will cause recursion in this method. In32 // order to propagate and preserve default-* attributes correctly,33 // keep track of the current (parent) delegate, which may be null. Create34 // the new (child) delegate with a reference to the parent for fallback purposes,35 // then ultimately reset this.delegate back to its original (parent) reference.36 // this behavior emulates a stack of delegates without actually necessitating one.37 // 专门处理解析38 BeanDefinitionParserDelegate parent = this.delegate;39 this.delegate = createDelegate(this.readerContext, root, parent);40 // 解析前留给子类实现41 preProcessXml(root);42 43 parseBeanDefinitions(root, this.delegate);44 // 解析后留给子类实现45 postProcessXml(root);46 47 this.delegate = parent;48 }