First, step:
1) Use the PropertyDescriptor class to get the property descriptor object
// the Name property of the PD reference student New PropertyDescriptor ("name", Student. Class);
2) set by the Getwritemethod () method +invoke () method
// equivalent to getting setname () Method m = pd.getwritemethod (); " Berrry ");
3) get through the Getreadmethod () method +invoke () method
// equivalent to getting getname ()m=null);
Second, through the beaninfo to traverse all the properties and to set
1) Get BeanInfo object by static method Getbeaninfo () method of Introspector class
// BeanInfo represents all property collection objects for the student object BeanInfo bi = introspector.getbeaninfo (Student. Class);
2) Get all property collections
// gets the collection of all attributes for the student object propertydescriptor[] pds = Bi.getpropertydescriptors ();
3) As above: through the Getwritemethod () and the Getreadmethod () + Invoke () method to do the corresponding operation.
Setting up JavaBean through introspection mechanism