public class Juggler implements Performer{
private int beanBags=3;
private Poem poem;
public Juggler(){
}
public Juggler(int beanBags,Poem poem){
this.beanBags = beanBags;
this.poem = poem;
}
public void perform() throws Exception{
System.out.println("Juggler..........."+beanBags+"............going");
System.out.println(poem.getId()+".............."+poem.getName());
}
}
public class Poem {
private String id;
private String name;
public Poem(String id,String name){
this.id = id;
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
测试类
public class Test {
public static void main(String[] args) throws Exception {
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
Juggler juggler = (Juggler) context.getBean("dudk");
juggler.perform();
}
}