使用Spring来完成类的实例化
<bean id="SuperAction" class="com.SuperAction" scope="prototype">
<property name="sup1" ref="sup1"/>
<property name="sup2" ref="sup2"/>
</bean><bean id="SubAction1" class="com.SubAction1" scope="prototype">
<property name="sup1" ref="sup1"/>
<property name="sup2" ref="sup2"/>
</bean><bean id="SubAction2" class="com.SubAction2" scope="prototype">
<property name="sup1" ref="sup1"/>
<property name="sup2" ref="sup2"/>
</bean>
类SubAction1和类SubAction2都继承类SuperAction,如果有多个类都继承SupAction
那么每个子类都需要配置
<property name="sup1" ref="sup1"/>
<property name="sup2" ref="sup2"/>
有什么方法可以不用在每个子类中都进行配置
<bean id="SuperAction" class="com.SuperAction" scope="prototype">
<property name="sup1" ref="sup1"/>
<property name="sup2" ref="sup2"/>
</bean><bean id="SubAction1" class="com.SubAction1" scope="prototype">
<property name="sup1" ref="sup1"/>
<property name="sup2" ref="sup2"/>
</bean><bean id="SubAction2" class="com.SubAction2" scope="prototype">
<property name="sup1" ref="sup1"/>
<property name="sup2" ref="sup2"/>
</bean>
类SubAction1和类SubAction2都继承类SuperAction,如果有多个类都继承SupAction
那么每个子类都需要配置
<property name="sup1" ref="sup1"/>
<property name="sup2" ref="sup2"/>
有什么方法可以不用在每个子类中都进行配置
解决方案 »
- flex4的问题,求兄弟姐妹们帮帮忙
- 在Hibernate.cfg.xml文件中配置具有实例名的数据库,如何写connection.url
- 求一个关于application session pagecontext的具体分析
- 怎么实现在Cookie中保留登录信息N天?
- Java 点击一个压缩文件,页面展示其压缩文件内的文件列表怎么实现?
- 对JSP, STRUCTS, JSF, SPRING, AOP, IOC的讨论...
- Axis+tomcat配置失败,高手请看看
- 如何让JDOM忽略DTD声明
- 在EJB中客户端是否可以通过本地接口来调用望高手指点
- Java web使用JDBC连接MySQL进行插入操作时中文显示乱码
- 关于java学习
- jQuery或$ 不能识别问题
<bean name="LogTestService" class="com.study.spring.aop.service.impl.LogTestServiceImpl"></bean>
<bean name="superObject" class="com.study.spring.aop.SuperObject">
<property name="logTestService" ref="LogTestService"></property>
</bean>
<bean name="subObject" class="com.study.spring.aop.SubObject" parent="superObject"></bean>
public static void main(String[] args) throws Exception {
ApplicationContext act = new ClassPathXmlApplicationContext("applicationContext.xml");
SubObject sub = (SubObject)act.getBean("subObject");
System.out.println(sub.getLogTestService().say(1));
}//可以得到service