mulesoft/mule — pull request #249 by marianogonzalez (2013-12-23 20:52:00+00:00)
Title: MULE-7017: Making sure that bootstrap lines are read in order to have co...

...mponents added into the registry in order.

As explained in MULE-7017, Mule currently has an issue with its bootstrap in which each registered object is applied its full lifecycle in the very moment it's registered, while expected behavior would be to have lifecycle applied only once all objects have been registered.

This issue makes it quite difficult for any given component to use its initialise() method to fetch a dependency from the registry, since there's no guarantee of which component was loaded first.

Unfortunately, this issue cannot be easily fixed before Mule 4.

This issue has other implications. Even if we were willing to accept that there's no guarantee that module A is bootstrapped before module B, any module A or B has no guarantee between its own components. That's because each line in a bootstrap.properties is loaded into a HashTable. That means that right now your code can rely on component C1 being registered before component C2, but any future changes in any of those components might change the classes' hash codes in a way that C1 is no longer initialised before C2. It also makes the line orders in each bootstrap file irrelevant which is confusing.

Regardless of how lifecycle is managed at a context level, each module's component should be loaded in order and that's what this pull request does