public static MicroserviceConfig readConfig ( final String serviceName ) { final Logger logger = LoggerFactory . getLogger ( MicroserviceConfig . class ) ; if ( new File ( resourceLocation ) . exists ( ) ) { final String json = IO . read ( resourceLocation ) ; return JsonFactory . fromJson ( json , MicroserviceConfig . class ) ; } else if ( resourceLocationEnv != null && new File ( resourceLocationEnv ) . exists ( ) ) { final String json = IO . read ( resourceLocationEnv ) ; return JsonFactory . fromJson ( json , MicroserviceConfig . class ) ; } else { logger . info ( "Reading config from classpath as it is not found on file system" ) ; final String qbitEnv = System . getenv ( "QBIT_ENV" ) ; final String resourceLocationOnClasspath = qbitEnv != null && ! qbitEnv . isEmpty ( ) ? serviceName + "_" + qbitEnv + ".json" : serviceName + ".json" ; final String json = IO . read ( Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( resourceLocationOnClasspath ) ) ; return JsonFactory . fromJson ( json , MicroserviceConfig . class ) ; } }
Reads the readConfig file which can be a classpath or file system resource .