Added support for custom user-defined routers
This commit is contained in:
parent
e779690aa1
commit
d31057dacf
7 changed files with 49 additions and 36 deletions
|
|
@ -89,6 +89,24 @@ object Routing {
|
|||
if (clusteringEnabled && !props.localOnly) ReflectiveAccess.ClusterModule.newClusteredActorRef(props)
|
||||
else new RoutedActorRef(props, address)
|
||||
}
|
||||
|
||||
def createCustomRouter(implClass: String): Router = {
|
||||
ReflectiveAccess.createInstance(
|
||||
implClass,
|
||||
Array[Class[_]](),
|
||||
Array[AnyRef]()) match {
|
||||
case Right(router) ⇒ router.asInstanceOf[Router]
|
||||
case Left(exception) ⇒
|
||||
val cause = exception match {
|
||||
case i: InvocationTargetException ⇒ i.getTargetException
|
||||
case _ ⇒ exception
|
||||
}
|
||||
throw new ConfigurationException(
|
||||
"Could not instantiate custom Router of [" +
|
||||
implClass + "] due to: " +
|
||||
cause, cause)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue