tags:

views:

37

answers:

1

I need to read the bean definitions from a Spring context file, practically reading what is inside the XML. I do not want to instantiate beans, I just want to read the content of the file.

While I can write a parser to do so, I imagine Spring already does this. What classes does it use (I am running around the XmlBeanDefinitionReader related classes but I am not sure how to use them)?

How can I load the XML into bean definitions using Spring's classes?

I am using Spring 2.0.

Thank you!

+1  A: 

If you create an XmlBeanFactory you can then use the methods in the ListableBeanFactory interface to inspect available beans, and get a BeanDefintion object as necessary using getBeanDefinition(beanName)

Jon Freedman
Since this is a BeanFactory implementation, with getBean(...) methods, won't it trigger an instantiation of the beans?
user777
Not until you call `getBean` or `insantiateBean` or `preInsantiateSingletons` etc.
Jon Freedman