中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

spring bean parse

發布時間:2020-04-07 20:00:06 來源:網絡 閱讀:406 作者:mingyongyao_cto 欄目:開發技術

BeanDefinitionParserDelegate

解析<bean id="" name=""  name中的內容可以用“,”,“:”,“  ”作為分隔符

如果id為空,就將name中的第一個值賦給id


Entry-->BeanEntry

public final class ParseState {

    /**
     * Tab character used when rendering the tree-style representation.
     */
    private static final char TAB = '\t';

    /**
     * Internal {@link Stack} storage.
     */
    private final Stack<Entry> state;


    /**
     * Create a new {@code ParseState} with an empty {@link Stack}.
     */
    public ParseState() {
        this.state = new Stack<Entry>();
    }

    /**
     * Create a new {@code ParseState} whose {@link Stack} is a {@link Object#clone clone}
     * of that of the passed in {@code ParseState}.
     */
    @SuppressWarnings("unchecked")
    private ParseState(ParseState other) {
        this.state = (Stack<Entry>) other.state.clone();
    }


    /**
     * Add a new {@link Entry} to the {@link Stack}.
     */
    public void push(Entry entry) {
        this.state.push(entry);
    }

    /**
     * Remove an {@link Entry} from the {@link Stack}.
     */
    public void pop() {
        this.state.pop();
    }

    /**
     * Return the {@link Entry} currently at the top of the {@link Stack} or
     * {@code null} if the {@link Stack} is empty.
     */
    public Entry peek() {
        return this.state.empty() ? null : this.state.peek();
    }

    /**
     * Create a new instance of {@link ParseState} which is an independent snapshot
     * of this instance.
     */
    public ParseState snapshot() {
        return new ParseState(this);
    }


    /**
     * Returns a tree-style representation of the current {@code ParseState}.
     */
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        for (int x = 0; x < this.state.size(); x++) {
            if (x > 0) {
                sb.append('\n');
                for (int y = 0; y < x; y++) {
                    sb.append(TAB);
                }
                sb.append("-> ");
            }
            sb.append(this.state.get(x));
        }
        return sb.toString();
    }


    /**
     * Marker interface for entries into the {@link ParseState}.
     */
    public interface Entry {

    }

}

 


public class BeanEntry implements ParseState.Entry {

    private String beanDefinitionName;


    /**
     * Creates a new instance of {@link BeanEntry} class.
     * @param beanDefinitionName the name of the associated bean definition
     */
    public BeanEntry(String beanDefinitionName) {
        this.beanDefinitionName = beanDefinitionName;
    }


    @Override
    public String toString() {
        return "Bean '" + this.beanDefinitionName + "'";
    }

}





BeanDefinition的實例:GenericBeanDefinition bd = new GenericBeanDefinition();

AbstractBeanDefinition-->BeanMetadataAttributeAccessor


public class BeanMetadataAttributeAccessor extends AttributeAccessorSupport implements BeanMetadataElement {

    private Object source;

    ........

}

public abstract class AttributeAccessorSupport implements AttributeAccessor, Serializable {

    /** Map with String keys and Object values */
    private final Map<String, Object> attributes = new LinkedHashMap<String, Object>(0);

....

}



BeanMetadataAttribute attribute :

public class BeanMetadataAttribute implements BeanMetadataElement {

    private final String name;

    private final Object value;

    private Object source;

}


LookupOverride:

public class LookupOverride extends MethodOverride {

    private final String beanName;

    private Method method;
.......}


public abstract class MethodOverride implements BeanMetadataElement {

    private final String methodName;

    private boolean overloaded = true;

    private Object source;

...........}


public class MethodOverrides {

    private final Set<MethodOverride> overrides = new LinkedHashSet<MethodOverride>(0);

......}



ReplaceOverride

    public class ReplaceOverride extends MethodOverride {

    private final String methodReplacerBeanName;

    private List<String> typeIdentifiers = new LinkedList<String>();


     。。。。。}


   constructor-arg:只有一個子元素(must not contain more than one sub-element)

       is only allowed to contain either 'ref' attribute OR 'value' attribute OR sub-element

     

ref作為屬性,則轉換成RuntimeBeanReference

public class RuntimeBeanReference implements BeanReference {

    private final String beanName;

    private final boolean toParent;

    private Object source;

。。。。}

        

如果value作為屬性則轉換成:

    public class TypedStringValue implements BeanMetadataElement {

    private String value;

    private volatile Object targetType;

    private Object source;

    private String specifiedTypeName;

    private volatile boolean dynamic;

   。。。。。}

構造函數解析存放的對象:

    public class ConstructorArgumentValues {

    private final Map<Integer, ValueHolder> indexedArgumentValues = new LinkedHashMap<Integer, ValueHolder>(0);

    private final List<ValueHolder> genericArgumentValues = new LinkedList<ValueHolder>();

。。。。}

對應<constructor index....   利用indexedArgumentValues 存放

沒有index的利用genericArgumentValues存放


Property解析:

    public class PropertyValue extends BeanMetadataAttributeAccessor implements Serializable {

    private final String name;

    private final Object value;

    private Object source;

    private boolean optional = false;

    private boolean converted = false;

    private Object convertedValue;

    /** Package-visible field that indicates whether conversion is necessary */
    volatile Boolean conversionNecessary;

    /** Package-visible field for caching the resolved property path tokens */
    transient volatile Object resolvedTokens;

.......}

其中PropertyValue 中的value保存的類型就是ManagedList


public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccessor
        implements BeanDefinition, Cloneable {


.........

private MutablePropertyValues propertyValues;

.........

} 作為存儲默認元素的屬性



Qualifier子元素的解析:

    public class AutowireCandidateQualifier extends BeanMetadataAttributeAccessor {

    public static String VALUE_KEY = "value";

    private final String typeName;

     ......

    }


    public class BeanMetadataAttributeAccessor extends AttributeAccessorSupport implements BeanMetadataElement {

    private Object source;

   ..............

   }


   public abstract class AttributeAccessorSupport implements AttributeAccessor, Serializable {

    /** Map with String keys and Object values */
    private final Map<String, Object> attributes = new LinkedHashMap<String, Object>(0);

    ........

   }



 


  

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

耿马| 南岸区| 青海省| 夹江县| 泸西县| 盘山县| 灵川县| 信丰县| 璧山县| 广昌县| 阳曲县| 同德县| 南昌市| 吉木乃县| 安仁县| 长岭县| 大城县| 象州县| 文化| 河南省| 左贡县| 安新县| 赤水市| 延长县| 海安县| 蒙城县| 永靖县| 宜兰县| 新宾| 陕西省| 肃南| 五台县| 凤阳县| 讷河市| 盐池县| 睢宁县| 沁源县| 兰西县| 怀柔区| 巴塘县| 固镇县|