parameter in config file

30 views
Skip to first unread message

tobias amft

unread,
Nov 25, 2013, 7:02:55 AM11/25/13
to peerfac...@googlegroups.com
Hi,

currently I am implementing an own analyzer in PeerfactSim. I know that the analyser class has to be declared in the xml config file of the experiment. e.g.:
<Analyzer class="org.peerfact.impl.overlay.dht.chord.chord.analyzer.myAnalyzer" />.

My question now is:
how can one hand over parameter to the class?

e.g.:
<Analyzer
    class="org.peerfact.impl.overlay.dht.chord.chord.analyzer.myAnalyzer"
    param1 = "..."
    param2 = "..."
/>

Is it possible to reach the variables directly if param1 and param2 are declared public in my analyzer class?
Or do I have to use getter/setter methods?
Or  do I have to change the Scenario Builder or something like that?

best regards
Tobi


Philipp Giesen

unread,
Nov 25, 2013, 8:15:00 AM11/25/13
to peerfac...@googlegroups.com
Hey Tobias,

yes, setter-methods are the way to go. For each parameter you add in the config file, the engine searches for a setter-method within the class specified. In your example, you would have to add a method setParam1(<typeOfParameter>). param1 and param2 would be declared private in your class but are modified via the setter-methods anyway.

This works for the host builder and should also work for analyzers. Quite simple. :-)

regards,
Philipp

tobias amft

unread,
Nov 25, 2013, 8:33:59 AM11/25/13
to peerfac...@googlegroups.com
Thanks for your quick answer,

you are such an educated person ...
I wish i had your knowledge ;)

regards Tobi
Reply all
Reply to author
Forward
0 new messages