Java Code Examples for com.alibaba.dubbo.common.extension.ExtensionLoader#getExtension()
The following examples show how to use
com.alibaba.dubbo.common.extension.ExtensionLoader#getExtension() .
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: MixCacheFactory.java From dubbo-plus with Apache License 2.0 | 6 votes |
@Override protected Cache generateNewCache(String cacheName, URL url) { String mixCache = CacheConfig.getProperty(MIX_CACHE); if(StringUtils.isEmpty(mixCache)){ throw new IllegalArgumentException("cache.mix must not be null"); } String caches[] = Constants.COMMA_SPLIT_PATTERN.split(mixCache); if(caches.length!=2){ throw new IllegalArgumentException("cache.mix must set two caches,but not set "+caches.length+" "); } ExtensionLoader cacheFactoryLoader = ExtensionLoader.getExtensionLoader(CacheFactory.class); CacheFactory l1CacheFactory = (CacheFactory) cacheFactoryLoader.getExtension(caches[0]); if(l1CacheFactory==null){ throw new IllegalArgumentException("not found CacheFactory extension by name ["+caches[0]+"]"); } CacheFactory l2CacheFactory = (CacheFactory) cacheFactoryLoader.getExtension(caches[1]); if(l2CacheFactory==null){ throw new IllegalArgumentException("not found CacheFactory extension by name ["+caches[1]+"]"); } return new MixCache(l1CacheFactory.getCache(url),l2CacheFactory.getCache(url),cacheName,url); }
Example 2
Source File: AdaptiveCompiler.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Override 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); }
Example 3
Source File: ExtensionLoaderTest.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@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)); } }
Example 4
Source File: AdaptiveCompiler.java From dubbox with Apache License 2.0 | 5 votes |
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); }
Example 5
Source File: ExtensionLoaderTest.java From dubbox with Apache License 2.0 | 5 votes |
@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)); } }
Example 6
Source File: AdaptiveCompiler.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
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); }
Example 7
Source File: ExtensionLoaderTest.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
@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)); } }
Example 8
Source File: AdaptiveCompiler.java From dubbo3 with Apache License 2.0 | 5 votes |
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); }
Example 9
Source File: ExtensionLoaderTest.java From dubbo3 with Apache License 2.0 | 5 votes |
@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)); } }
Example 10
Source File: AdaptiveCompiler.java From dubbox with Apache License 2.0 | 5 votes |
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); }
Example 11
Source File: ExtensionLoaderTest.java From dubbox with Apache License 2.0 | 5 votes |
@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)); } }
Example 12
Source File: CompensableLoadBalance.java From ByteTCC with GNU Lesser General Public License v3.0 | 5 votes |
private synchronized void initializeIfNecessary() { if (this.loadBalancer == null) { Environment environment = CompensableBeanRegistry.getInstance().getEnvironment(); String loadBalanceKey = environment.getProperty(CONSTANT_LOADBALANCE_KEY, "default"); ExtensionLoader<ILoadBalancer> extensionLoader = ExtensionLoader.getExtensionLoader(ILoadBalancer.class); this.loadBalancer = extensionLoader.getExtension(loadBalanceKey); } }
Example 13
Source File: AdaptiveCompiler.java From dubbox with Apache License 2.0 | 5 votes |
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); }
Example 14
Source File: ExtensionLoaderTest.java From dubbox with Apache License 2.0 | 5 votes |
@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)); } }
Example 15
Source File: TransactionLoadBalance.java From ByteJTA with GNU Lesser General Public License v3.0 | 5 votes |
private synchronized void initializeIfNecessary() { if (this.loadBalancer == null) { Environment environment = TransactionBeanRegistry.getInstance().getEnvironment(); String loadBalanceKey = environment.getProperty(CONSTANT_LOADBALANCE_KEY, "default"); ExtensionLoader<ILoadBalancer> extensionLoader = ExtensionLoader.getExtensionLoader(ILoadBalancer.class); this.loadBalancer = extensionLoader.getExtension(loadBalanceKey); } }