From db446cc6094b51d244eddc563f8a96aa82de8647 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 2 Feb 2010 23:23:37 +0100 Subject: [PATCH] Cleaned up cluster instantiation --- akka-core/src/main/scala/remote/Cluster.scala | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/akka-core/src/main/scala/remote/Cluster.scala b/akka-core/src/main/scala/remote/Cluster.scala index f355cf5ced..4df15f6f97 100644 --- a/akka-core/src/main/scala/remote/Cluster.scala +++ b/akka-core/src/main/scala/remote/Cluster.scala @@ -199,17 +199,23 @@ abstract class BasicClusterActor extends ClusterActor { * Loads a specified ClusterActor and delegates to that instance. */ object Cluster extends Cluster with Logging { - private[remote] val clusterActor: Option[ClusterActor] = { - val name = config.getString("akka.remote.cluster.actor","not defined") - try { - val a = Class.forName(name).newInstance.asInstanceOf[ClusterActor] + + private[remote] val actorName = config.getString("akka.remote.cluster.actor") + + private[remote] val clusterActor = createClusterActor + + private[remote] def createClusterActor : Option[ClusterActor] = { + try { + actorName map { s => + val a = Class.forName(s).newInstance.asInstanceOf[ClusterActor] a.start - Some(a) - } - catch { - case e => log.error(e,"Couldn't load Cluster provider: [%s]",name) - None + a } + } + catch { + case e => log.error(e,"Couldn't load Cluster provider: [%s]",actorName.getOrElse("")) + None + } } private[remote] val supervisor: Option[Supervisor] = if (clusterActor.isDefined) {