From: Michal K. <mic...@gm...> - 2008-09-11 18:35:49
|
Peter C. Mehlitz wrote: > it doesn't have to be a static field. Your listeners are created > outside of JPF, so you can pass whatever shared object you want into > their constructors: > > .. > Config conf = JPF.createConfig(..) > SharedData shared = ... > Listener1 l1 = new Listener1(conf,..shared..); > Listener2 l2 = new Listener2(conf,..shared..); > JPF jpf = new JPF(conf); > jpf.addListener(l1); > jpf.addListener(l2); > jpf.run(); > .. > > A generic per-run object in the JPF instance wouldn't work because > Listeners shouldn't be forced to know about each other, and could > therefore easily compete for this field. That's clear. JPF listener (I won't need more than one) is ok, it is constructed in my code so I can pass whatever I want in its constructor. What is problem is JUnit listener called through native peers. Config object seems to be a good idea, thanks. > > So even if you need to share data between a native peer (static > methods) and a listener, this requires a per-run registry, and we > already have one - Config. You can stick whatever object you want in > there, it's just a Hashtable. Just make sure it doesn't contain a > conflicting key before you do so. > > -- Peter |