spring中的parent属性我看别人说是继承关系,但我不清楚它是怎么继承的,
比如在写service时候每个service要加入事务管理然后加入parent属性,
但service并没有明显的继承proxy呀,请问是怎么继承的??使用的是什么技术?
如果我的service继承了某个类 如下面代码所示
Test bean = (Test)new ResourceService(); //ResourceService继承Test
Test bean = (Test)a.getBean("resourceService");//这个是经过spring IOC得到的配置文件如下所示
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
value="classpath:hibernate.cfg.xml">
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="basicTxProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="edit*">PROPAGATION_REQUIRED</prop>
<prop key="del*">PROPAGATION_REQUIRED</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="query*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="disPlay*">PROPAGATION_REQUIRES_NEW</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="steelBasicDaoImpl" class="com.steel.hibernate.dao.impl.SteelBasicDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="resourceService" parent="basicTxProxy">
<property name="target">
<bean class="com.steel.resource.service.ResourceService">
<property name="steelBasicDaoImpl" ref="steelBasicDaoImpl" />
<property name="userService" ref="userService" />
</bean>
</property>
</bean>
结果打印一个语句 System.out.println(bean.getClass().getSuperclass());
new出来的显示正确,是Test,但从spring拿到的却显示转型异常,
百思不得其解,望大家能解惑