内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

sharding-jdbc中WrapperAdapter的作用是什么

本篇文章為大家展示了sharding-jdbc中WrapperAdapter的作用是什么,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。

成都創(chuàng)新互聯(lián)專注于衡陽企業(yè)網(wǎng)站建設(shè),自適應(yīng)網(wǎng)站建設(shè),商城系統(tǒng)網(wǎng)站開發(fā)。衡陽網(wǎng)站建設(shè)公司,為衡陽等地區(qū)提供建站服務(wù)。全流程按需定制網(wǎng)站,專業(yè)設(shè)計,全程項目跟蹤,成都創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)

Wrapper

jdk-12.jdk/Contents/Home/lib/src.zip!/java.sql/java/sql/Wrapper.java

public interface Wrapper {

    <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException;

    boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException;

}
  • Wrapper接口定義了unwrap、isWrapperFor方法

WrapperAdapter

incubator-shardingsphere-4.0.0-RC1/sharding-jdbc/sharding-jdbc-core/src/main/java/org/apache/shardingsphere/shardingjdbc/jdbc/adapter/WrapperAdapter.java

public abstract class WrapperAdapter implements Wrapper {
    
    private final Collection<JdbcMethodInvocation> jdbcMethodInvocations = new ArrayList<>();
    
    @SuppressWarnings("unchecked")
    @Override
    public final <T> T unwrap(final Class<T> iface) throws SQLException {
        if (isWrapperFor(iface)) {
            return (T) this;
        }
        throw new SQLException(String.format("[%s] cannot be unwrapped as [%s]", getClass().getName(), iface.getName()));
    }
    
    @Override
    public final boolean isWrapperFor(final Class<?> iface) {
        return iface.isInstance(this);
    }
    
    /**
     * record method invocation.
     * 
     * @param targetClass target class
     * @param methodName method name
     * @param argumentTypes argument types
     * @param arguments arguments
     */
    @SneakyThrows
    public final void recordMethodInvocation(final Class<?> targetClass, final String methodName, final Class<?>[] argumentTypes, final Object[] arguments) {
        jdbcMethodInvocations.add(new JdbcMethodInvocation(targetClass.getMethod(methodName, argumentTypes), arguments));
    }
    
    /**
     * Replay methods invocation.
     * 
     * @param target target object
     */
    public final void replayMethodsInvocation(final Object target) {
        for (JdbcMethodInvocation each : jdbcMethodInvocations) {
            each.invoke(target);
        }
    }
}
  • WrapperAdapter聲明實現(xiàn)java.sql.Wrapper接口,它定義了JdbcMethodInvocation集合;recordMethodInvocation方法會往jdbcMethodInvocations添加JdbcMethodInvocation;replayMethodsInvocation方法則會挨個執(zhí)行JdbcMethodInvocation的invoke方法

JdbcMethodInvocation

incubator-shardingsphere-4.0.0-RC1/sharding-jdbc/sharding-jdbc-core/src/main/java/org/apache/shardingsphere/shardingjdbc/jdbc/adapter/invocation/JdbcMethodInvocation.java

@RequiredArgsConstructor
public class JdbcMethodInvocation {
    
    @Getter
    private final Method method;
    
    @Getter
    private final Object[] arguments;
    
    /**
     * Invoke JDBC method.
     * 
     * @param target target object
     */
    @SneakyThrows
    public void invoke(final Object target) {
        method.invoke(target, arguments);
    }
}
  • JdbcMethodInvocation的invoke方法執(zhí)行的是method.invoke

小結(jié)

WrapperAdapter聲明實現(xiàn)java.sql.Wrapper接口,它定義了JdbcMethodInvocation集合;recordMethodInvocation方法會往jdbcMethodInvocations添加JdbcMethodInvocation;replayMethodsInvocation方法則會挨個執(zhí)行JdbcMethodInvocation的invoke方法

上述內(nèi)容就是sharding-jdbc中WrapperAdapter的作用是什么,你們學(xué)到知識或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識儲備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

當(dāng)前標(biāo)題:sharding-jdbc中WrapperAdapter的作用是什么
當(dāng)前URL:http://www.rwnh.cn/article24/pedoje.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計、手機網(wǎng)站建設(shè)、定制開發(fā)、企業(yè)建站服務(wù)器托管、域名注冊

廣告

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

網(wǎng)站托管運營
通州区| 黎川县| 高陵县| 博罗县| 合作市| 思茅市| 定兴县| 陇川县| 南安市| 拜城县| 徐汇区| 吴堡县| 安溪县| 辰溪县| 包头市| 蓬莱市| 山阴县| 太仆寺旗| 东莞市| 乌鲁木齐县| 雅江县| 廊坊市| 建平县| 大名县| 田阳县| 咸阳市| 宜兴市| 桑植县| 汽车| 邓州市| 荃湾区| 田林县| 合作市| 教育| 汨罗市| 新沂市| 宜城市| 武功县| 永城市| 乌拉特中旗| 清徐县|