Skip to content

Commit

Permalink
Document all remaining public methods on BeanDefinitionParserDelegate
Browse files Browse the repository at this point in the history
Closes gh-23349
  • Loading branch information
jhoeller committed Aug 1, 2019
1 parent 379e919 commit f99b2f1
Showing 1 changed file with 64 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,9 @@ protected AbstractBeanDefinition createBeanDefinition(String className, String p
parentName, className, this.readerContext.getBeanClassLoader());
}

/**
* Parse the meta elements underneath the given element, if any.
*/
public void parseMetaElements(Element ele, BeanMetadataAttributeAccessor attributeAccessor) {
NodeList nl = ele.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
Expand All @@ -688,23 +691,27 @@ public void parseMetaElements(Element ele, BeanMetadataAttributeAccessor attribu
}
}

/**
* Parse the given autowire attribute value into
* {@link AbstractBeanDefinition} autowire constants.
*/
@SuppressWarnings("deprecation")
public int getAutowireMode(String attValue) {
String att = attValue;
if (isDefaultValue(att)) {
att = this.defaults.getAutowire();
public int getAutowireMode(String attrValue) {
String attr = attrValue;
if (isDefaultValue(attr)) {
attr = this.defaults.getAutowire();
}
int autowire = AbstractBeanDefinition.AUTOWIRE_NO;
if (AUTOWIRE_BY_NAME_VALUE.equals(att)) {
if (AUTOWIRE_BY_NAME_VALUE.equals(attr)) {
autowire = AbstractBeanDefinition.AUTOWIRE_BY_NAME;
}
else if (AUTOWIRE_BY_TYPE_VALUE.equals(att)) {
else if (AUTOWIRE_BY_TYPE_VALUE.equals(attr)) {
autowire = AbstractBeanDefinition.AUTOWIRE_BY_TYPE;
}
else if (AUTOWIRE_CONSTRUCTOR_VALUE.equals(att)) {
else if (AUTOWIRE_CONSTRUCTOR_VALUE.equals(attr)) {
autowire = AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR;
}
else if (AUTOWIRE_AUTODETECT_VALUE.equals(att)) {
else if (AUTOWIRE_AUTODETECT_VALUE.equals(attr)) {
autowire = AbstractBeanDefinition.AUTOWIRE_AUTODETECT;
}
// Else leave default value.
Expand Down Expand Up @@ -1001,6 +1008,12 @@ else if (subElement != null) {
}
}

/**
* Parse a value, ref or collection sub-element of a property or
* constructor-arg element.
* @param ele subelement of property element; we don't know which yet
* @param bd the current bean definition (if any)
*/
public Object parsePropertySubElement(Element ele, BeanDefinition bd) {
return parsePropertySubElement(ele, bd, null);
}
Expand All @@ -1009,6 +1022,7 @@ public Object parsePropertySubElement(Element ele, BeanDefinition bd) {
* Parse a value, ref or collection sub-element of a property or
* constructor-arg element.
* @param ele subelement of property element; we don't know which yet
* @param bd the current bean definition (if any)
* @param defaultValueType the default type (class name) for any
* {@code <value>} tag that might be created
*/
Expand Down Expand Up @@ -1396,10 +1410,21 @@ public boolean parseMergeAttribute(Element collectionElement) {
return TRUE_VALUE.equals(value);
}

/**
* Parse a custom element (outside of the default namespace).
* @param ele the element to parse
* @return the resulting bean definition
*/
public BeanDefinition parseCustomElement(Element ele) {
return parseCustomElement(ele, null);
}

/**
* Parse a custom element (outside of the default namespace).
* @param ele the element to parse
* @param containingBd the containing bean definition (if any)
* @return the resulting bean definition
*/
public BeanDefinition parseCustomElement(Element ele, BeanDefinition containingBd) {
String namespaceUri = getNamespaceURI(ele);
NamespaceHandler handler = this.readerContext.getNamespaceHandlerResolver().resolve(namespaceUri);
Expand All @@ -1410,14 +1435,27 @@ public BeanDefinition parseCustomElement(Element ele, BeanDefinition containingB
return handler.parse(ele, new ParserContext(this.readerContext, this, containingBd));
}

public BeanDefinitionHolder decorateBeanDefinitionIfRequired(Element ele, BeanDefinitionHolder definitionHolder) {
return decorateBeanDefinitionIfRequired(ele, definitionHolder, null);
/**
* Decorate the given bean definition through a namespace handler, if applicable.
* @param ele the current element
* @param originalDef the current bean definition
* @return the decorated bean definition
*/
public BeanDefinitionHolder decorateBeanDefinitionIfRequired(Element ele, BeanDefinitionHolder originalDef) {
return decorateBeanDefinitionIfRequired(ele, originalDef, null);
}

/**
* Decorate the given bean definition through a namespace handler, if applicable.
* @param ele the current element
* @param originalDef the current bean definition
* @param containingBd the containing bean definition (if any)
* @return the decorated bean definition
*/
public BeanDefinitionHolder decorateBeanDefinitionIfRequired(
Element ele, BeanDefinitionHolder definitionHolder, BeanDefinition containingBd) {
Element ele, BeanDefinitionHolder originalDef, BeanDefinition containingBd) {

BeanDefinitionHolder finalDefinition = definitionHolder;
BeanDefinitionHolder finalDefinition = originalDef;

// Decorate based on custom attributes first.
NamedNodeMap attributes = ele.getAttributes();
Expand All @@ -1437,6 +1475,14 @@ public BeanDefinitionHolder decorateBeanDefinitionIfRequired(
return finalDefinition;
}

/**
* Decorate the given bean definition through a namespace handler,
* if applicable.
* @param node the current child node
* @param originalDef the current bean definition
* @param containingBd the containing bean definition (if any)
* @return the decorated bean definition
*/
public BeanDefinitionHolder decorateIfRequired(
Node node, BeanDefinitionHolder originalDef, BeanDefinition containingBd) {

Expand Down Expand Up @@ -1511,10 +1557,16 @@ public boolean nodeNameEquals(Node node, String desiredName) {
return desiredName.equals(node.getNodeName()) || desiredName.equals(getLocalName(node));
}

/**
* Determine whether the given URI indicates the default namespace.
*/
public boolean isDefaultNamespace(String namespaceUri) {
return (!StringUtils.hasLength(namespaceUri) || BEANS_NAMESPACE_URI.equals(namespaceUri));
}

/**
* Determine whether the given node indicates the default namespace.
*/
public boolean isDefaultNamespace(Node node) {
return isDefaultNamespace(getNamespaceURI(node));
}
Expand Down

0 comments on commit f99b2f1

Please sign in to comment.