@Test public void getAddressHolder() throws Exception { ConsumerConfig consumerConfig = new ConsumerConfig().setBootstrap("test").setAddressHolder("test"); ConsumerBootstrap bootstrap = Bootstraps.from(consumerConfig); Assert.assertEquals(AddressHolderFactory.getAddressHolder(bootstrap).getClass(), TestAddressHolder.class); boolean error = false; try { consumerConfig.setAddressHolder("xasdsa"); AddressHolderFactory.getAddressHolder(bootstrap); } catch (Exception e) { error = true; } Assert.assertTrue(error); }
public static AddressHolder getAddressHolder(ConsumerBootstrap consumerBootstrap) { String addressHolder = null; try { addressHolder = consumerBootstrap.getConsumerConfig().getAddressHolder(); ExtensionClass<AddressHolder> ext = ExtensionLoaderFactory.getExtensionLoader(AddressHolder.class) .getExtensionClass(addressHolder); if (ext == null) { throw new SofaRpcRuntimeException(LogCodes.getLog(LogCodes.ERROR_LOAD_ADDRESS_HOLDER, addressHolder)); } return ext.getExtInstance(new Class[] { ConsumerBootstrap.class }, new Object[] { consumerBootstrap }); } catch (SofaRpcRuntimeException e) { throw e; } catch (Throwable e) { throw new SofaRpcRuntimeException(LogCodes.getLog(LogCodes.ERROR_LOAD_ADDRESS_HOLDER, addressHolder), e); } }
AddressHolderFactory { public static AddressHolder getAddressHolder(ConsumerBootstrap consumerBootstrap) { String addressHolder = null; try { addressHolder = consumerBootstrap.getConsumerConfig().getAddressHolder(); ExtensionClass<AddressHolder> ext = ExtensionLoaderFactory.getExtensionLoader(AddressHolder.class) .getExtensionClass(addressHolder); if (ext == null) { throw new SofaRpcRuntimeException(LogCodes.getLog(LogCodes.ERROR_LOAD_ADDRESS_HOLDER, addressHolder)); } return ext.getExtInstance(new Class[] { ConsumerBootstrap.class }, new Object[] { consumerBootstrap }); } catch (SofaRpcRuntimeException e) { throw e; } catch (Throwable e) { throw new SofaRpcRuntimeException(LogCodes.getLog(LogCodes.ERROR_LOAD_ADDRESS_HOLDER, addressHolder), e); } } }
AddressHolderFactory { public static AddressHolder getAddressHolder(ConsumerBootstrap consumerBootstrap) { String addressHolder = null; try { addressHolder = consumerBootstrap.getConsumerConfig().getAddressHolder(); ExtensionClass<AddressHolder> ext = ExtensionLoaderFactory.getExtensionLoader(AddressHolder.class) .getExtensionClass(addressHolder); if (ext == null) { throw new SofaRpcRuntimeException(LogCodes.getLog(LogCodes.ERROR_LOAD_ADDRESS_HOLDER, addressHolder)); } return ext.getExtInstance(new Class[] { ConsumerBootstrap.class }, new Object[] { consumerBootstrap }); } catch (SofaRpcRuntimeException e) { throw e; } catch (Throwable e) { throw new SofaRpcRuntimeException(LogCodes.getLog(LogCodes.ERROR_LOAD_ADDRESS_HOLDER, addressHolder), e); } }  }
AddressHolderFactory { public static AddressHolder getAddressHolder(ConsumerBootstrap consumerBootstrap) { String addressHolder = null; try { addressHolder = consumerBootstrap.getConsumerConfig().getAddressHolder(); ExtensionClass<AddressHolder> ext = ExtensionLoaderFactory.getExtensionLoader(AddressHolder.class) .getExtensionClass(addressHolder); if (ext == null) { throw new SofaRpcRuntimeException(LogCodes.getLog(LogCodes.ERROR_LOAD_ADDRESS_HOLDER, addressHolder)); } return ext.getExtInstance(new Class[] { ConsumerBootstrap.class }, new Object[] { consumerBootstrap }); } catch (SofaRpcRuntimeException e) { throw e; } catch (Throwable e) { throw new SofaRpcRuntimeException(LogCodes.getLog(LogCodes.ERROR_LOAD_ADDRESS_HOLDER, addressHolder), e); } }  static AddressHolder getAddressHolder(ConsumerBootstrap consumerBootstrap); }
AddressHolderFactory { public static AddressHolder getAddressHolder(ConsumerBootstrap consumerBootstrap) { String addressHolder = null; try { addressHolder = consumerBootstrap.getConsumerConfig().getAddressHolder(); ExtensionClass<AddressHolder> ext = ExtensionLoaderFactory.getExtensionLoader(AddressHolder.class) .getExtensionClass(addressHolder); if (ext == null) { throw new SofaRpcRuntimeException(LogCodes.getLog(LogCodes.ERROR_LOAD_ADDRESS_HOLDER, addressHolder)); } return ext.getExtInstance(new Class[] { ConsumerBootstrap.class }, new Object[] { consumerBootstrap }); } catch (SofaRpcRuntimeException e) { throw e; } catch (Throwable e) { throw new SofaRpcRuntimeException(LogCodes.getLog(LogCodes.ERROR_LOAD_ADDRESS_HOLDER, addressHolder), e); } }  static AddressHolder getAddressHolder(ConsumerBootstrap consumerBootstrap);  }