When I need to use Property Place Holder, I just define a bean in spring_config.xml as follows, without doing anything to this bean in java code, how could the spring know that?
<bean id="configBean" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="spring_test/spring.properties"></bean>
another confused part is alike: I define two beans in spring_config.xml, namely SqlSessionFactoryBean and MapperFactoryBean, how could spring implement that the MapperFactoryBean acts just like a proxy to my DAO without I having to write any java code?
Is there any article on the mechanism of xml parsing or something related? Thanks a lot!
You need to know about Java Reflection. Java Reflection makes it possible to inspect classes, interfaces, fields and methods at runtime, without knowing the names of the classes, methods etc. at compile time. It is also possible to instantiate new objects, invoke methods and get/set field values using reflection. below is simple example.
The Spring container will find "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" class by "forName" method and instantiate "PropertyPlaceholderConfigurer" class.