List of usage examples for org.springframework.beans.factory.xml BeanDefinitionParserDelegate DESCRIPTION_ELEMENT
String DESCRIPTION_ELEMENT
To view the source code for org.springframework.beans.factory.xml BeanDefinitionParserDelegate DESCRIPTION_ELEMENT.
Click Source Link
From source file:org.eclipse.gemini.blueprint.blueprint.config.internal.BlueprintParser.java
/** * Parse the bean definition itself, without regard to name or aliases. May return <code>null</code> if problems * occurred during the parse of the bean definition. *//*from w w w . ja va2 s . c o m*/ private AbstractBeanDefinition parseBeanDefinitionElement(Element ele, String beanName, BeanDefinition containingBean) { this.parseState.push(new BeanEntry(beanName)); String className = null; if (ele.hasAttribute(BeanDefinitionParserDelegate.CLASS_ATTRIBUTE)) { className = ele.getAttribute(BeanDefinitionParserDelegate.CLASS_ATTRIBUTE).trim(); } try { AbstractBeanDefinition beanDefinition = BeanDefinitionReaderUtils.createBeanDefinition(null, className, parserContext.getReaderContext().getBeanClassLoader()); // some early validation String activation = ele.getAttribute(LAZY_INIT_ATTR); String scope = ele.getAttribute(BeanDefinitionParserDelegate.SCOPE_ATTRIBUTE); if (EAGER_INIT_VALUE.equals(activation) && BeanDefinition.SCOPE_PROTOTYPE.equals(scope)) { error("Prototype beans cannot be eagerly activated", ele); } // add marker to indicate that the scope was present if (StringUtils.hasText(scope)) { beanDefinition.setAttribute(DECLARED_SCOPE, Boolean.TRUE); } // parse attributes parseAttributes(ele, beanName, beanDefinition); // inner beans get a predefined scope in RFC 124 if (containingBean != null) { beanDefinition.setLazyInit(true); beanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE); } // parse description beanDefinition.setDescription( DomUtils.getChildElementValueByTagName(ele, BeanDefinitionParserDelegate.DESCRIPTION_ELEMENT)); parseConstructorArgElements(ele, beanDefinition); parsePropertyElements(ele, beanDefinition); beanDefinition.setResource(parserContext.getReaderContext().getResource()); beanDefinition.setSource(extractSource(ele)); return beanDefinition; } 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.eclipse.gemini.blueprint.blueprint.config.internal.BlueprintParser.java
private Object parsePropertyValue(Element ele, BeanDefinition bd, String propertyName) { String elementName = (propertyName != null) ? "<property> element for property '" + propertyName + "'" : "<constructor-arg> element"; // Should only have one child element: ref, value, list, etc. NodeList nl = ele.getChildNodes(); Element subElement = null;//from w ww.j a v a2 s .c om for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && !DomUtils.nodeNameEquals(node, BeanDefinitionParserDelegate.DESCRIPTION_ELEMENT)) { // Child element is what we're looking for. if (subElement != null) { error(elementName + " must not contain more than one sub-element", ele); } else { subElement = (Element) node; } } } boolean hasRefAttribute = ele.hasAttribute(BeanDefinitionParserDelegate.REF_ATTRIBUTE); boolean hasValueAttribute = ele.hasAttribute(BeanDefinitionParserDelegate.VALUE_ATTRIBUTE); if ((hasRefAttribute && hasValueAttribute) || ((hasRefAttribute || hasValueAttribute) && subElement != null)) { error(elementName + " is only allowed to contain either 'ref' attribute OR 'value' attribute OR sub-element", ele); } if (hasRefAttribute) { String refName = ele.getAttribute(BeanDefinitionParserDelegate.REF_ATTRIBUTE); if (!StringUtils.hasText(refName)) { error(elementName + " contains empty 'ref' attribute", ele); } RuntimeBeanReference ref = new RuntimeBeanReference(refName); ref.setSource(parserContext.extractSource(ele)); return ref; } else if (hasValueAttribute) { TypedStringValue valueHolder = new TypedStringValue( ele.getAttribute(BeanDefinitionParserDelegate.VALUE_ATTRIBUTE)); valueHolder.setSource(parserContext.extractSource(ele)); return valueHolder; } else if (subElement != null) { return parsePropertySubElement(subElement, bd, null); } else { // Neither child element nor "ref" or "value" attribute found. error(elementName + " must specify a ref or value", ele); return null; } }
From source file:org.eclipse.gemini.blueprint.blueprint.config.internal.BlueprintParser.java
protected void parseCollectionElements(NodeList elementNodes, Collection<Object> target, BeanDefinition bd, String defaultElementType) { for (int i = 0; i < elementNodes.getLength(); i++) { Node node = elementNodes.item(i); if (node instanceof Element && !DomUtils.nodeNameEquals(node, BeanDefinitionParserDelegate.DESCRIPTION_ELEMENT)) { target.add(parsePropertySubElement((Element) node, bd, defaultElementType)); }//from w ww. j a va 2 s . c om } }