JBotSim
JBotSim copied to clipboard
Initialization callback creation
We are considering adding an initialization callback (at least) on the Node class.
This callback would be called before the onStart callback. Its content would be in charge of initializing the node's state, possibly avoiding the necessity of "startAndPause" trick.
Note: This issue is created partly in order to keep track of discussions.
I have made an implementation proposition on feature/56-initialization-method.
What's in it:
Topology.initialize()added It is automatically called byTopology.start()if needed.InitializationListenercreatedInitializationListener.onInit()is meant to be called after theTopology's initialization- As for the other listeners, it has been added to the
Topology
Node.onInit()added It is meant to be called after theTopology's initialization.TopologyLifeCycleUT added to specify the basics of the topology's life cycle- A
MainInitexample has been provided
This is still modifiable.
@acasteigts , following the discussion in my office:
Topology.initialize()does not setisStartedback tofalseanymore.- removing the
new ArrayList(...)copies when notifying listeners in the hope of speeding things a bit actually raisedConcurrentModificationExceptions. I have addedio.jbotsim.core.XXXListenerTestsclasses intest-classes(thus needing to be run manually) to tests the associated behaviors. - I have put in a separate commit the fact that you have a strong doubt on the fact that we can switch notifying the listeners that a
Nodehas been added and notifying theNodethat the topology has been initialized/started.
- rebased over #85 and #86
- take latest modifications into account