Modify SettingsCompanion to support create using ActorSystem (#20845)
- Remove final modifier from create(system: ActorSystem) within SettingsCompanion - Implement create(system: ActorSystem) within each of the SettingsCompanion subclass - Add tests to ensure compilation
This commit is contained in:
parent
29dec00c45
commit
334959edd1
11 changed files with 114 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ package akka.http.javadsl.settings
|
|||
|
||||
import java.util.{ Optional, Random }
|
||||
|
||||
import akka.actor.ActorSystem
|
||||
import akka.http.impl.settings.ClientConnectionSettingsImpl
|
||||
import akka.http.javadsl.model.headers.UserAgent
|
||||
import akka.io.Inet.SocketOption
|
||||
|
|
@ -42,4 +43,5 @@ abstract class ClientConnectionSettings private[akka] () { self: ClientConnectio
|
|||
object ClientConnectionSettings extends SettingsCompanion[ClientConnectionSettings] {
|
||||
def create(config: Config): ClientConnectionSettings = ClientConnectionSettingsImpl(config)
|
||||
def create(configOverrides: String): ClientConnectionSettings = ClientConnectionSettingsImpl(configOverrides)
|
||||
override def create(system: ActorSystem): ClientConnectionSettings = create(system.settings.config)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package akka.http.javadsl.settings
|
||||
|
||||
import akka.actor.ActorSystem
|
||||
import akka.http.impl.settings.ConnectionPoolSettingsImpl
|
||||
import com.typesafe.config.Config
|
||||
|
||||
|
|
@ -34,4 +35,5 @@ abstract class ConnectionPoolSettings private[akka] () { self: ConnectionPoolSet
|
|||
object ConnectionPoolSettings extends SettingsCompanion[ConnectionPoolSettings] {
|
||||
override def create(config: Config): ConnectionPoolSettings = ConnectionPoolSettingsImpl(config)
|
||||
override def create(configOverrides: String): ConnectionPoolSettings = ConnectionPoolSettingsImpl(configOverrides)
|
||||
override def create(system: ActorSystem): ConnectionPoolSettings = create(system.settings.config)
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ package akka.http.javadsl.settings
|
|||
|
||||
import java.util.Optional
|
||||
|
||||
import akka.actor.ActorSystem
|
||||
import akka.http.impl.engine.parsing.BodyPartParser
|
||||
import akka.http.impl.settings.ParserSettingsImpl
|
||||
import java.{ util ⇒ ju }
|
||||
|
|
@ -83,4 +84,5 @@ object ParserSettings extends SettingsCompanion[ParserSettings] {
|
|||
|
||||
override def create(config: Config): ParserSettings = ParserSettingsImpl(config)
|
||||
override def create(configOverrides: String): ParserSettings = ParserSettingsImpl(configOverrides)
|
||||
override def create(system: ActorSystem): ParserSettings = create(system.settings.config)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package akka.http.javadsl.settings
|
||||
|
||||
import akka.actor.ActorSystem
|
||||
import akka.http.impl.settings.RoutingSettingsImpl
|
||||
import com.typesafe.config.Config
|
||||
|
||||
|
|
@ -30,4 +31,5 @@ abstract class RoutingSettings private[akka] () { self: RoutingSettingsImpl ⇒
|
|||
object RoutingSettings extends SettingsCompanion[RoutingSettings] {
|
||||
override def create(config: Config): RoutingSettings = RoutingSettingsImpl(config)
|
||||
override def create(configOverrides: String): RoutingSettings = RoutingSettingsImpl(configOverrides)
|
||||
override def create(system: ActorSystem): RoutingSettings = create(system.settings.config)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ package akka.http.javadsl.settings
|
|||
|
||||
import java.util.{ Optional, Random }
|
||||
|
||||
import akka.actor.ActorSystem
|
||||
import akka.http.impl.settings.ServerSettingsImpl
|
||||
import akka.http.javadsl.model.headers.Host
|
||||
import akka.http.javadsl.model.headers.Server
|
||||
|
|
@ -71,4 +72,5 @@ object ServerSettings extends SettingsCompanion[ServerSettings] {
|
|||
|
||||
override def create(config: Config): ServerSettings = ServerSettingsImpl(config)
|
||||
override def create(configOverrides: String): ServerSettings = ServerSettingsImpl(configOverrides)
|
||||
override def create(system: ActorSystem): ServerSettings = create(system.settings.config)
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ trait SettingsCompanion[T] {
|
|||
*
|
||||
* Java API
|
||||
*/
|
||||
final def create(system: ActorSystem): T = create(system.settings.config)
|
||||
def create(system: ActorSystem): T = create(system.settings.config)
|
||||
|
||||
/**
|
||||
* Creates an instance of settings using the given Config.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.http.javadsl.settings;
|
||||
|
||||
import akka.actor.ActorSystem;
|
||||
import org.junit.Test;
|
||||
import org.scalatest.junit.JUnitSuite;
|
||||
|
||||
public class ClientConnectionSettingsTest extends JUnitSuite {
|
||||
|
||||
@Test
|
||||
public void testCreateWithActorSystem() {
|
||||
ActorSystem sys = ActorSystem.create("test");
|
||||
ClientConnectionSettings settings = ClientConnectionSettings.create(sys);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.http.javadsl.settings;
|
||||
|
||||
import akka.actor.ActorSystem;
|
||||
import org.junit.Test;
|
||||
import org.scalatest.junit.JUnitSuite;
|
||||
|
||||
public class ConnectionPoolSettingsTest extends JUnitSuite {
|
||||
|
||||
@Test
|
||||
public void testCreateWithActorSystem() {
|
||||
ActorSystem sys = ActorSystem.create("test");
|
||||
ConnectionPoolSettings settings = ConnectionPoolSettings.create(sys);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.http.javadsl.settings;
|
||||
|
||||
import akka.actor.ActorSystem;
|
||||
import org.junit.Test;
|
||||
import org.scalatest.junit.JUnitSuite;
|
||||
|
||||
public class ParserSettingsTest extends JUnitSuite {
|
||||
|
||||
@Test
|
||||
public void testCreateWithActorSystem() {
|
||||
ActorSystem sys = ActorSystem.create("test");
|
||||
ParserSettings settings = ParserSettings.create(sys);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.http.javadsl.settings;
|
||||
|
||||
import akka.actor.ActorSystem;
|
||||
import com.typesafe.config.Config;
|
||||
import com.typesafe.config.ConfigFactory;
|
||||
import org.junit.Test;
|
||||
import org.scalatest.junit.JUnitSuite;
|
||||
|
||||
public class RoutingSettingsTest extends JUnitSuite {
|
||||
|
||||
@Test
|
||||
public void testCreateWithActorSystem() {
|
||||
String testConfig =
|
||||
"akka.http.routing {\n" +
|
||||
" verbose-error-messages = off\n" +
|
||||
" file-get-conditional = on\n" +
|
||||
" render-vanity-footer = yes\n" +
|
||||
" range-coalescing-threshold = 80\n" +
|
||||
" range-count-limit = 16\n" +
|
||||
" decode-max-bytes-per-chunk = 1m\n" +
|
||||
" file-io-dispatcher = \"test-only\"\n" +
|
||||
"}";
|
||||
Config config = ConfigFactory.parseString(testConfig);
|
||||
ActorSystem sys = ActorSystem.create("test", config);
|
||||
RoutingSettings settings = RoutingSettings.create(sys);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.http.javadsl.settings;
|
||||
|
||||
import akka.actor.ActorSystem;
|
||||
import org.junit.Test;
|
||||
import org.scalatest.junit.JUnitSuite;
|
||||
|
||||
public class ServerSettingsTest extends JUnitSuite {
|
||||
|
||||
@Test
|
||||
public void testCreateWithActorSystem() {
|
||||
ActorSystem sys = ActorSystem.create("test");
|
||||
ServerSettings settings = ServerSettings.create(sys);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue