-
Notifications
You must be signed in to change notification settings - Fork 1
Properties Sequence
laforge49 edited this page Sep 9, 2011
·
4 revisions
Systems and subsystems can, as we have seen, be configured using properties. The PropertiesSeq message, when sent to a SystemsContext which supports properties, returns a sequence over the properties specific to it.
First, a test driver.
case class DoIt()
class Driver extends Actor {
bind(classOf[DoIt], doIt)
def doIt(msg: AnyRef, rf: Any => Unit) {
systemServices(PropertiesSeq()) {
rsp1 => {
val seq = rsp1.asInstanceOf[Sequence[String, String]]
seq(Loop((key: String, value: String) => println(key+" -> "+value))) {
rsp2 => rf(null)
}
}
}
}
}
Now the test code.
val p1 = new Properties
p1.put("a", "1")
p1.put("b", "2")
p1.put("c", "3")
val systemServices = SystemServices(new PropertiesComponentFactory, properties = p1)
val p2 = new Properties
p2.put("b", null)
p2.put("c", "11")
p2.put("d", "12")
val aSubsystem = Subsystem(systemServices, new PropertiesComponentFactory, properties = p2)
val driver = new Driver
driver.setSystemServices(aSubsystem)
Future(driver, DoIt())
Output.
b -> null
c -> 11
d -> 12