Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

which one is called first Activate function or bind function in SCR Runtime

I was confused with the order that which function Activate function or bind function gets called when component become active. In my opinion activate function function will be called first as Bind function is for binding the service. But as we know that all the target service are first get into the component context then component gets activated.

Please clear my doubt.

like image 471
Sanjeev Shukla Avatar asked Apr 03 '13 08:04

Sanjeev Shukla


1 Answers

The activate method will be called after all the static references have been bound, i.e. after the bind methods have been called. So during the activate, you can be sure that the value of the static references will not change.

However for dynamic references, all bets are off. In fact the value of a dynamic reference could change multiple times in different threads, during the execution of the activate method.

UPDATE: You didn't ask about deactivation, but you might find this information useful all the same. The deactivate method will be called before any static reference is unbound. So for example: if you were bound to a service with a static reference and the service you were bound to goes away, then SCR will first call your deactivate, then your unbind method(s), and finally it will free the component instance for garbage collection.

like image 195
Neil Bartlett Avatar answered Nov 15 '22 07:11

Neil Bartlett