HannesWell commented on PR #1429:
URL: https://github.com/apache/logging-log4j2/pull/1429#issuecomment-1624092744

   > @HannesWell and @N1k145,
   > 
   > I don't work with OSGI on a daily basis, so I need time to setup a testing 
environment. Since Hannes confirms that this solution works, I guess I could 
skip this step.
   
   I have not yet tried out this explicit change, but I remember from that the 
past that I tried something similar (if not the same) already for the same 
reason.
   But I'll try this out with our projects tomorrow.
   
   > 
   > What happens if someone puts `log4j-core` in start level 1 and `log4j-api` 
in start level 2? Will this solution work anyway or the bundles must be in the 
same start level?
   
   As Niklas said, this should not cause harm. If you are interested in the 
details, chapter [4.4.6.2 `Lazy Activation Policy` of the OSGi 
specification](https://docs.osgi.org/specification/osgi.core/8.0.0/framework.lifecycle.html#i3270445)
 that covers it. If you want a little bit more context the entire [4.4.6 
`Activation` 
chapter](https://docs.osgi.org/specification/osgi.core/8.0.0/framework.lifecycle.html#i3270394)
 probably makes it a bit more clear.
   But to summaries it, this header mainly commands the running OSGi framework 
to delay the activation of a bundle (i.e. calling its `BundleActivator's 
start()` method to the time immediately before when the first class from it is 
loaded, after it has been started.
   
   Additionally as far as I know, Equinox has the specialty (I don't know how 
other implementations like Felix behave in this regard) to put bundles that 
have the `Bundle-ActivationPolicy: lazy` declared into the STARTING state 
automatically, which has the effect that they are started as soon as the first 
class is loaded from them, without the need to start them explicitly. This also 
has the advantage that lazy activated bundles have a BundleContext, even if 
they not have been started (as Niklas also pointed out). This is for example 
stated in 
[Bundle.getBundleContext()](https://docs.osgi.org/specification/osgi.core/8.0.0/framework.api.html#org.osgi.framework.Bundle.getBundleContext--).
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to