The method implements:
public class SingleBand implements Performer{
public SingleBand(){}
private Collection<Instrument> instruments;
public void setInstrument(Collection<Instrument> instruments){
this.instruments = instruments;
}
public void perform() {
// TODO Auto-generated method stub
for(Instrument instrument: instruments){
instrument.play();
}
}
}
the bean settings:
<bean id="band" class="com.performence.SingleBand">
<property name="instrument">
<list>
<ref bean='piano'/>
<ref bean='voilin'/>
<ref bean='piano'/>
<ref bean='voilin'/>
</list>
</property>
</bean>
<bean id="piano" class="com.performence.Piano"/>
<bean id="voilin" class="com.performence.Violin"/>
</beans>
test method :
public static void main(String args[]){
BeanFactory factory = new XmlBeanFactory(new FileSystemResource("bean.xml"));
Performer per = (Performer)factory.getBean("band");
per.perform();
}
}
output:
piano playing.......
violin playing.......
piano playing.......
violin playing.......
if change the <list> to <set> in the bean.xml
output :
piano playing.......
violin playing.......
分享到:
相关推荐
PART 1 CORE SPRING ...............................................................1 1 ■ Springing into action 3 2 ■ Basic bean wiring 31 3 ■ Advanced bean wiring 72 4 ■ Advising beans ...
Praise for the Third Edition of Spring in Action Preface Acknowledgments About this Book 1. Core Spring Chapter 1. Springing into action 1.1. Simplifying Java development 1.1.1. Unleashing the power ...
Separate the wiring of multiple modules from application logic Use Java annotations for configuration Master the scripting API built into the Java language Understand static versus dynamic ...
Wiring Your Web Application with Open Source Java 这个资源是转载。 文件中有 原版格式pdf,doc; 翻译格式doc。 花费了一下午的时间。 这个做毕业设计文献正好。呵呵 我就是拿这个做的毕业课题。
Separate the wiring of multiple modules from the application logic into an application using dependency injection Benchmark Java execution using Java 9 microbenchmarking See the workings of the Spring...
标题《Dependency injection in action》所指的知识点是依赖注入的实践应用,这一概念属于软件架构设计的基本原则。依赖注入是一种编程技术,通过这种方式,对象可以不直接创建或者查找其依赖的其他对象,而是在运行...
java开发ide源码关于接线 Wiring 是一种用于微控制器的开源编程框架。 Wiring 允许编写跨平台软件来控制连接到各种微控制器板上的设备,以创建各种创造性的编码、交互式对象、空间或物理体验。 该框架是为设计师和...
Separate the wiring of multiple modules from the application logic into an application using dependency injection Benchmark Java execution using Java 9 microbenchmarking See the workings of the Spring...
As the most current wiring book on the market, you can be confident that your projects will meet national writing codes. You’ll also spend more time on your project and less time scratching your head...
- **出版社**:SYBEX Inc. - **出版年份**:2004年 - **ISBN**:0-7821-4331-8 #### 书籍简介 《Cabling: The Complete Guide to Network Wiring, Third Edition》是一本全面介绍网络布线技术的专业书籍,由三位...
在Java开发中,XML到Java对象的数据转换是一个常见的需求,这有助于简化数据处理和提高代码可读性。 Smooks是一个开放源码的Java框架,专门用于处理各种数据格式,包括XML、CSV、EDI等,它提供了强大的数据转换能力...
标题中的“POINT I/O Wiring Base Assembly.pdf”表明这是一份关于Rockwell Automation公司的POINT I/O线缆基础组件装配说明文档。POINT I/O是一种工业用模块化输入输出系统,主要用于工业自动化领域。 描述中提到...
Ebac RM85 Wiring Diagram