Search in sources :

Example 1 with ServiceBImpl4

use of com.alipay.sofa.ark.container.service.extension.spi.impl.ServiceBImpl4 in project sofa-ark by alipay.

the class ExtensionServiceTest method testExtensionServiceLoader.

@Test
public void testExtensionServiceLoader() {
    PluginManagerService pluginManagerService = ArkServiceContainerHolder.getContainer().getService(PluginManagerService.class);
    PluginModel pluginModel = new PluginModel().setPluginClassLoader(this.getClass().getClassLoader()).setPluginName("mock-plugin");
    pluginManagerService.registerPlugin(pluginModel);
    ServiceB impl1 = ArkServiceLoader.loadExtensionFromArkPlugin(ServiceB.class, "type1", "mock-plugin");
    Assert.assertTrue(impl1 instanceof ServiceBImpl3);
    ServiceB impl2 = ArkServiceLoader.loadExtensionFromArkPlugin(ServiceB.class, "type2", "mock-plugin");
    Assert.assertTrue(impl2 instanceof ServiceBImpl4);
    ServiceB impl3 = ArkServiceLoader.loadExtensionFromArkPlugin(ServiceB.class, "type1", "mock-plugin");
    Assert.assertTrue(impl3 instanceof ServiceBImpl3);
    ServiceB impl4 = ArkServiceLoader.loadExtensionFromArkPlugin(ServiceB.class, "type2", "mock-plugin");
    Assert.assertTrue(impl4 instanceof ServiceBImpl4);
    Assert.assertFalse(impl1 == impl3);
    Assert.assertFalse(impl2 == impl4);
}
Also used : PluginManagerService(com.alipay.sofa.ark.spi.service.plugin.PluginManagerService) ServiceBImpl3(com.alipay.sofa.ark.container.service.extension.spi.impl.ServiceBImpl3) PluginModel(com.alipay.sofa.ark.container.model.PluginModel) ServiceBImpl4(com.alipay.sofa.ark.container.service.extension.spi.impl.ServiceBImpl4) ServiceB(com.alipay.sofa.ark.container.service.extension.spi.ServiceB) ArkContainerTest(com.alipay.sofa.ark.container.ArkContainerTest) Test(org.junit.Test) BaseTest(com.alipay.sofa.ark.container.BaseTest)

Aggregations

ArkContainerTest (com.alipay.sofa.ark.container.ArkContainerTest)1 BaseTest (com.alipay.sofa.ark.container.BaseTest)1 PluginModel (com.alipay.sofa.ark.container.model.PluginModel)1 ServiceB (com.alipay.sofa.ark.container.service.extension.spi.ServiceB)1 ServiceBImpl3 (com.alipay.sofa.ark.container.service.extension.spi.impl.ServiceBImpl3)1 ServiceBImpl4 (com.alipay.sofa.ark.container.service.extension.spi.impl.ServiceBImpl4)1 PluginManagerService (com.alipay.sofa.ark.spi.service.plugin.PluginManagerService)1 Test (org.junit.Test)1