
On Mon, May 25, 2009 at 11:24 AM, wesley kiriinya <kiriinya2000@yahoo.com> wrote:
Another solution:
You don't have to make the setters and getters private (i.e. setCustomerDao, getCustomer because the references they return are also private). Therefore the s/getters would be either protected or public allowing you to do the spring wiring as follows:
<bean id="customerServiceImpl" class="ke.co.x.x.CustomerServiceImpl"> <property name="customerDao" ref="customerDao"/> </bean>
You would think that is the logical way.... but with direct injection frameworks like Spring method encapsulation is ignored ... you can have a private setter method which is settable by an external object ! it uses the reflection api to call setter / getter methods irrespective of encapsulation rules