diff --git a/akka-rest/src/main/scala/ActorComponentProvider.scala b/akka-rest/src/main/scala/ActorComponentProvider.scala index 5d9d49bef2..c1d8029425 100644 --- a/akka-rest/src/main/scala/ActorComponentProvider.scala +++ b/akka-rest/src/main/scala/ActorComponentProvider.scala @@ -9,19 +9,21 @@ import com.sun.jersey.core.spi.component.ioc.IoCFullyManagedComponentProvider import se.scalablesolutions.akka.config.Configurator import se.scalablesolutions.akka.util.Logging +import se.scalablesolutions.akka.actor.Actor class ActorComponentProvider(val clazz: Class[_], val configurators: List[Configurator]) extends IoCFullyManagedComponentProvider with Logging { override def getScope = ComponentScope.Singleton - override def getInstance: AnyRef = { + override def getInstance: Actor = { val instances = for { conf <- configurators if conf.isDefined(clazz) - } yield conf.getInstance(clazz).asInstanceOf[AnyRef] + instance <- conf.getInstance(clazz) + } yield instance instances match { - case instance :: Nil => instance + 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.") }