fixed bug in REST module

This commit is contained in:
Jonas Bonér 2010-03-22 00:01:46 +01:00
parent 919e1e3a30
commit c2bfb4c0c6

View file

@ -16,16 +16,14 @@ class ActorComponentProvider(val clazz: Class[_], val configurators: List[Config
override def getScope = ComponentScope.Singleton
override def getInstance: Actor = {
override def getInstance: AnyRef = {
val instances = for {
conf <- configurators
if conf.isDefined(clazz)
instance <- conf.getInstance(clazz)
} yield instance
instances match {
case (instance : Actor) :: Nil => instance
case Nil => throw new IllegalArgumentException("No Actor for class [" + clazz + "] could be found. Make sure you have defined and configured the class as an Active Object or Actor in a Configurator")
case _ => throw new IllegalArgumentException("Actor for class [" + clazz + "] is defined in more than one Configurator. Eliminate the redundancy.")
}
if (instances.isEmpty) throw new IllegalArgumentException(
"No Actor or Active Object for class [" + clazz + "] could be found.\nMake sure you have defined and configured the class as an Active Object or Actor in a supervisor hierarchy.")
else instances.head.asInstanceOf[AnyRef]
}
}