Please sign in to comment.
! can, routing, servlet, util: improve *Settings infrastructure
All our Setting model classes follow the same pattern: apart from the default case class constructor we supply two `XxxSettings.apply` overloads: 1. `def apply(system: ActorSystem): XxxSettings` 2. `def apply(config: Config): XxxSettings` The first one simply calls the second with the ActorSystem's config. However, so far it also selected the respective sub-config for the Settings, e.g. "spray.can.server" for the spray-can `ServerSettings`. The second overload therefore required the correct *sub-config* for the Settings rather than a root-level Config object. Internally it then applied a `withFallback(ConfigFactory.defaultReference(getClass.getClassLoader))` to this sub-config, which was ineffective since the defaultReference supplies a root-level config (we were mixing a root-level config into a sub-config). This patch fixes this problem by moving sub-config selection from the first overload into the second. It also improves DRYness by factoring out common logic into a new superclass `SettingsCompanion` and adds another convenience `apply` overload for settings overrides given as a String. Even though the public API in terms of method signatures is not changed by this patch the semantics of the parameter on the second overload change, thereby breaking all code that uses it.
- Loading branch information...
Showing with 159 additions and 168 deletions.
- +11 −17 site/src/main/scala/spray/site/SiteSettings.scala
- +1 −1 spray-can-tests/src/test/scala/spray/can/TestSupport.scala
- +2 −1 spray-can-tests/src/test/scala/spray/can/server/SprayCanServerSpec.scala
- +13 −21 spray-can/src/main/scala/spray/can/client/ClientConnectionSettings.scala
- +8 −15 spray-can/src/main/scala/spray/can/client/HostConnectorSettings.scala
- +15 −23 spray-can/src/main/scala/spray/can/parsing/ParserSettings.scala
- +35 −36 spray-can/src/main/scala/spray/can/server/ServerSettings.scala
- +10 −16 spray-routing/src/main/scala/spray/routing/RoutingSettings.scala
- +11 −18 spray-servlet/src/main/scala/spray/servlet/ConnectorSettings.scala
- +37 −0 spray-util/src/main/scala/spray/util/SettingsCompanion.scala
- +7 −15 spray-util/src/main/scala/spray/util/UtilSettings.scala
- +2 −3 spray-util/src/main/scala/spray/util/Utils.scala
- +7 −2 spray-util/src/main/scala/spray/util/pimps/PimpedConfig.scala
Oops, something went wrong.