成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

模擬spring加載過(guò)程-創(chuàng)新互聯(lián)

package bean;

創(chuàng)新互聯(lián)自2013年起,先為景谷等服務(wù)建站,景谷等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為景谷企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問(wèn)題。

import org.springframework.beans.factory.annotation.Autowired;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class SimpleSpringParse implements MyApplicationAware {

@Autowired
private Person person;

private Factory factory;

private static ListbeanNameList = new ArrayList();

private static ListannotationList = new ArrayList();

public static Object createInstance(String name) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    ClassaClass = Class.forName(name);
    Field[] fields = aClass.getDeclaredFields();
    for(Field f:fields){
        if(f.getAnnotation(Autowired.class) != null){
            beanNameList.add(f.getType().getName());
            annotationList.add(f.getName());
            System.out.println("has annotationsByType Autowired ");
        }else{
            System.out.println("not has annotationsByType Autowired ");
        }
    }
    return aClass.newInstance();
}

public static void populate(Object instance) throws IllegalAccessException {
    Field field = null;
    try {
        field = instance.getClass().getDeclaredField(annotationList.get(0));
    } catch (NoSuchFieldException ex) {
        // 子類不存在該變量那么嘗試去父類獲取變量

// field=object.getClass().getSuperclass().getDeclaredField(“name”);
}
field.setAccessible(true);
Person p = new Person();
p.setName(“xxxxx”);
field.set(instance, p);
}

public static void initializeBean(Object instance){
    if(instance instanceof MyApplicationAware){
        ((MyApplicationAware) instance).setFactory(new DefaultFactory());
    }
}


public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    SimpleSpringParse instance = (SimpleSpringParse)createInstance("bean.SimpleSpringParse");
    populate(instance);
    initializeBean(instance);
    System.out.println(instance.getPerson().getName());
    System.out.println(beanNameList.get(0));
    System.out.println(annotationList.get(0));

}

public Person getPerson() {
    return person;
}

public void setPerson(Person person) {
    this.person = person;
}

@Override
public void setFactory(Factory factory) {
    this.factory = factory;
}

}

你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購(gòu),新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧

分享文章:模擬spring加載過(guò)程-創(chuàng)新互聯(lián)
轉(zhuǎn)載注明:http://jinyejixie.com/article12/hiedc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動(dòng)態(tài)網(wǎng)站外貿(mào)網(wǎng)站建設(shè)、App設(shè)計(jì)、標(biāo)簽優(yōu)化移動(dòng)網(wǎng)站建設(shè)、軟件開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司
泾川县| 武陟县| 漳浦县| 思南县| 唐山市| 岗巴县| 祁阳县| 温泉县| 黄龙县| 天津市| 廊坊市| 霍林郭勒市| 稻城县| 苏州市| 舟山市| 肥东县| 和平县| 定襄县| 页游| 成安县| 申扎县| 任丘市| 广昌县| 随州市| 大荔县| 庐江县| 互助| 淳安县| 黄大仙区| 扶沟县| 赤壁市| 和平县| 嵩明县| 永顺县| 湘乡市| 桂阳县| 泰来县| 突泉县| 武城县| 洪湖市| 游戏|