/**
 * AET
 *
 * Copyright (C) 2013 Cognifide Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.cognifide.aet.rest.helpers;

import java.util.Map;
import java.util.Optional;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.osgi.PropertiesUtil;

@Service(ReportConfigurationManager.class)
@Component(metatype = true, description = "AET Report Application Configuration",
    label = "AET Report Application Configuration")
public class ReportConfigurationManager {

  private static final String REPORT_DOMAIN_PROPERTY_NAME = "report-domain";

  private static final String DEFAULT_REPORT_DOMAIN = "http://aet-vagrant";

  private static final String REPORT_DOMAIN_ENV = "REPORT_DOMAIN";

  @Property(name = REPORT_DOMAIN_PROPERTY_NAME, label = "Report application domain",
      description = "Report application domain", value = DEFAULT_REPORT_DOMAIN)
  private String reportDomain;

  @Activate
  public void activate(Map<String, String> properties) {
    reportDomain = Optional.ofNullable(System.getenv(REPORT_DOMAIN_ENV))
        .orElse(PropertiesUtil
            .toString(properties.get(REPORT_DOMAIN_PROPERTY_NAME), DEFAULT_REPORT_DOMAIN));
  }

  public String getReportDomain() {
    return reportDomain;
  }
}

/**
 * AET
 *
 * Copyright (C) 2013 Cognifide Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.cognifide.aet.rest.helpers;

import java.util.Map;
import java.util.Optional;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;

@Service(ReportConfigurationManager.class)
@Component(metatype = true, description = "AET Report Application Configuration",
    label = "AET Report Application Configuration")
public class ReportConfigurationManager {

  private static final String REPORT_DOMAIN_PROPERTY_NAME = "report-domain";

  private static final String DEFAULT_REPORT_DOMAIN = "http://aet-vagrant";

  private static final String REPORT_DOMAIN_ENV = "REPORT_DOMAIN";

  @Property(name = REPORT_DOMAIN_PROPERTY_NAME, label = "Report application domain",
      description = "Report application domain that is printed at the end of processing suite. "
          + "If not provided here, env variable REPORT_DOMAIN will be used instead or value will fallback to the default."
      , value = DEFAULT_REPORT_DOMAIN)
  private String reportDomain;

  @Activate
  public void activate(Map<String, String> properties) {
    reportDomain = Optional.ofNullable(properties.get(REPORT_DOMAIN_PROPERTY_NAME))
        .orElseGet(() -> Optional.ofNullable(System.getenv(REPORT_DOMAIN_ENV))
            .orElse(DEFAULT_REPORT_DOMAIN));
  }

  public String getReportDomain() {
    return reportDomain;
  }
}

change the property resolving priority