You are using RuntimeBeanReference
correctly. The code you posted is basically what Spring generates when you have
<bean class="beanClassName">
<property name="dataSource" ref="dataSourceBeanName" />
</bean>
At run time, Spring will find the bean referenced by dataSourceBeanName
and inject it.
RuntimeBeanNameReference
, as far as I can tell (there are very few uses of it), is basically used to inject the bean name while validating that a bean with that name exists in the context.