Back porting wyclif's fix for:
ModuleActivator.started()/.contextRefreshed() not called when module is
stopped/restarted or newly uploaded - TRUNK-4134(cherry picked from commit 23e3a63560ebcd529d664b163ea511e45443ac2c)
Fixed compilation issues - TRUNK-4402