From 5d34828581ec8897e40dbd3667205de392e3c2cd Mon Sep 17 00:00:00 2001 From: Peter Vlugter Date: Mon, 4 May 2020 13:24:28 +1200 Subject: [PATCH] Allow java-support service info to be overridden in config --- java-support/src/main/resources/reference.conf | 8 +------- .../javasupport/impl/EntityDiscoveryImpl.scala | 11 ++++++----- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/java-support/src/main/resources/reference.conf b/java-support/src/main/resources/reference.conf index 41d409dce..2b02ca0a2 100644 --- a/java-support/src/main/resources/reference.conf +++ b/java-support/src/main/resources/reference.conf @@ -1,10 +1,4 @@ cloudstate { - - library { - name = "cloudstate-java-support" - version = "0.4.3" - } - user-function-interface = "127.0.0.1" user-function-interface = ${?HOST} @@ -31,4 +25,4 @@ cloudstate { } } } -} \ No newline at end of file +} diff --git a/java-support/src/main/scala/io/cloudstate/javasupport/impl/EntityDiscoveryImpl.scala b/java-support/src/main/scala/io/cloudstate/javasupport/impl/EntityDiscoveryImpl.scala index 7cf381e1f..a5b84c739 100644 --- a/java-support/src/main/scala/io/cloudstate/javasupport/impl/EntityDiscoveryImpl.scala +++ b/java-support/src/main/scala/io/cloudstate/javasupport/impl/EntityDiscoveryImpl.scala @@ -25,13 +25,14 @@ import io.cloudstate.javasupport.{BuildInfo, StatefulService} class EntityDiscoveryImpl(system: ActorSystem, services: Map[String, StatefulService]) extends EntityDiscovery { - private val config = system.settings.config.getConfig("cloudstate") + private def configuredOrElse(key: String, default: String): String = + if (system.settings.config.hasPath(key)) system.settings.config.getString(key) else default private val serviceInfo = ServiceInfo( - serviceRuntime = sys.props.getOrElse("java.runtime.name", "") + " " + sys.props.getOrElse("java.runtime.version", - ""), - supportLibraryName = config.getString("library.name"), - supportLibraryVersion = config.getString("library.version") + serviceRuntime = sys.props.getOrElse("java.runtime.name", "") + + " " + sys.props.getOrElse("java.runtime.version", ""), + supportLibraryName = configuredOrElse("cloudstate.library.name", BuildInfo.name), + supportLibraryVersion = configuredOrElse("cloudstate.library.version", BuildInfo.version) ) /**