| 1 | package org.maxur.perfmodel.backend.service.impl; | |
| 2 | ||
| 3 | import com.typesafe.config.Config; | |
| 4 | import com.typesafe.config.ConfigException; | |
| 5 | import com.typesafe.config.ConfigFactory; | |
| 6 | import org.jvnet.hk2.annotations.Service; | |
| 7 | import org.maxur.perfmodel.backend.service.PropertiesService; | |
| 8 | import org.slf4j.Logger; | |
| 9 | import org.slf4j.LoggerFactory; | |
| 10 | ||
| 11 | import javax.annotation.PostConstruct; | |
| 12 | ||
| 13 | /** | |
| 14 | * @author Maxim Yunusov | |
| 15 | * @version 1.0 | |
| 16 | * @since <pre>9/2/2015</pre> | |
| 17 | */ | |
| 18 | @Service | |
| 19 | public class PropertiesServiceHoconImpl implements PropertiesService { | |
| 20 | ||
| 21 | private static final Logger LOGGER = LoggerFactory.getLogger(PropertiesServiceHoconImpl.class); | |
| 22 | ||
| 23 | private Config defaultConfig; | |
| 24 | ||
| 25 | private Config userConfig; | |
| 26 | ||
| 27 | @PostConstruct | |
| 28 | public void init() { | |
| 29 | defaultConfig = ConfigFactory.load().getConfig("DEFAULTS"); | |
| 30 | userConfig = ConfigFactory.load().getConfig("PMC"); | |
| 31 | } | |
| 32 | ||
| 33 | ||
| 34 | @Override | |
| 35 | public String asString(final String key) { | |
| 36 | String value; | |
| 37 | try { | |
| 38 | try { | |
| 39 | value = userConfig.getString(key); | |
| 40 | } catch (ConfigException.Missing e) { | |
| 41 | value = defaultConfig.getString(key); | |
| 42 | } | |
| 43 | } catch (ConfigException.Missing e) { | |
| 44 | LOGGER.error("Configuration parameter '{}' is not found.", key); | |
| 45 | throw e; | |
| 46 | } | |
| 47 | LOGGER.info("Configuration parameter {} = '{}'", key, value); | |
| 48 |
1
1. asString : mutated return of Object value for org/maxur/perfmodel/backend/service/impl/PropertiesServiceHoconImpl::asString to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return value; |
| 49 | } | |
| 50 | ||
| 51 | ||
| 52 | ||
| 53 | } | |
Mutations | ||
| 48 |
1.1 |