示例#1
0
 /**
  * Merge excluded configs types with parent. Child values override parent values.
  *
  * @param parent parent service module
  */
 private void mergeExcludedConfigTypes(ServiceInfo parent) {
   if (serviceInfo.getExcludedConfigTypes() == null) {
     serviceInfo.setExcludedConfigTypes(parent.getExcludedConfigTypes());
   } else if (parent.getExcludedConfigTypes() != null) {
     Set<String> resultExcludedConfigTypes = serviceInfo.getExcludedConfigTypes();
     for (String excludedType : parent.getExcludedConfigTypes()) {
       if (!resultExcludedConfigTypes.contains(excludedType)) {
         resultExcludedConfigTypes.add(excludedType);
       }
     }
     serviceInfo.setExcludedConfigTypes(resultExcludedConfigTypes);
   }
 }
示例#2
0
  /** Parse and populate child configuration modules. */
  private void populateConfigurationModules() {
    ConfigurationDirectory configDirectory =
        serviceDirectory.getConfigurationDirectory(serviceInfo.getConfigDir());

    if (configDirectory != null) {
      for (ConfigurationModule config : configDirectory.getConfigurationModules()) {
        ConfigurationInfo info = config.getModuleInfo();
        if (isValid()) {
          setValid(config.isValid() && info.isValid());
          if (!isValid()) {
            setErrors(config.getErrors());
            setErrors(info.getErrors());
          }
        }
        serviceInfo.getProperties().addAll(info.getProperties());
        serviceInfo.setTypeAttributes(config.getConfigType(), info.getAttributes());
        configurationModules.put(config.getConfigType(), config);
      }

      for (String excludedType : serviceInfo.getExcludedConfigTypes()) {
        if (!configurationModules.containsKey(excludedType)) {
          ConfigurationInfo configInfo =
              new ConfigurationInfo(
                  Collections.<PropertyInfo>emptyList(), Collections.<String, String>emptyMap());
          ConfigurationModule config = new ConfigurationModule(excludedType, configInfo);

          config.setDeleted(true);
          configurationModules.put(excludedType, config);
        }
      }
    }
  }