diff --git a/akka-actor/src/main/scala/akka/routing/Routing.scala b/akka-actor/src/main/scala/akka/routing/Routing.scala index 2b4502430f..4556cbc90c 100644 --- a/akka-actor/src/main/scala/akka/routing/Routing.scala +++ b/akka-actor/src/main/scala/akka/routing/Routing.scala @@ -5,12 +5,12 @@ package akka.routing import language.implicitConversions import language.postfixOps + import akka.actor._ import scala.concurrent.util.Duration import scala.concurrent.util.duration._ import akka.ConfigurationException import akka.pattern.pipe -import akka.pattern.pipe import com.typesafe.config.Config import scala.collection.JavaConversions.iterableAsScalaIterable import java.util.concurrent.atomic.{ AtomicLong, AtomicBoolean } @@ -19,7 +19,6 @@ import scala.concurrent.forkjoin.ThreadLocalRandom import akka.dispatch.Dispatchers import scala.annotation.tailrec import concurrent.ExecutionContext -import akka.dispatch.MessageDispatcher /** * A RoutedActorRef is an ActorRef that has a set of connected ActorRef and it uses a Router to @@ -46,7 +45,7 @@ private[akka] class RoutedActorCell(_system: ActorSystemImpl, _ref: InternalActo _system, _ref, _props.copy(creator = () ⇒ _props.routerConfig.createActor(), dispatcher = _props.routerConfig.routerDispatcher), - _supervisor) with RouterContext { + _supervisor) { private[akka] val routerConfig = _props.routerConfig private[akka] val resizeInProgress = new AtomicBoolean @@ -141,27 +140,6 @@ private[akka] class RoutedActorCell(_system: ActorSystemImpl, _ref: InternalActo } } -/** - * Contextual information for [[akka.routing.RouterConfig]] - * [[akka.routing.RouteeProvider]] - * It's a subset of [[akka.actor.ActorContext]]. - */ -trait RouterContext { - - def system: ActorSystem - - def self: ActorRef - - implicit def dispatcher: MessageDispatcher - - def actorOf(props: Props): ActorRef - - def actorOf(props: Props, name: String): ActorRef - - def actorFor(path: String): ActorRef - -} - /** * This trait represents a router factory: it produces the actual router actor * and creates the routing table (a function which determines the recipients @@ -184,7 +162,7 @@ trait RouterConfig { def createRoute(routeeProvider: RouteeProvider): Route - def createRouteeProvider(context: RouterContext, routeeProps: Props): RouteeProvider = + def createRouteeProvider(context: ActorContext, routeeProps: Props): RouteeProvider = new RouteeProvider(context, routeeProps, resizer) def createActor(): Router = new Router { @@ -227,7 +205,7 @@ trait RouterConfig { * Uses `context.actorOf` to create routees from nrOfInstances property * and `context.actorFor` lookup routees from paths. */ -class RouteeProvider(val context: RouterContext, val routeeProps: Props, val resizer: Option[Resizer]) { +class RouteeProvider(val context: ActorContext, val routeeProps: Props, val resizer: Option[Resizer]) { /** * Adds the routees to the router. diff --git a/akka-cluster/src/main/scala/akka/cluster/routing/ClusterRouterConfig.scala b/akka-cluster/src/main/scala/akka/cluster/routing/ClusterRouterConfig.scala index ff7875a050..eb21958b8e 100644 --- a/akka-cluster/src/main/scala/akka/cluster/routing/ClusterRouterConfig.scala +++ b/akka-cluster/src/main/scala/akka/cluster/routing/ClusterRouterConfig.scala @@ -9,6 +9,8 @@ import scala.collection.immutable.SortedSet import com.typesafe.config.ConfigFactory import akka.ConfigurationException +import akka.actor.Actor +import akka.actor.ActorContext import akka.actor.ActorRef import akka.actor.ActorSystemImpl import akka.actor.Address @@ -27,7 +29,6 @@ import akka.routing.Route import akka.routing.RouteeProvider import akka.routing.Router import akka.routing.RouterConfig -import akka.routing.RouterContext /** * [[akka.routing.RouterConfig]] implementation for deployment on cluster nodes. @@ -37,7 +38,7 @@ import akka.routing.RouterContext */ case class ClusterRouterConfig(local: RouterConfig, totalInstances: Int, maxInstancesPerNode: Int) extends RouterConfig { - override def createRouteeProvider(context: RouterContext, routeeProps: Props) = + override def createRouteeProvider(context: ActorContext, routeeProps: Props) = new ClusterRouteeProvider(context, routeeProps, resizer, totalInstances, maxInstancesPerNode) override def createRoute(routeeProvider: RouteeProvider): Route = { @@ -70,7 +71,7 @@ case class ClusterRouterConfig(local: RouterConfig, totalInstances: Int, maxInst * Deploys new routees on the cluster nodes. */ private[akka] class ClusterRouteeProvider( - _context: RouterContext, + _context: ActorContext, _routeeProps: Props, _resizer: Option[Resizer], totalInstances: Int, diff --git a/akka-remote/src/main/scala/akka/routing/RemoteRouterConfig.scala b/akka-remote/src/main/scala/akka/routing/RemoteRouterConfig.scala index f0c0f10cdd..183ba66beb 100644 --- a/akka-remote/src/main/scala/akka/routing/RemoteRouterConfig.scala +++ b/akka-remote/src/main/scala/akka/routing/RemoteRouterConfig.scala @@ -4,6 +4,7 @@ package akka.routing import com.typesafe.config.ConfigFactory +import akka.actor.ActorContext import akka.actor.ActorRef import akka.actor.ActorSystemImpl import akka.actor.Deploy @@ -28,7 +29,7 @@ case class RemoteRouterConfig(local: RouterConfig, nodes: Iterable[Address]) ext def this(local: RouterConfig, nodes: java.lang.Iterable[Address]) = this(local, nodes.asScala) def this(local: RouterConfig, nodes: Array[Address]) = this(local, nodes: Iterable[Address]) - override def createRouteeProvider(context: RouterContext, routeeProps: Props) = + override def createRouteeProvider(context: ActorContext, routeeProps: Props) = new RemoteRouteeProvider(nodes, context, routeeProps, resizer) override def createRoute(routeeProvider: RouteeProvider): Route = { @@ -55,7 +56,7 @@ case class RemoteRouterConfig(local: RouterConfig, nodes: Iterable[Address]) ext * * Routee paths may not be combined with remote target nodes. */ -class RemoteRouteeProvider(nodes: Iterable[Address], _context: RouterContext, _routeeProps: Props, _resizer: Option[Resizer]) +class RemoteRouteeProvider(nodes: Iterable[Address], _context: ActorContext, _routeeProps: Props, _resizer: Option[Resizer]) extends RouteeProvider(_context, _routeeProps, _resizer) { if (nodes.isEmpty) throw new ConfigurationException("Must specify list of remote target.nodes for [%s]"