Cleanup of TestActorRef constructor, see #2728

* Don't expose internal classes in public constructor
This commit is contained in:
Patrik Nordwall 2013-04-08 12:02:21 +02:00
parent 90905907c5
commit 9bf46e476c
3 changed files with 10 additions and 11 deletions

View file

@ -82,11 +82,10 @@ Due to a limitation in Scalas type inference, there is only the factory metho
shown above, so you will probably write code like ``TestFSMRef(new MyFSM)`` shown above, so you will probably write code like ``TestFSMRef(new MyFSM)``
instead of the hypothetical :class:`ActorRef`-inspired ``TestFSMRef[MyFSM]``. instead of the hypothetical :class:`ActorRef`-inspired ``TestFSMRef[MyFSM]``.
All methods shown above directly access the FSM state without any All methods shown above directly access the FSM state without any
synchronization; this is perfectly alright if the synchronization; this is perfectly alright if the :class:`CallingThreadDispatcher`
:class:`CallingThreadDispatcher` is used (which is the default for is used and no other threads are involved, but it may lead to surprises if you
:class:`TestFSMRef`) and no other threads are involved, but it may lead to were to actually exercise timer events, because those are executed on the
surprises if you were to actually exercise timer events, because those are :obj:`Scheduler` thread.
executed on the :obj:`Scheduler` thread.
Testing the Actor's Behavior Testing the Actor's Behavior
---------------------------- ----------------------------

View file

@ -19,10 +19,10 @@ import akka.pattern.ask
* @since 1.1 * @since 1.1
*/ */
class TestActorRef[T <: Actor]( class TestActorRef[T <: Actor](
_system: ActorSystemImpl, _system: ActorSystem,
_prerequisites: DispatcherPrerequisites, _prerequisites: DispatcherPrerequisites,
_props: Props, _props: Props,
_supervisor: InternalActorRef, _supervisor: ActorRef,
name: String) name: String)
extends { extends {
private val disregard = _supervisor match { private val disregard = _supervisor match {
@ -35,11 +35,11 @@ class TestActorRef[T <: Actor](
case s _system.log.error("trying to attach child {} to unknown type of supervisor {}, this is not going to end well", name, s.getClass) case s _system.log.error("trying to attach child {} to unknown type of supervisor {}, this is not going to end well", name, s.getClass)
} }
} with LocalActorRef( } with LocalActorRef(
_system, _system.asInstanceOf[ActorSystemImpl],
_props.withDispatcher( _props.withDispatcher(
if (_props.dispatcher == Dispatchers.DefaultDispatcherId) CallingThreadDispatcher.Id if (_props.dispatcher == Dispatchers.DefaultDispatcherId) CallingThreadDispatcher.Id
else _props.dispatcher), else _props.dispatcher),
_supervisor, _supervisor.asInstanceOf[InternalActorRef],
_supervisor.path / name) { _supervisor.path / name) {
// we need to start ourselves since the creation of an actor has been split into initialization and starting // we need to start ourselves since the creation of an actor has been split into initialization and starting

View file

@ -34,10 +34,10 @@ import scala.concurrent.duration.FiniteDuration
* @since 1.2 * @since 1.2
*/ */
class TestFSMRef[S, D, T <: Actor]( class TestFSMRef[S, D, T <: Actor](
system: ActorSystemImpl, system: ActorSystem,
_prerequisites: DispatcherPrerequisites, _prerequisites: DispatcherPrerequisites,
props: Props, props: Props,
supervisor: InternalActorRef, supervisor: ActorRef,
name: String)(implicit ev: T <:< FSM[S, D]) name: String)(implicit ev: T <:< FSM[S, D])
extends TestActorRef(system, _prerequisites, props, supervisor, name) { extends TestActorRef(system, _prerequisites, props, supervisor, name) {