Move name parameter to 2nd pos. in typed system factories (#23244)

This commit is contained in:
Heiko Seeberger 2017-07-04 09:13:51 +02:00 committed by Johan Andrén
parent e6c2d3f550
commit ba3f6a6c14
10 changed files with 44 additions and 38 deletions

View file

@ -43,8 +43,8 @@ public class ExtensionsTest extends JUnitSuite {
@Test
public void loadJavaExtensionsFromConfig() {
final ActorSystem<Object> system = ActorSystem.create(
"loadJavaExtensionsFromConfig",
Behavior.empty(),
"loadJavaExtensionsFromConfig",
Optional.empty(),
Optional.of(ConfigFactory.parseString("akka.typed.extensions += \"akka.typed.ExtensionsTest$MyExtension\"").resolve()),
Optional.empty(),
@ -66,7 +66,7 @@ public class ExtensionsTest extends JUnitSuite {
@Test
public void loadScalaExtension() {
final ActorSystem<Object> system = ActorSystem.create("loadScalaExtension", Behavior.empty());
final ActorSystem<Object> system = ActorSystem.create(Behavior.empty(), "loadScalaExtension");
try {
DummyExtension1 instance1 = DummyExtension1.get(system);
DummyExtension1 instance2 = DummyExtension1.get(system);

View file

@ -45,7 +45,7 @@ public class ActorCompile {
Behavior<MyMsg> actor9 = widened(actor7, pf -> pf.match(MyMsgA.class, x -> x));
Behavior<MyMsg> actor10 = immutable((ctx, msg) -> stopped(actor4), (ctx, signal) -> same());
ActorSystem<MyMsg> system = ActorSystem.create("Sys", actor1);
ActorSystem<MyMsg> system = ActorSystem.create(actor1, "Sys");
{
Actor.<MyMsg>immutable((ctx, msg) -> {

View file

@ -70,7 +70,7 @@ public class WatchTest extends JUnitSuite {
watched.tell(new Stop());
return waitingForTermination(msg.replyTo);
});
ActorSystem<RunTest<Done>> system = ActorSystem.create("sysname", root);
ActorSystem<RunTest<Done>> system = ActorSystem.create(root, "sysname");
try {
// Not sure why this does not compile without an explicit cast?
// system.tell(new RunTest());
@ -93,7 +93,7 @@ public class WatchTest extends JUnitSuite {
return unhandled();
}
});
ActorSystem<Message> system = ActorSystem.create("sysname", root);
ActorSystem<Message> system = ActorSystem.create(root, "sysname");
try {
// Not sure why this does not compile without an explicit cast?
// system.tell(new RunTest());

View file

@ -58,7 +58,7 @@ public class IntroTest {
public static void main(String[] args) {
//#hello-world
final ActorSystem<HelloWorld.Greet> system =
ActorSystem.create("hello", HelloWorld.greeter);
ActorSystem.create(HelloWorld.greeter, "hello");
final CompletionStage<HelloWorld.Greeted> reply =
AskPattern.ask(system,
@ -198,7 +198,7 @@ public class IntroTest {
});
final ActorSystem<Void> system =
ActorSystem.create("ChatRoomDemo", main);
ActorSystem.create(main, "ChatRoomDemo");
Await.result(system.whenTerminated(), Duration.create(3, TimeUnit.SECONDS));
//#chatroom-main

View file

@ -95,7 +95,7 @@ class ExtensionsSpec extends TypedSpecSetup {
def `04 handle extensions that fail to initialize`(): Unit = {
def create(): Unit = {
ActorSystem[Any]("ExtensionsSpec04", Behavior.EmptyBehavior, config = Some(ConfigFactory.parseString(
ActorSystem[Any](Behavior.EmptyBehavior, "ExtensionsSpec04", config = Some(ConfigFactory.parseString(
"""
akka.typed.extensions = ["akka.typed.FailingToLoadExtension$"]
""")))
@ -153,7 +153,7 @@ class ExtensionsSpec extends TypedSpecSetup {
}
def withEmptyActorSystem[T](name: String, config: Option[Config] = None)(f: ActorSystem[_] T): T = {
val system = ActorSystem[Any](name, Behavior.EmptyBehavior, config = config)
val system = ActorSystem[Any](Behavior.EmptyBehavior, name, config = config)
try f(system) finally system.terminate().futureValue
}

View file

@ -60,7 +60,7 @@ abstract class TypedSpec(val config: Config) extends TypedSpecSetup {
private var nativeSystemUsed = false
lazy val nativeSystem: ActorSystem[TypedSpec.Command] = {
val sys = ActorSystem(AkkaSpec.getCallerName(classOf[TypedSpec]), guardian(), config = Some(config withFallback AkkaSpec.testConf))
val sys = ActorSystem(guardian(), AkkaSpec.getCallerName(classOf[TypedSpec]), config = Some(config withFallback AkkaSpec.testConf))
nativeSystemUsed = true
sys
}

View file

@ -26,11 +26,11 @@ class ActorSystemSpec extends Spec with Matchers with BeforeAndAfterAll with Sca
case class Probe(msg: String, replyTo: ActorRef[String])
trait CommonTests {
def system[T](name: String, behavior: Behavior[T]): ActorSystem[T]
def system[T](behavior: Behavior[T], name: String): ActorSystem[T]
def suite: String
def withSystem[T](name: String, behavior: Behavior[T], doTerminate: Boolean = true)(block: ActorSystem[T] Unit): Terminated = {
val sys = system(s"$suite-$name", behavior)
val sys = system(behavior, s"$suite-$name")
try {
block(sys)
if (doTerminate) sys.terminate().futureValue else sys.whenTerminated.futureValue
@ -55,13 +55,15 @@ class ActorSystemSpec extends Spec with Matchers with BeforeAndAfterAll with Sca
def `must terminate the guardian actor`(): Unit = {
val inbox = Inbox[String]("terminate")
val sys = system("terminate", immutable[Probe] {
val sys = system(
immutable[Probe] {
case (_, _) unhandled
} onSignal {
case (ctx, PostStop)
inbox.ref ! "done"
same
})
},
"terminate")
sys.terminate().futureValue
inbox.receiveAll() should ===("done" :: Nil)
}
@ -98,7 +100,7 @@ class ActorSystemSpec extends Spec with Matchers with BeforeAndAfterAll with Sca
}
object `An ActorSystemImpl` extends CommonTests {
def system[T](name: String, behavior: Behavior[T]): ActorSystem[T] = ActorSystem(name, behavior)
def system[T](behavior: Behavior[T], name: String) = ActorSystem(behavior, name)
def suite = "native"
// this is essential to complete ActorCellSpec, see there
@ -133,7 +135,7 @@ class ActorSystemSpec extends Spec with Matchers with BeforeAndAfterAll with Sca
}
object `An ActorSystemAdapter` extends CommonTests {
def system[T](name: String, behavior: Behavior[T]): ActorSystem[T] = ActorSystem.adapter(name, behavior)
def system[T](behavior: Behavior[T], name: String) = ActorSystem.adapter(name, behavior)
def suite = "adapter"
}
}

View file

@ -83,7 +83,7 @@ class IntroSpec extends TypedSpec {
// using global pool since we want to run tasks after system.terminate
import scala.concurrent.ExecutionContext.Implicits.global
val system: ActorSystem[Greet] = ActorSystem("hello", greeter)
val system: ActorSystem[Greet] = ActorSystem(greeter, "hello")
val future: Future[Greeted] = system ? (Greet("world", _))
@ -133,7 +133,7 @@ class IntroSpec extends TypedSpec {
}
}
val system = ActorSystem("ChatRoomDemo", main)
val system = ActorSystem(main, "ChatRoomDemo")
Await.result(system.whenTerminated, 3.seconds)
//#chatroom-main
}

View file

@ -105,7 +105,7 @@ class MutableIntroSpec extends TypedSpec {
}
}
val system = ActorSystem("ChatRoomDemo", main)
val system = ActorSystem(main, "ChatRoomDemo")
Await.result(system.whenTerminated, 1.second)
//#chatroom-main
}

View file

@ -159,7 +159,9 @@ object ActorSystem {
* Akka Typed [[Behavior]] hierarchiesthis system cannot run untyped
* [[akka.actor.Actor]] instances.
*/
def apply[T](name: String, guardianBehavior: Behavior[T],
def apply[T](
guardianBehavior: Behavior[T],
name: String,
guardianProps: Props = Props.empty,
config: Option[Config] = None,
classLoader: Option[ClassLoader] = None,
@ -175,13 +177,15 @@ object ActorSystem {
* Akka Typed [[Behavior]] hierarchiesthis system cannot run untyped
* [[akka.actor.Actor]] instances.
*/
def create[T](name: String, guardianBehavior: Behavior[T],
def create[T](
guardianBehavior: Behavior[T],
name: String,
guardianProps: Optional[Props],
config: Optional[Config],
classLoader: Optional[ClassLoader],
executionContext: Optional[ExecutionContext]): ActorSystem[T] = {
import scala.compat.java8.OptionConverters._
apply(name, guardianBehavior, guardianProps.asScala.getOrElse(EmptyProps), config.asScala, classLoader.asScala, executionContext.asScala)
apply(guardianBehavior, name, guardianProps.asScala.getOrElse(EmptyProps), config.asScala, classLoader.asScala, executionContext.asScala)
}
/**
@ -189,8 +193,8 @@ object ActorSystem {
* Akka Typed [[Behavior]] hierarchiesthis system cannot run untyped
* [[akka.actor.Actor]] instances.
*/
def create[T](name: String, guardianBehavior: Behavior[T]): ActorSystem[T] =
apply(name, guardianBehavior)
def create[T](guardianBehavior: Behavior[T], name: String): ActorSystem[T] =
apply(guardianBehavior, name)
/**
* Create an ActorSystem based on the untyped [[akka.actor.ActorSystem]]