also convert these values to any primitive or primitive wrapper class. Listing 4-35 shows a simple bean
that has a variety of properties exposed for injection.
Listing 4-35. Injecting Simple Values (XML)
package com.apress.prospring3.ch4.xml;
import org.springframework.context.support.GenericXmlApplicationContext;
public class InjectSimple {
private String name;
private int age;
private float height;
private boolean programmer;
private Long ageInSeconds;
public static void main(String[] args) {
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
ctx.load("classpath:app-context-xml.xml");
ctx.refresh();
InjectSimple simple = (InjectSimple)ctx.getBean("injectSimple");
System.out.println(simple);
}
public void setAgeInSeconds(Long ageInSeconds) {
this.ageInSeconds = ageInSeconds;
}
public void setProgrammer(boolean programmer) {
this.programmer = programmer;
}
public void setAge(int age) {
this.age = age;
}
public void setHeight(float height) {
this.height = height;
}
public void setName(String name) {
this.name = name;
}
public String toString() {
return
"Name :" + name + "\n"
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home