得到注册中心对象

@param registryConfig RegistryConfig类
@return Registry实现
545489
public static synchronized Registry getRegistry(RegistryConfig registryConfig) {
        if (ALL_REGISTRIES.size() > 3) { // 超过3次 是不是配错了？
            if (LOGGER.isWarnEnabled()) {
                LOGGER.warn("Size of registry is greater than 3, Please check it!");
            }
        }
        try {
            // 注意：RegistryConfig重写了equals方法，如果多个RegistryConfig属性一样，则认为是一个对象
            Registry registry = ALL_REGISTRIES.get(registryConfig);
            if (registry == null) {
                ExtensionClass<Registry> ext = ExtensionLoaderFactory.getExtensionLoader(Registry.class)
                    .getExtensionClass(registryConfig.getProtocol());
                if (ext == null) {
                    throw ExceptionUtils.buildRuntime("registry.protocol", registryConfig.getProtocol(),
                        "Unsupported protocol of registry config !");
                }
                registry = ext.getExtInstance(new Class[] { RegistryConfig.class }, new Object[] { registryConfig });
                ALL_REGISTRIES.put(registryConfig, registry);
            }
            return registry;
        } catch (SofaRpcRuntimeException e) {
            throw e;
        } catch (Throwable e) {
            throw new SofaRpcRuntimeException(e.getMessage(), e);
        }
    }
872802
@NotNull
    public static <T> T deserialize(@NotNull final DeserializerRegistry registry, @NotNull final SerializedData data) {
        Contract.requireArgNotNull("registry", registry);
        Contract.requireArgNotNull("data", data);
        final Deserializer deserializer = registry.getDeserializer(data.getType(), data.getMimeType());
        return deserializer.unmarshal(data.getRaw(), data.getType(), data.getMimeType());

    }
1246178
private AbstractInterfaceConfig getRegisterConfig(ConsumerConfig config) {
        String url = ZookeeperRegistryHelper.convertConsumerToUrl(config);
        String addr = url.substring(0, url.indexOf("?"));
        for (Map.Entry<ConsumerConfig, String> consumerUrl : consumerUrls.entrySet()) {
            if (consumerUrl.getValue().contains(addr)) {
                return consumerUrl.getKey();
            }
        }
        return null;
    }
298428
public static Registry run(String type, String test) {
    Registry registry = createRegistry(type);
    TESTS.get(test).accept(registry);
    return registry;
  }
1286355
public static DynamicConfigGenerator createDynamicConfigGenerator(Config config) {
    String dynamicConfigGeneratorClassName =
        ConfigUtils.getString(config, ConfigurationKeys.DYNAMIC_CONFIG_GENERATOR_CLASS_KEY,
            ConfigurationKeys.DEFAULT_DYNAMIC_CONFIG_GENERATOR_CLASS_KEY);

    try {
      ClassAliasResolver<DynamicConfigGenerator> aliasResolver =
          new ClassAliasResolver<>(DynamicConfigGenerator.class);
      return aliasResolver.resolveClass(dynamicConfigGeneratorClassName).newInstance();
    } catch (ReflectiveOperationException e) {
      throw new RuntimeException("Could not construct DynamicConfigGenerator " +
          dynamicConfigGeneratorClassName, e);
    }
  }
1251942
public static SparkNameFunction fromConfig(Config config, String key, Registry registry) {
    return fromPatternList(config.getConfigList(key), registry);
  }
510220
private Dictionary<String, Object> buildUserRegistryConfigProps() {
        Hashtable<String, Object> properties = new Hashtable<String, Object>();
        properties.put("config.id", QUICK_START_SECURITY_REGISTRY_ID);
        properties.put("id", QUICK_START_SECURITY_REGISTRY_ID);
        properties.put(UserRegistryService.REGISTRY_TYPE, QUICK_START_SECURITY_REGISTRY_TYPE);
        properties.put(CFG_KEY_USER, config.userName());
        properties.put("service.vendor", "IBM");
        return properties;
    }
659001
static public long computeConfigurationSignature(byte [] config) {
        PureJavaCrc32C crc = new PureJavaCrc32C();
        crc.update(config);
        return crc.getValue();
    }
942349
private PluginRegistryBean loadRegistry(URI registryUrl) {
        PluginRegistryBean fromCache = registryCache.get(registryUrl);
        if (fromCache != null) {
            return fromCache;
        }
        try {
            PluginRegistryBean registry = mapper.reader(PluginRegistryBean.class).readValue(registryUrl.toURL());
            registryCache.put(registryUrl, registry);
            return registry;
        } catch (IOException e) {
            return null;
        }
    }
655087
protected List<ProviderGroup> subscribeFromRegistries() {
        List<ProviderGroup> result = new ArrayList<ProviderGroup>();
        List<RegistryConfig> registryConfigs = consumerConfig.getRegistry();
        if (CommonUtils.isEmpty(registryConfigs)) {
            return result;
        }
        // 是否等待结果
        int addressWaitTime = consumerConfig.getAddressWait();
        int maxAddressWaitTime = SofaConfigs.getIntegerValue(consumerConfig.getAppName(),
            SofaOptions.CONFIG_MAX_ADDRESS_WAIT_TIME, SofaOptions.MAX_ADDRESS_WAIT_TIME);
        addressWaitTime = addressWaitTime < 0 ? maxAddressWaitTime : Math.min(addressWaitTime, maxAddressWaitTime);

        ProviderInfoListener listener = consumerConfig.getProviderInfoListener();
        respondRegistries = addressWaitTime == 0 ? null : new CountDownLatch(registryConfigs.size());

        // 从注册中心订阅 {groupName: ProviderGroup}
        Map<String, ProviderGroup> tmpProviderInfoList = new HashMap<String, ProviderGroup>();
        for (RegistryConfig registryConfig : registryConfigs) {
            Registry registry = RegistryFactory.getRegistry(registryConfig);
            registry.init();
            registry.start();

            try {
                List<ProviderGroup> current;
                try {
                    if (respondRegistries != null) {
                        consumerConfig.setProviderInfoListener(new WrapperClusterProviderInfoListener(listener,
                            respondRegistries));
                    }
                    current = registry.subscribe(consumerConfig);
                } finally {
                    if (respondRegistries != null) {
                        consumerConfig.setProviderInfoListener(listener);
                    }
                }
                if (current == null) {
                    continue; // 未同步返回结果
                } else {
                    if (respondRegistries != null) {
                        respondRegistries.countDown();
                    }
                }
                for (ProviderGroup group : current) { //  当前注册中心的
                    String groupName = group.getName();
                    if (!group.isEmpty()) {
                        ProviderGroup oldGroup = tmpProviderInfoList.get(groupName);
                        if (oldGroup != null) {
                            oldGroup.addAll(group.getProviderInfos());
                        } else {
                            tmpProviderInfoList.put(groupName, group);
                        }
                    }
                }
            } catch (SofaRpcRuntimeException e) {
                throw e;
            } catch (Throwable e) {
                String appName = consumerConfig.getAppName();
                if (LOGGER.isWarnEnabled(appName)) {
                    LOGGER.warnWithApp(appName,
                        "Catch exception when subscribe from registry: " + registryConfig.getId()
                            + ", but you can ignore if it's called by JVM shutdown hook", e);
                }
            }
        }
        if (respondRegistries != null) {
            try {
                respondRegistries.await(addressWaitTime, TimeUnit.MILLISECONDS);
            } catch (Exception ignore) { // NOPMD
            }
        }
        return new ArrayList<ProviderGroup>(tmpProviderInfoList.values());
    }
1212405
protected MetricRegistryImpl createMetricRegistry(Configuration config) {
		return new MetricRegistryImpl(
			MetricRegistryConfiguration.fromConfiguration(config),
			ReporterSetup.fromConfiguration(config));
	}
1087850
@Override
    public RegistrationManager getRegistrationManager(){
        if(registrationManager == null){
            synchronized(this){
                if(registrationManager == null){
                    RegistrationManagerImpl registration = new RegistrationManagerImpl(getDirectoryServiceClientManager());
                    registration.start();
                    registrationManager = registration;
                }
            }
        }
        return registrationManager;
    }
482430
public static CipherExecutor newTicketRegistryCipherExecutor(final EncryptionRandomizedSigningJwtCryptographyProperties registry,
                                                                 final String registryName) {
        return newTicketRegistryCipherExecutor(registry, false, registryName);
    }
186980
public static ExtensionRegistry addToRegistry(final FieldDescriptor extension,
      final ExtensionRegistry registry) {
    if (extension.getJavaType() == JavaType.MESSAGE) {
      registry.add(extension, DynamicMessage.getDefaultInstance(extension.getMessageType()));
    } else {
      registry.add(extension);
    }

    return registry;
  }
825698
public static void installDefaultRegistry(@NonNull final DefaultResolverRegistry registry) {
            /*
             * register built-in cards & mCells
             */
        MVHelper mvHelper = new MVHelper(new MVResolver());
        registry.setMVHelper(mvHelper);

        // built-in mCells
        registry.registerCell(TYPE_EXTENDED_VIEW_COMPACT, Card.PlaceholderCell.class,
            SimpleEmptyView.class);
        registry.registerCell(TYPE_EMPTY_VIEW_COMPACT, BaseCell.class, SimpleEmptyView.class);
        //registry.registerCell(TYPE_SIMPLE_IMAGE_COMPACT, Cell.class, SimpleImgView.class);
        registry.registerCell(TYPE_CAROUSEL_CELL_COMPACT, BannerView.class);
        registry.registerCell(TYPE_CONTAINER_BANNER, BannerView.class);
        registry.registerCell(TYPE_LINEAR_SCROLL_CELL_COMPACT, LinearScrollView.class);
        registry.registerCell(TYPE_CONTAINER_SCROLL, LinearScrollView.class);

        // built-in cards
        registry.registerCard(TYPE_CAROUSEL_COMPACT, BannerCard.class);
        registry.registerCard(TYPE_CONTAINER_BANNER, BannerCard.class);
        registry.registerCard(TYPE_SINGLE_COLUMN_COMPACT, SingleColumnCard.class);
        registry.registerCard(TYPE_CONTAINER_1C_FLOW, SingleColumnCard.class);
        registry.registerCard(TYPE_DOUBLE_COLUMN_COMPACT, DoubleColumnCard.class);
        registry.registerCard(TYPE_CONTAINER_2C_FLOW, DoubleColumnCard.class);
        registry.registerCard(TYPE_TRIPLE_COLUMN_COMPACT, TripleColumnCard.class);
        registry.registerCard(TYPE_CONTAINER_3C_FLOW, TripleColumnCard.class);
        registry.registerCard(TYPE_FOUR_COLUMN_COMPACT, FourColumnCard.class);
        registry.registerCard(TYPE_CONTAINER_4C_FLOW, FourColumnCard.class);
        registry.registerCard(TYPE_ONE_PLUS_N_COMPACT, OnePlusNCard.class);
        registry.registerCard(TYPE_CONTAINER_ON_PLUSN, OnePlusNCard.class);
        registry.registerCard(TYPE_FLOAT_COMPACT, FloatCard.class);
        registry.registerCard(TYPE_CONTAINER_FLOAT, FloatCard.class);
        registry.registerCard(TYPE_PIN_BOTTOM_COMPACT, PinBottomCard.class);
        registry.registerCard(TYPE_FIVE_COLUMN_COMPACT, FiveColumnCard.class);
        registry.registerCard(TYPE_CONTAINER_5C_FLOW, FiveColumnCard.class);
        registry.registerCard(TYPE_STICKY_COMPACT, StickyCard.class);
        registry.registerCard(TYPE_CONTAINER_STICKY, StickyCard.class);
        registry.registerCard(TYPE_STICKY_START_COMPACT, StickyCard.class);
        registry.registerCard(TYPE_STICKY_END_COMPACT, StickyEndCard.class);
        registry.registerCard(TYPE_PIN_TOP_COMPACT, PinTopCard.class);
        registry.registerCard(TYPE_CONTAINER_FIX, FixCard.class);
        registry.registerCard(TYPE_STAGGER_COMPACT, StaggeredCard.class);
        registry.registerCard(TYPE_CONTAINER_WATERFALL, StaggeredCard.class);

        registry.registerCard(TYPE_FUSION_TABS_COMPACT, FusionCard.class);
        registry.registerCard(TYPE_FLOW_COMPACT, FlowCard.class);
        registry.registerCard(TYPE_CONTAINER_FLOW, FlowCard.class);
        registry.registerCard(TYPE_SCROLL_FIX_COMPACT, ScrollFixCard.class);
        registry.registerCard(TYPE_CONTAINER_SCROLL_FIX, ScrollFixCard.class);

        registry.registerCard(TYPE_LINEAR_SCROLL_COMPACT, LinearScrollCard.class);
        registry.registerCard(TYPE_CONTAINER_SCROLL, LinearScrollCard.class);
        registry.registerCard(TYPE_SCROLL_FIX_BANNER_COMPACT, FixLinearScrollCard.class);
        registry.registerCard(TYPE_CONTAINER_SCROLL_FIX_BANNER, FixLinearScrollCard.class);

        // extend cards
        registry.registerCard(TYPE_FIX_COMPACT, FixCard.class);
        registry.registerCard(TYPE_GRID_COMPACT, GridCard.class);
        registry.registerCard(TYPE_LINEAR_COMPACT, LinearCard.class);
        registry.registerCard(TYPE_X_COLUMN_COMPACT, ColumnCard.class);
    }
136166
public Registry getRegistry() throws RemoteException {
        if (registry == null) {
            if (StringUtils.hasText(host)) {
                registry = LocateRegistry.getRegistry(host, port);
            } else {
                registry = LocateRegistry.getRegistry(port);
            }
        }

        return registry;
    }
715957
private UserRegistry getUserRegistryFromConfiguration() throws RegistryException {
        String[] refIds = this.refId;
        if (refIds == null || refIds.length == 0) {
            // Can look for config.source = file
            // If thats set, and we're missing this, we can error.
            // If its not set, we don't have configuration from the
            // file and we should try to resolve if we have one instance defined?
            Tr.error(tc, "USER_REGISTRY_SERVICE_CONFIG_ERROR_NO_REFID");
            throw new RegistryException(TraceNLS.getFormattedMessage(
                                                                     this.getClass(),
                                                                     TraceConstants.MESSAGE_BUNDLE,
                                                                     "USER_REGISTRY_SERVICE_CONFIG_ERROR_NO_REFID",
                                                                     null,
                                                                     "CWWKS3000E: A configuration error has occurred. There is no configured refId parameter for the userRegistry configuration."));
        } else if (refIds.length == 1) {
            return getUserRegistry(refIds[0]);
        } else {
            // Multiple refIds, we'll use the UserRegistryProxy.
            List<UserRegistry> delegates = new ArrayList<UserRegistry>();
            for (String refId : refIds) {
                delegates.add(getUserRegistry(refId));
            }
            return new UserRegistryProxy(realm, delegates);
        }
    }