System.out.println(element.attributeva lue("class"));
BeanInformation beanInformation = new BeanInformation();
beanInformation.setId(element.attributeva lue("id"));
beanInformation.setName(element.attributeva lue("class"));
XPath xref = element.createXPath("ns:property");//创建properties查询路径
xref.setNamespaceURIs(nsMap);//设置命名空间
List
for(Element property : propertys){
PropertyInformation propertyInformation = new PropertyInformation();
propertyInformation.setName(property.attributeva lue("name"));
propertyInformation.setRef(property.attributeva lue("ref"));
propertyInformation.setValue(property.attributeva lue("value"));
beanInformation.getPropertyInformation().add(propertyInformation);
}
beansInformation.add(beanInformation);
}
} catch(Exception e){
e.printStackTrace();
}
}
public void initBean(){
for(BeanInformation beanInformation: beansInformation){
if(beanInformation.getName()!=null && !"".equals(beanInformation.getName())){
//通过反射机制,根据名字初始化这个类
try {
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
/**
* 关于注入的实现
*/
private void injectObject() {
for(BeanInformation beanInformation : beansInformation){
Object bean = singleton.get(beanInformation.getId());
if(bean!=null){
try {
PropertyDescriptor[] ps = Introspector.getBeanInfo(bean.getClass()).getPropertyDescriptors();
for(PropertyInformation propertyInformation : beanInformation.getPropertyInformation()){
for(PropertyDescriptor properdesc : ps){
if(propertyInformation.getName().equals(properdesc.getName())){
Method setter = properdesc.getWriteMethod();//获取属性的setter方法 ,private
if(setter!=null){
Object value = null;
if(propertyInformation.getRef()!=null && !"".equals(propertyInformation.getRef().trim())){
value = singleton.get(propertyInformation.getRef());
}else{
value = ConvertUtils.convert(propertyInformation.getValue(), properdesc.getPropertyType());
}
setter.setAccessible(true);