Lets take I have a class as shown below :
public interface UserDAO {
public List<User> list();
}
public class UserDAOImpl implements UserDAO {
private DataSource dataSource;
public UserDAOImpl(DataSource dataSource) {
this.dataSource = dataSource;
}
Let's assume JNDI configuration is done correctly in tomcat.
Now for spring bean mapping in many sites I found the below configuration:
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/UsersDB"/>
</bean>
<bean id="userDao" class="net.codejava.spring.dao.UserDAOImpl">
<constructor-arg>
<ref bean="dataSource" />
</constructor-arg>
</bean>
Here is what my question , UserDAOImpl class is looking for DataSource object but we are injecting JndiObjectFactoryBean object[Which is not a subclass of DataSource] , since we are not even mentioning the factory method how or where the conversion is happening ?