|
From: Pavel T. <Pa...@ts...> - 2004-07-21 12:10:30
|
Hi, This may have been discussed before, I did a Google search but nothing came up. I was reading something on spring-user yesterday when it struck me, why do we need to describe each and every property of each and every bean when we have inheritance. Sure, this may not always be the best choice, but it would make life easier in many cases and I would think it's relatively easy to implement. Possible scenario: A hierarchy of DAO objects, all extending a base DAO, which in turn extends, say, HibernateDaoSupport. Then instead of having in applicationContext.xml: <bean id="xyzDAO" class="com.mycompany.product.dao.hibernate.XyzDAO"> <property name="sessionFactory"> <ref local="mySessionFactory"> </property> <property name="somethingElse"> <value>xyz</value> </property> </bean> for each and every DAO, you could just write something like: <bean superclass="com.mycompany.product.dao.hibernate.GenericDao"> <property name="sessionFactory"> <ref local="mySessionFactory"> </property> </bean> And then you could still have specific properties for those beans that require it, like: <bean id="xyzDAO" class="com.mycompany.product.dao.hibernate.XyzDAO"> <property name="somethingElse"> <value>xyz</value> </property> </bean> Yay or nay? Seems to me it's a better way of dealing with generic properties across the board and would make refactoring/plugging new implementations easier? One could even take this a step further and implement property setting based on regex on the bean ids or classnames much like the pointcut definitions in the AOP module. Best regards, Pavel -- Pavel Tcholakov Technology Systems Integration (Pty) Ltd. Email: pa...@ts... Tel. +27 11 7921094 |