merge the serviceRef properties and port properties, and update the merged properties in the configAdmin service.

@param configAdmin
@param serviceRefProps
@param portProps
@return
@throws IOException
519735
private void prepareProperties(QName portQName, Map<String, String> serviceRefProps, Map<String, String> portProps) throws IOException {
        // Merge the properties form port and service.
        Map<String, String> allProperties = new HashMap<String, String>();

        if (null != serviceRefProps) {
            allProperties.putAll(serviceRefProps);
        }

        if (null != portProps) {
            allProperties.putAll(portProps);
        }

        for (Map.Entry<String, String> entry : servicePidToPropertyPrefixMap.entrySet()) {

            String serviceFactoryPid = entry.getKey();
            String prefix = entry.getValue();

            // Extract the properties according to different property prefix,
            // update the extracted properties by corresponding factory service.
            Map<String, String> extractProps = extract(prefix, allProperties);

            // Put the port QName and the properties into the servicePropertiesMap
            ConfigProperties configProps = new ConfigProperties(serviceFactoryPid, extractProps);
            Set<ConfigProperties> configSet = servicePropertiesMap.get(portQName);
            if (null == configSet) {
                configSet = new HashSet<ConfigProperties>();
                servicePropertiesMap.put(portQName, configSet);
            }
            if (configSet.contains(configProps)) {
                // re-add the config props
                configSet.remove(configProps);
                configSet.add(configProps);
            } else {
                configSet.add(configProps);
            }
        }
    }
406907
static void mergeResRefsAndBindings(ComponentNameSpaceConfiguration masterCompNSConfig,
                                        List<ComponentNameSpaceConfiguration> compNSConfigs,
                                        InjectionScope scope) throws InjectionException {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "mergeResRefsAndBindings");

        Map<String, ResourceRefConfig[]> resRefMap = new LinkedHashMap<String, ResourceRefConfig[]>();

        Map<JNDIEnvironmentRefType, Map<String, ComponentNameSpaceConfiguration>> allBindingComps = new EnumMap<JNDIEnvironmentRefType, Map<String, ComponentNameSpaceConfiguration>>(JNDIEnvironmentRefType.class);
        for (JNDIEnvironmentRefType refType : JNDIEnvironmentRefType.VALUES) {
            if (refType.getBindingElementName() != null) {
                masterCompNSConfig.setJNDIEnvironmentRefBindings(refType.getType(), new HashMap<String, String>());
                allBindingComps.put(refType, new HashMap<String, ComponentNameSpaceConfiguration>());
            }
        }

        Map<String, String> envEntryValues = new HashMap<String, String>();
        Map<String, ComponentNameSpaceConfiguration> envEntryValueComps = new HashMap<String, ComponentNameSpaceConfiguration>();
        masterCompNSConfig.setEnvEntryValues(envEntryValues);

        boolean refMergeSuccess = true;
        for (int componentIndex = 0; componentIndex < compNSConfigs.size(); componentIndex++) {
            ComponentNameSpaceConfiguration compNSConfig = compNSConfigs.get(componentIndex);
            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "merging component " + componentIndex + ": " + compNSConfig.getJ2EEName());

            // d643480 - Build map of resource reference arrays for merging.
            ResourceRefConfigList resRefs = compNSConfig.getResourceRefConfigList();
            if (resRefs != null) {
                for (int i = 0, size = resRefs.size(); i < size; i++) {
                    ResourceRefConfig resRef = resRefs.getResourceRefConfig(i);
                    String resRefName = resRef.getName();

                    if (scope == null ||
                        scope == InjectionScope.match(resRefName)) {
                        ResourceRefConfig[] resRefArray = resRefMap.get(resRefName);
                        if (resRefArray == null) {
                            resRefArray = new ResourceRefConfig[compNSConfigs.size()];
                            resRefMap.put(resRefName, resRefArray);
                        }

                        // Like in previous releases, we won't error if an individual
                        // component has conflicting ResRefs.  ResRefList.findByName
                        // has always returned the first ResRef in the list, so
                        // ignore subsequent ResRefs for this component.
                        if (resRefArray[componentIndex] == null) {
                            resRefArray[componentIndex] = resRef;
                        }
                    }
                }
            }

            for (JNDIEnvironmentRefType refType : JNDIEnvironmentRefType.VALUES) {
                if (refType.getBindingElementName() != null) {
                    refMergeSuccess &= mergeBindings(compNSConfig, scope,
                                                     refType.getBindingElementName(),
                                                     refType.getBindingAttributeName(),
                                                     compNSConfig.getJNDIEnvironmentRefBindings(refType.getType()),
                                                     masterCompNSConfig.getJNDIEnvironmentRefBindings(refType.getType()),
                                                     allBindingComps.get(refType));
                }
            }

            refMergeSuccess &= mergeBindings(compNSConfig, scope,
                                             "env-entry", "value",
                                             compNSConfig.getEnvEntryValues(),
                                             envEntryValues, envEntryValueComps);
        }

        refMergeSuccess &= mergeResRefs(masterCompNSConfig, compNSConfigs, resRefMap); // d643480

        if (!refMergeSuccess) {
            throw new InjectionConfigurationException("There were conflicting references.  " +
                                                      "See CWNEN0061E messages in log for details.");
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "mergeResRefsAndBindings");
    }
1323510
public static List<InetSocketAddress> getRPCAddresses(String suffix,
      Configuration conf, Collection<String> serviceIds, String... keys) 
          throws IOException {
    // Use default address as fall back
    String defaultAddress = null;
    try {
      defaultAddress = conf.get(FileSystem.FS_DEFAULT_NAME_KEY + suffix);
      if (defaultAddress != null) {
        defaultAddress = NameNode.getDefaultAddress(conf);
      }
    } catch (IllegalArgumentException e) {
      defaultAddress = null;
    }
    
    for (int i = 0; i < keys.length; i++) {
      keys[i] += suffix;
    }
    
    List<InetSocketAddress> addressList = DFSUtil.getAddresses(conf,
        serviceIds, defaultAddress,
        keys);
    if (addressList == null) {
      String keyStr = "";
      for (String key: keys) {
        keyStr += key + " ";
      }
      throw new IOException("Incorrect configuration: namenode address "
          + keyStr
          + " is not configured.");
    }
    return addressList;
  }
815800
public List<PortComponentRefType<ServiceRefType<T>>> getAllPortComponentRef()
   {
      List<PortComponentRefType<ServiceRefType<T>>> list = new ArrayList<PortComponentRefType<ServiceRefType<T>>>();
      List<Node> nodeList = childNode.get("port-component-ref");
      for(Node node: nodeList)
      {
         PortComponentRefType<ServiceRefType<T>>  type = new PortComponentRefTypeImpl<ServiceRefType<T>>(this, "port-component-ref", childNode, node);
         list.add(type);
      }
      return list;
   }
1373494
@Override
    protected K addService(S service, ServiceProperties props) {
        K key = keyFunction.apply(service, props);
        if (key != null) {
            if (serviceMap.putIfAbsent(key, service) != null) {
                getLogger().error("Duplicate key \"{}\" detected for service {}.", key, props.getServiceId());
                return null;
            }
            return key;
        }
        return null;
    }
346799
public static boolean isServiceExported(Configuration configuration, int port, String serviceName) {
        if (serviceName == null)
            return false;
        try {
            final Registry registry = RegistryFinder.getInstance().getRegistry(configuration, port);
            String[] list = registry.list();

            if (list != null) {
                for (int i = 0; i < list.length; i++) {
                    if (serviceName.equals(list[i]))
                        return true;
                }
            }
        } catch (RemoteException ex) {
            return false;
        } catch (Exception e) {
            return false;
        }
        return false;
    }
423613
def add_service_port(service, port):
    '''
    
    '''
    if service not in get_services(permanent=True):
        raise CommandExecutionError('The service does not exist.')

    cmd = '--permanent --service={0} --add-port={1}'.format(service, port)
    return __firewall_cmd(cmd)
44909
@Override
  public ServiceRefAmp toRef(Object serviceImpl)
  {
    if (serviceImpl instanceof ProxyHandleAmp) {
      ProxyHandleAmp proxy = (ProxyHandleAmp) serviceImpl;
      
      return proxy.__caucho_getServiceRef();
    }
    
    Objects.requireNonNull(serviceImpl);
    
    return new ServiceBuilderImpl<>(this, serviceImpl).ref();
  }
792379
static void setJobManagerAddressInConfig(Configuration config, InetSocketAddress address) {
		config.setString(JobManagerOptions.ADDRESS, address.getHostString());
		config.setInteger(JobManagerOptions.PORT, address.getPort());
		config.setString(RestOptions.ADDRESS, address.getHostString());
		config.setInteger(RestOptions.PORT, address.getPort());
	}
512094
public static void configureCustomProxyProperties(
      Map<SFSessionProperty, Object> connectionPropertiesMap)
  {
    if (connectionPropertiesMap.containsKey(SFSessionProperty.USE_PROXY))
    {
      useProxy = (boolean) connectionPropertiesMap.get(
          SFSessionProperty.USE_PROXY);
    }

    if (useProxy)
    {
      proxyHost =
          (String) connectionPropertiesMap.get(SFSessionProperty.PROXY_HOST);
      proxyPort =
          Integer.parseInt(
              connectionPropertiesMap.get(SFSessionProperty.PROXY_PORT).toString());
      proxyUser =
          (String) connectionPropertiesMap.get(SFSessionProperty.PROXY_USER);
      proxyPassword =
          (String) connectionPropertiesMap.get(SFSessionProperty.PROXY_PASSWORD);
      nonProxyHosts =
          (String) connectionPropertiesMap.get(SFSessionProperty.NON_PROXY_HOSTS);
    }
  }
220116
public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException {
        try {
            if (com.google.api.ads.admanager.axis.v201805.PublisherQueryLanguageServiceInterface.class.isAssignableFrom(serviceEndpointInterface)) {
                com.google.api.ads.admanager.axis.v201805.PublisherQueryLanguageServiceSoapBindingStub _stub = new com.google.api.ads.admanager.axis.v201805.PublisherQueryLanguageServiceSoapBindingStub(new java.net.URL(PublisherQueryLanguageServiceInterfacePort_address), this);
                _stub.setPortName(getPublisherQueryLanguageServiceInterfacePortWSDDServiceName());
                return _stub;
            }
        }
        catch (java.lang.Throwable t) {
            throw new javax.xml.rpc.ServiceException(t);
        }
        throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface:  " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName()));
    }
1142104
public void putComponent(String serviceClass,
      String serviceName,
      String componentName,
      ServiceRecord record) throws IOException {
    String path = RegistryUtils.componentPath(
        user, serviceClass, serviceName, componentName);
    registryOperations.mknode(RegistryPathUtils.parentOf(path), true);
    registryOperations.bind(path, record, BindFlags.OVERWRITE);
  }
952605
@FFDCIgnore(PrivilegedActionException.class)
    private String getConfigNameForRef(final String ref) {
        String name = null;
        if (ref != null) {
            final ConfigurationAdmin configAdmin = configAdminRef.getService();
            Configuration config;
            try {
                config = AccessController.doPrivileged(new PrivilegedExceptionAction<Configuration>() {
                    @Override
                    public Configuration run() throws IOException {
                        return configAdmin.getConfiguration(ref, configAdminRef.getReference().getBundle().getLocation());
                    }
                });
            } catch (PrivilegedActionException paex) {
                return null;
            }
            Dictionary<String, Object> props = config.getProperties();
            name = (String) props.get(KEY_NAME);
        }
        return name;
    }
1201319
public void registerComponentBindingsProvider(ServiceReference reference) {
		log.info("registerComponentBindingsProvider");
		log.info("Registering Component Bindings Provider {} - {}",
				new Object[] { reference.getProperty(Constants.SERVICE_ID),
						reference.getProperty(Constants.SERVICE_PID) });
		String[] resourceTypes = OsgiUtil.toStringArray(reference
				.getProperty(ComponentBindingsProvider.RESOURCE_TYPE_PROP),
				new String[0]);
		for (String resourceType : resourceTypes) {
			if (!this.containsKey(resourceType)) {
				put(resourceType, new HashSet<ServiceReference>());
			}
			log.debug("Adding to resource type {}", resourceType);
			get(resourceType).add(reference);
		}
	}
340792
public void setEndpointAddress(javax.xml.namespace.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException {
        setEndpointAddress(portName.getLocalPart(), address);
    }
1318502
@Modified(id = "exporterServices")
    void modifiedExporterService(ServiceReference<ExporterService> serviceReference) {
        try {
            exportersManager.modified(serviceReference);
        } catch (InvalidFilterException invalidFilterException) {
            LOG.error("The ServiceProperty \"" + TARGET_FILTER_PROPERTY + "\" of the ExporterService "
                            + bundleContext.getService(serviceReference) + " doesn't provides a valid Filter."
                            + " To be used, it must provides a correct \"" + TARGET_FILTER_PROPERTY + "\" ServiceProperty.",
                    invalidFilterException
            );
            exportersManager.removeLinks(serviceReference);
            return;
        }
        if (exportersManager.matched(serviceReference)) {
            exportersManager.updateLinks(serviceReference);
        } else {
            exportersManager.removeLinks(serviceReference);
        }
    }
1276318
public static void setAwsClientConfigProperties(ClientConfiguration config,
													Properties configProps) {

		Map<String, Object> awsConfigProperties = new HashMap<>();
		for (Map.Entry<Object, Object> entry : configProps.entrySet()) {
			String key = (String) entry.getKey();
			if (key.startsWith(AWS_CLIENT_CONFIG_PREFIX)) {
				awsConfigProperties.put(key.substring(AWS_CLIENT_CONFIG_PREFIX.length()), entry.getValue());
			}
		}
		// Jackson does not like the following properties
		String[] ignorableProperties = {"secureRandom"};
		BeanDeserializerModifier modifier = new BeanDeserializerModifierForIgnorables(
			ClientConfiguration.class, ignorableProperties);
		DeserializerFactory factory = BeanDeserializerFactory.instance.withDeserializerModifier(
			modifier);
		ObjectMapper mapper = new ObjectMapper(null, null,
			new DefaultDeserializationContext.Impl(factory));

		JsonNode propTree = mapper.convertValue(awsConfigProperties, JsonNode.class);
		try {
			mapper.readerForUpdating(config).readValue(propTree);
		} catch (IOException ex) {
			throw new RuntimeException(ex);
		}
	}