Fixing akka-rest breakage from Configurator.getInstance
This commit is contained in:
parent
7f7a0485b2
commit
aef25b7517
1 changed files with 5 additions and 3 deletions
|
|
@ -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.")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue