Skip to content

Please undeprecate XmlBeanFactory [SPR-8404] #13051

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

Closed
spring-projects-issues opened this issue Jun 6, 2011 · 5 comments
Closed

Please undeprecate XmlBeanFactory [SPR-8404] #13051

spring-projects-issues opened this issue Jun 6, 2011 · 5 comments
Assignees
Labels
status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jun 6, 2011

Dave Syer opened SPR-8404 and commented

Please undeprecate XmlBeanFactory. It's only a few lines of code, so not a big deal to keep it I would have thought. It's really useful for testing, and those few lines have to be duplicated, plus I never remember how to do it.


Affects: 3.1 M1

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

Chris Beams commented

Hi Dave,

The combination to replace XmlBeanFactory you're probably referring to is:

BeanDefinitionRegistry bdr = DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bdr);
reader.loadBeanDefinitionReader(new ClassPathResource("foo.xml"));

This is certainly more verbose than:

XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("foo.xml"));

However, the following is more concise than either:

ApplicationContext ctx = new GenericXmlApplicationContext("foo.xml");

So the first question is, why not use GXAC in your testing scenarios?

XmlBeanFactory was deprecated because it existed before the ApplicationContext abstraction did, and the ApplicationContext hierarchy was specifically designed to accommodate concrete types aligned with different bean definition types (GenericXmlApplicationContext, AnnotationConfigApplicationContext, etc), while the BeanFactory hierarchy represents a more fundamental abstraction not designed for such variability. XmlBeanFactory is the one historical exception to that rule, and the deprecation reflects that fact. Given that GenericXmlApplicationContext provides equal if not greater convenience (given the String- and Resource-based constructors), undeprecating is unlikely at this point.

@spring-projects-issues
Copy link
Collaborator Author

Chris Beams commented

Resolving "won't fix" after 1+ month of waiting for feedback.

@spring-projects-issues
Copy link
Collaborator Author

Dave Syer commented

Sorry, I didn't get any prompts for feedback, or I would have responded. I'm sure you are right that the little dance with BDR and XBDR is the equivalent of using XBF directly, but was I, as a regular user, supposed to just know how to do that?

GXAC is not the same at all because ApplicationContext has several important features and contractual obligations that BeanFactory does not. In particular it forces all beans to be instantiated and adds additional "services" that are really useful at runtime in an application, but you quite often want to avoid in a test case (of XML namespace features in particular).

@spring-projects-issues
Copy link
Collaborator Author

Chris Beams commented

http://www.youtube.com/watch?v=7qnd-hdmgfk (but maybe Juergen can)

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

At this point, we'd rather drop XmlBeanFactory completely than undeprecate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants