| 在前面已經(jīng)簡要的介紹了Spring的管理方式,下面對其做進一步的解釋。在Spring中,有三種方式對Bean進行管理,分別是BeanWrapper,BeanFactory,ApplicationContext.  下面分別對其做解釋: 1 BeanWrapper 先看一下代碼: 
 package com.jnotnull;
public class HelloWorld {
public String message = null;
HelloWorld(){
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
在這里我們加入了一個無參數(shù)構(gòu)造函數(shù):因為 org.springframework.beans包遵循Sun發(fā)布的JavaBeans標(biāo)準(zhǔn)。 一個JavaBean是一個簡單的包含無參數(shù)構(gòu)造函數(shù)的類,并且包含seter和getter屬性方法。 下面看一下調(diào)用的測試類 
 package com.jnotnull;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
public class Test {
public static void main(String []args) throws Exception{
Object object =  Class.forName("com.jnotnull.HelloWorld");
BeanWrapper bw = new BeanWrapperImpl(object);
bw.setPropertyValue("message","HelloWorld");
System.out.println(bw.getPropertyValue("message"));
}
}
由此我們可以看出,在BeanWrapper是不需要配置文件的。 | 
|  |