当前位置: 首页>>代码示例>>Java>>正文


Java ExtensionLoader.getExtensionLoader方法代码示例

本文整理汇总了Java中com.alibaba.dubbo.common.extension.ExtensionLoader.getExtensionLoader方法的典型用法代码示例。如果您正苦于以下问题:Java ExtensionLoader.getExtensionLoader方法的具体用法?Java ExtensionLoader.getExtensionLoader怎么用?Java ExtensionLoader.getExtensionLoader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.dubbo.common.extension.ExtensionLoader的用法示例。


在下文中一共展示了ExtensionLoader.getExtensionLoader方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getExtension

import com.alibaba.dubbo.common.extension.ExtensionLoader; //导入方法依赖的package包/类
public <T> T getExtension(Class<T> type, String name) {
    if (type.isInterface() && type.isAnnotationPresent(SPI.class)) {
        ExtensionLoader<T> loader = ExtensionLoader.getExtensionLoader(type);
        if (loader.getSupportedExtensions().size() > 0) {
            return loader.getAdaptiveExtension();
        }
    }
    return null;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:10,代码来源:SpiExtensionFactory.java

示例2: compile

import com.alibaba.dubbo.common.extension.ExtensionLoader; //导入方法依赖的package包/类
public Class<?> compile(String code, ClassLoader classLoader) {
    Compiler compiler;
    ExtensionLoader<Compiler> loader = ExtensionLoader.getExtensionLoader(Compiler.class);
    String name = DEFAULT_COMPILER; // copy reference
    if (name != null && name.length() > 0) {
        compiler = loader.getExtension(name);
    } else {
        compiler = loader.getDefaultExtension();
    }
    return compiler.compile(code, classLoader);
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:12,代码来源:AdaptiveCompiler.java

示例3: test_InitError

import com.alibaba.dubbo.common.extension.ExtensionLoader; //导入方法依赖的package包/类
@Test
public void test_InitError() throws Exception {
    ExtensionLoader<InitErrorExt> loader = ExtensionLoader.getExtensionLoader(InitErrorExt.class);
    
    loader.getExtension("ok");
    
    try {
        loader.getExtension("error");
        fail();
    } catch (IllegalStateException expected) {
        assertThat(expected.getMessage(), containsString("Failed to load extension class(interface: interface com.alibaba.dubbo.common.extensionloader.ext7.InitErrorExt"));
        assertThat(expected.getCause(), instanceOf(ExceptionInInitializerError.class));
    }
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:15,代码来源:ExtensionLoaderTest.java

示例4: test_getExtensionLoader_Null

import com.alibaba.dubbo.common.extension.ExtensionLoader; //导入方法依赖的package包/类
@Test
public void test_getExtensionLoader_Null() throws Exception {
    try {
        ExtensionLoader.getExtensionLoader(null);
        fail();
    } catch (IllegalArgumentException expected) {
        assertThat(expected.getMessage(),
                containsString("Extension type == null"));
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:11,代码来源:ExtensionLoaderTest.java

示例5: destroyAll

import com.alibaba.dubbo.common.extension.ExtensionLoader; //导入方法依赖的package包/类
public static void destroyAll() {
    AbstractRegistryFactory.destroyAll();
    ExtensionLoader<Protocol> loader = ExtensionLoader.getExtensionLoader(Protocol.class);
    for (String protocolName : loader.getLoadedExtensions()) {
        try {
            Protocol protocol = loader.getLoadedExtension(protocolName);
            if (protocol != null) {
                protocol.destroy();
            }
        } catch (Throwable t) {
            logger.warn(t.getMessage(), t);
        }
    }
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:15,代码来源:ProtocolConfig.java

示例6: test_getExtensionLoader_NotSpiAnnotation

import com.alibaba.dubbo.common.extension.ExtensionLoader; //导入方法依赖的package包/类
@Test
public void test_getExtensionLoader_NotSpiAnnotation() throws Exception {
    try {
        ExtensionLoader.getExtensionLoader(NoSpiExt.class);
        fail();
    } catch (IllegalArgumentException expected) {
        assertThat(expected.getMessage(),
                allOf(containsString("com.alibaba.dubbo.common.extensionloader.NoSpiExt"),
                        containsString("is not extension"),
                        containsString("WITHOUT @SPI Annotation")));
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:13,代码来源:ExtensionLoaderTest.java

示例7: test_AddExtension_Adaptive

import com.alibaba.dubbo.common.extension.ExtensionLoader; //导入方法依赖的package包/类
@Test
public void test_AddExtension_Adaptive() throws Exception {
    ExtensionLoader<AddExt2> loader = ExtensionLoader.getExtensionLoader(AddExt2.class);
    loader.addExtension(null, AddExt2_ManualAdaptive.class);

    AddExt2 adaptive = loader.getAdaptiveExtension();
    assertTrue(adaptive instanceof AddExt2_ManualAdaptive);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:9,代码来源:ExtensionLoaderTest.java

示例8: test_AddExtension_Adaptive_ExceptionWhenExistedAdaptive

import com.alibaba.dubbo.common.extension.ExtensionLoader; //导入方法依赖的package包/类
@Test
public void test_AddExtension_Adaptive_ExceptionWhenExistedAdaptive() throws Exception {
    ExtensionLoader<AddExt1> loader = ExtensionLoader.getExtensionLoader(AddExt1.class);

    loader.getAdaptiveExtension();

    try {
        loader.addExtension(null, AddExt1_ManualAdaptive.class);
        fail();
    }
    catch (IllegalStateException expected) {
        assertThat(expected.getMessage(), containsString("Adaptive Extension already existed(Extension interface com.alibaba.dubbo.common.extensionloader.ext8_add.AddExt1)!"));
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:15,代码来源:ExtensionLoaderTest.java

示例9: test_replaceExtension_Adaptive_ExceptionWhenNotExistedExtension

import com.alibaba.dubbo.common.extension.ExtensionLoader; //导入方法依赖的package包/类
@Test
public void test_replaceExtension_Adaptive_ExceptionWhenNotExistedExtension() throws Exception {
    ExtensionLoader<AddExt4> loader = ExtensionLoader.getExtensionLoader(AddExt4.class);

    try {
        loader.replaceExtension(null, AddExt4_ManualAdaptive.class);
        fail();
    }
    catch (IllegalStateException expected) {
        assertThat(expected.getMessage(), containsString("Adaptive Extension not existed(Extension interface com.alibaba.dubbo.common.extensionloader.ext8_add.AddExt4)"));
    }
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:13,代码来源:ExtensionLoaderTest.java

示例10: test_replaceExtension_Adaptive

import com.alibaba.dubbo.common.extension.ExtensionLoader; //导入方法依赖的package包/类
@Test
public void test_replaceExtension_Adaptive() throws Exception {
    ExtensionLoader<AddExt3> loader = ExtensionLoader.getExtensionLoader(AddExt3.class);

    AddExt3 adaptive = loader.getAdaptiveExtension();
    assertFalse(adaptive instanceof AddExt3_ManualAdaptive);

    loader.replaceExtension(null, AddExt3_ManualAdaptive.class);

    adaptive = loader.getAdaptiveExtension();
    assertTrue(adaptive instanceof AddExt3_ManualAdaptive);
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:13,代码来源:ExtensionLoaderTest.java

示例11: test_getExtensionLoader_NotInterface

import com.alibaba.dubbo.common.extension.ExtensionLoader; //导入方法依赖的package包/类
@Test
public void test_getExtensionLoader_NotInterface() throws Exception {
    try {
        ExtensionLoader.getExtensionLoader(ExtensionLoaderTest.class);
        fail();
    } catch (IllegalArgumentException expected) {
        assertThat(expected.getMessage(),
                containsString("Extension type(class com.alibaba.dubbo.common.extensionloader.ExtensionLoaderTest) is not interface"));
    }
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:11,代码来源:ExtensionLoaderTest.java

示例12: test_useAdaptiveClass

import com.alibaba.dubbo.common.extension.ExtensionLoader; //导入方法依赖的package包/类
@Test
public void test_useAdaptiveClass() throws Exception {
    ExtensionLoader<HasAdaptiveExt> loader = ExtensionLoader.getExtensionLoader(HasAdaptiveExt.class);
    HasAdaptiveExt ext = loader.getAdaptiveExtension();
    assertTrue(ext instanceof HasAdaptiveExt_ManualAdaptive);
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:7,代码来源:ExtensionLoader_Adaptive_Test.java


注:本文中的com.alibaba.dubbo.common.extension.ExtensionLoader.getExtensionLoader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。