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...
POINT I/O Wiring Base Assemblypdf,POINT I/O Wiring Base Assembly
• Upgrade wiring in your existing home room-by-room, system-by-system or wire the home you're building. • Learn wiring for the latest digital home technologies -- whole home audio, outdoor audio, ...
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...
Field Wiring and Noise Considerations for Analog Signals 模拟信号检测技术,微弱信号检测系统设计技术。
java开发ide源码关于接线 Wiring 是一种用于微控制器的开源编程框架。 Wiring 允许编写跨平台软件来控制连接到各种微控制器板上的设备,以创建各种创造性的编码、交互式对象、空间或物理体验。 该框架是为设计师和...
Cabling: The Complete Guide to Network Wiring, Third Edition David Barnett, David Groth, Jim McBee pages:733 英语
You're all in the business of software development.... If you are a person with a non-Java background, the book still benefits you since most of the integration wiring happens in XML configuration files.
UL 746F:2021-03 Polymeric Materials - Flexible Dielectric Film Materials for Use in Printed Wiring Boards and Flexible Materials Interconnect Constructions - 完整英文版(69页).pdf
SLC Wiring MAnual Notifier
Gecko wiring for CNC machine
S7 1200 系类PLC及扩展模块CAD接线图,整理出来方便大家画图方便
UL 758-Applicance Wiring Material 2022.rar
UL 758-Applicance Wiring Material 2022.pdf
Grounding, Audio Wiring, and Zero Loop AreaDesign