Java Code Examples for com.alibaba.dubbo.common.extension.ExtensionLoader#getAdaptiveExtension()

The following examples show how to use com.alibaba.dubbo.common.extension.ExtensionLoader#getAdaptiveExtension() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExtensionLoaderTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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)!"));
    }
}
 
Example 2
Source File: ExtensionLoaderTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 3
Source File: ExtensionLoaderTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@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)!"));
    }
}
 
Example 4
Source File: ExtensionLoaderTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 5
Source File: ExtensionLoaderTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 6
Source File: ExtensionLoaderTest.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
@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)!"));
    }
}
 
Example 7
Source File: ExtensionLoaderTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 8
Source File: ExtensionLoaderTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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)!"));
    }
}
 
Example 9
Source File: ExtensionLoaderTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 10
Source File: SpiExtensionFactory.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 11
Source File: ExtensionLoaderTest.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 12
Source File: ExtensionLoaderTest.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 13
Source File: ExtensionLoaderTest.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@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)!"));
    }
}
 
Example 14
Source File: ExtensionLoaderTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 15
Source File: SpiExtensionFactory.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 16
Source File: ExtensionLoader_Adaptive_Test.java    From dubbox with Apache License 2.0 4 votes vote down vote up
@Test
public void test_useAdaptiveClass() throws Exception {
    ExtensionLoader<HasAdaptiveExt> loader = ExtensionLoader.getExtensionLoader(HasAdaptiveExt.class);
    HasAdaptiveExt ext = loader.getAdaptiveExtension();
    assertTrue(ext instanceof HasAdaptiveExt_ManualAdaptive);
}
 
Example 17
Source File: ExtensionLoader_Adaptive_Test.java    From dubbox with Apache License 2.0 4 votes vote down vote up
@Test
public void test_useAdaptiveClass() throws Exception {
    ExtensionLoader<HasAdaptiveExt> loader = ExtensionLoader.getExtensionLoader(HasAdaptiveExt.class);
    HasAdaptiveExt ext = loader.getAdaptiveExtension();
    assertTrue(ext instanceof HasAdaptiveExt_ManualAdaptive);
}
 
Example 18
Source File: ExtensionLoader_Adaptive_Test.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
@Test
public void test_useAdaptiveClass() throws Exception {
    ExtensionLoader<HasAdaptiveExt> loader = ExtensionLoader.getExtensionLoader(HasAdaptiveExt.class);
    HasAdaptiveExt ext = loader.getAdaptiveExtension();
    assertTrue(ext instanceof HasAdaptiveExt_ManualAdaptive);
}
 
Example 19
Source File: ExtensionLoader_Adaptive_Test.java    From dubbox with Apache License 2.0 4 votes vote down vote up
@Test
public void test_useAdaptiveClass() throws Exception {
    ExtensionLoader<HasAdaptiveExt> loader = ExtensionLoader.getExtensionLoader(HasAdaptiveExt.class);
    HasAdaptiveExt ext = loader.getAdaptiveExtension();
    assertTrue(ext instanceof HasAdaptiveExt_ManualAdaptive);
}
 
Example 20
Source File: ExtensionLoader_Adaptive_Test.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
@Test
public void test_useAdaptiveClass() throws Exception {
    ExtensionLoader<HasAdaptiveExt> loader = ExtensionLoader.getExtensionLoader(HasAdaptiveExt.class);
    HasAdaptiveExt ext = loader.getAdaptiveExtension();
    assertTrue(ext instanceof HasAdaptiveExt_ManualAdaptive);
}