org.springframework.beans.factory.xml

Class AbstractBeanDefinitionParser

  • java.lang.Object
    • org.springframework.beans.factory.xml.AbstractBeanDefinitionParser
    • Field Detail

      • ID_ATTRIBUTE

        public static final java.lang.String ID_ATTRIBUTE
        Constant for the "id" attribute.
        See Also:
        Constant Field Values
      • NAME_ATTRIBUTE

        public static final java.lang.String NAME_ATTRIBUTE
        Constant for the "name" attribute.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractBeanDefinitionParser

        public AbstractBeanDefinitionParser()
    • Method Detail

      • resolveId

        protected java.lang.String resolveId(org.w3c.dom.Element element,
                                             AbstractBeanDefinition definition,
                                             ParserContext parserContext)
                                      throws BeanDefinitionStoreException
        Resolve the ID for the supplied BeanDefinition.

        When using generation, a name is generated automatically. Otherwise, the ID is extracted from the "id" attribute, potentially with a fallback to a generated id.

        Parameters:
        element - the element that the bean definition has been built from
        definition - the bean definition to be registered
        parserContext - the object encapsulating the current state of the parsing process; provides access to a BeanDefinitionRegistry
        Returns:
        the resolved id
        Throws:
        BeanDefinitionStoreException - if no unique name could be generated for the given bean definition
      • shouldGenerateId

        protected boolean shouldGenerateId()
        Should an ID be generated instead of read from the passed in Element?

        Disabled by default; subclasses can override this to enable ID generation. Note that this flag is about always generating an ID; the parser won't even check for an "id" attribute in this case.

        Returns:
        whether the parser should always generate an id
      • shouldGenerateIdAsFallback

        protected boolean shouldGenerateIdAsFallback()
        Should an ID be generated instead if the passed in Element does not specify an "id" attribute explicitly?

        Disabled by default; subclasses can override this to enable ID generation as fallback: The parser will first check for an "id" attribute in this case, only falling back to a generated ID if no value was specified.

        Returns:
        whether the parser should generate an id if no id was specified
      • shouldParseNameAsAliases

        protected boolean shouldParseNameAsAliases()
        Determine whether the element's "name" attribute should get parsed as bean definition aliases, i.e. alternative bean definition names.

        The default implementation returns true.

        Returns:
        whether the parser should evaluate the "name" attribute as aliases
        Since:
        4.1.5