org.apache.dubbo.common.utils.CollectionUtils Java Examples

The following examples show how to use org.apache.dubbo.common.utils.CollectionUtils. 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: NacosInstanceManageUtil.java    From dubbo-registry-nacos with Apache License 2.0 5 votes vote down vote up
public static List<Instance> getAllCorrespondingServiceInstanceList(String serviceName) {
    if (!CORRESPONDING_SERVICE_NAMES_MAP.containsKey(serviceName)) {
        return Lists.newArrayList();
    }
    List<Instance> allInstances = Lists.newArrayList();
    for (String correspondingServiceName : CORRESPONDING_SERVICE_NAMES_MAP.get(serviceName)) {
        if (SERVICE_INSTANCE_LIST_MAP.containsKey(correspondingServiceName) && CollectionUtils.isNotEmpty(SERVICE_INSTANCE_LIST_MAP.get(correspondingServiceName))) {
            allInstances.addAll(SERVICE_INSTANCE_LIST_MAP.get(correspondingServiceName));
        }
    }
    return allInstances;
}
 
Example #2
Source File: DubboGenericServiceFactory.java    From spring-cloud-alibaba with Apache License 2.0 5 votes vote down vote up
private void bindReferenceBean(ReferenceBean<GenericService> referenceBean,
		Map<String, Object> dubboTranslatedAttributes) {
	DataBinder dataBinder = new DataBinder(referenceBean);
	// Register CustomEditors for special fields
	dataBinder.registerCustomEditor(String.class, "filter",
			new StringTrimmerEditor(true));
	dataBinder.registerCustomEditor(String.class, "listener",
			new StringTrimmerEditor(true));
	dataBinder.registerCustomEditor(Map.class, "parameters",
			new PropertyEditorSupport() {

				@Override
				public void setAsText(String text)
						throws java.lang.IllegalArgumentException {
					// Trim all whitespace
					String content = StringUtils.trimAllWhitespace(text);
					if (!StringUtils.hasText(content)) { // No content , ignore
															// directly
						return;
					}
					// replace "=" to ","
					content = StringUtils.replace(content, "=", ",");
					// replace ":" to ","
					content = StringUtils.replace(content, ":", ",");
					// String[] to Map
					Map<String, String> parameters = CollectionUtils
							.toStringMap(commaDelimitedListToStringArray(content));
					setValue(parameters);
				}
			});

	// ignore "registries" field and then use RegistryConfig beans
	dataBinder.setDisallowedFields("registries");

	dataBinder.bind(new MutablePropertyValues(dubboTranslatedAttributes));

	registryConfigs.ifAvailable(referenceBean::setRegistries);
}