Added utility method and another test
This commit is contained in:
parent
51d89c6d92
commit
d9fe236b2e
2 changed files with 12 additions and 1 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.dispatch
|
||||
|
|
@ -112,6 +112,13 @@ object Dispatchers extends Logging {
|
|||
*/
|
||||
def newThreadBasedDispatcher(actor: ActorRef) = new ThreadBasedDispatcher(actor)
|
||||
|
||||
/**
|
||||
* Utility function that tries to load the specified dispatcher config from the akka.conf
|
||||
* or else use the supplied default dispatcher
|
||||
*/
|
||||
def fromConfig(key: String, default: => MessageDispatcher = defaultGlobalDispatcher): MessageDispatcher =
|
||||
config.getConfigMap(key).flatMap(from).getOrElse(default)
|
||||
|
||||
/*
|
||||
* Creates of obtains a dispatcher from a ConfigMap according to the format below
|
||||
*
|
||||
|
|
|
|||
|
|
@ -67,4 +67,8 @@ class DispatchersSpec extends JUnitSuite {
|
|||
assert(typesAndValidators.forall( tuple => tuple._2(allDispatchers(tuple._1).get) ))
|
||||
}
|
||||
|
||||
@Test def defaultingToDefaultWhileLoadingTheDefaultShouldWork {
|
||||
assert(from(Config.fromMap(Map(tipe -> "Default"))).getOrElse(defaultGlobalDispatcher) == defaultGlobalDispatcher)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue