Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding DocumentDefaultsDefinitions retrieval from root element attributes [SPR-6010] #10678

Closed
spring-projects-issues opened this issue Aug 16, 2009 · 5 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Tuomas Kiviaho opened SPR-6010 and commented

Currently DocumentDefaultsDefinition initialization seeks always the given root element attributes for default values. Overriding of the behavior requires creation and initialization of the DocumentDefaultsDefinition which is lazily created at BeanDefinitionParserDelegate.initDefaults(Element) method. Manual creation is impossible without reflection because the field where the default are held is private.

I propose that this field is made protected and/or construction of the default implementation is made along field the field declaration to help out overriding of the initDefaults method.

protected DocumentDefaultsDefinition defaults = new DocumentDefaultsDefinition();

More radical change would be altering the behaviour is binding the initialization to happen only when delegate.isDefaultNamespace(Element root) is true but this might have impact on custom implementations already out there so I guess this is completely out of the question.


Affects: 2.5.6

Referenced from: commits a805819

@spring-projects-issues
Copy link
Collaborator Author

Tuomas Kiviaho commented

Reflection is also needed to pull out original values of several fields that only have setters available at XmlBeanDefinitionReader.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

I've introduced a new template method for this purpose:

protected void populateDefaults(DocumentDefaultsDefinition defaults, Element root)

which allows for convenient overriding, with no need to access the underlying field directly.

What exactly are you trying to obtain from XmlBeanDefinitionReader that's not publicly accessible?

Juergen

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Nov 9, 2009

Tuomas Kiviaho commented

Thanks, leaving BeanDefinitionParserDelegate.defaults as null would break methods like ParserContext.isDefaultLazyInit() and initializing it from root element it only plausable for default namespace.

I couldn't find the fix for verification purposes. I presume I has been done to https://fisheye.springsource.org/browse/spring-framework/trunk/org.springframework.beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java?r=HEAD but at the time of writing a method called 'populateDefaults' was missing. Normally Source tab contains direct links but last revision (2100) was from october and no #10678 tagged commits have been done so I guess this fix isn't in trunk.


Tuomas

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

This is finally committed. The defaults field gets initialized with an empty DocumentDefaultsDefinition instance now right on construction of the containing delegate object.

You don't need to actually use the root element for deriving the default values. The template method just provides access to the root element for consideration (e.g. in its default implementation).

Juergen

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Nov 11, 2009

Tuomas Kiviaho commented

I can see it now. It's what I anticipated and I'm very pleased with it.

I consider this case closed (even without proposed delegate.isDefaultNamespace check at populateDefaults)


Tuomas

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0 RC2 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants