osgi - Lazy activation of Eclipse plugins -


i know "activate plug-in when 1 of classes loaded" check-box in eclipse manifest editor useful for.

i thought eclipse use "lazy initialization" approach. have option relation bundleactivator class of plugin? initialization different activation?

here similar question, don't understand entirely.

ticking box causes following header set in manifest:

bundle-activationpolicy: lazy 

i'll start how "pure" osgi deals this. if bundle started start_activation_policy flag bundle enters starting state activator's start() method not invoked , classloader not allocated bundle. bundle stays in starting until, whatever reason, class needs loaded bundle. @ point classloader allocated , activator (if any) instantiated , start() method invoked before requested class loaded.

however eclipse layers additional semantics on top. background, eclipse tries avoid starting bundles in order keep start-up time minimal. small core set of bundles started default (the list in configuration/config.ini) , 1 of these called p2 "simpleconfigurator". simpleconfigurator looks bundles have bundle-activationpolicy:lazy header , starts them start_activation_policy flag... therefore these bundles "lazily" started described above.

the important point all other bundles not contain header will not started @ all under eclipse. stay in resolved state, activators not invoked, , if contain declarative services component not loaded. because declarative services ever looks @ bundles in active or starting state.

therefore main reason use header if want write bundle containing declarative services components need work under eclipse.

in other environments there no need use header. normal osgi apps start bundles, rather trying selectively start subset of bundles. note doesn't mean osgi apps don't worry lazy loading! declarative services supports lazy loading without messing around bundle class loading triggers. in opinion eclipse gets wrong , has added unnecessary complexity bundle lifecycle. nevertheless if running in eclipse have no choice understand , work limitation.


Comments