You probably want to actually wait for the framework to stop:
FrameworkEvent frameworkEvent = Launcher.framework.waitForStop(timeout);
if (frameworkEvent.getType() == FrameworkEvent.WAIT_TIMEDOUT) {
_log.error("OSGi framework event {} triggered after a {}ms timeout",
frameworkEvent, timeout);
}
else if (_log.isInfoEnabled()) {
_log.info(frameworkEvent);
}
HTH,
- Ray
On Mon, Oct 15, 2018 at 2:41 PM Martin Petzold via osgi-dev <
[email protected]> wrote:
> Dear list.
>
> My aim is a graceful stop of the OSGi framework and all OSGi blueprint
> components.
>
> If I stop the OSGi framework, the OSGi blueprint components are not
> destroyed (destroy methods are not called). Why is this the case and how
> can I destroy them. I have my own OSGi launcher implementation. I'm
> using a shutdown hook and then stop the OSGi framework:
>
> Runtime.getRuntime().addShutdownHook(new Thread() {
> @Override
> public void run() {
> Launcher.logService.log(LogService.LOG_WARNING, "HANDLE
> SHUTDOWN");
> if(Launcher.framework != null) {
> try {
> Launcher.framework.stop();
> } catch (BundleException e) {
> Launcher.logService.log(LogService.LOG_ERROR,
> "Shutdown" + ((Launcher.framework != null) ? " of " +
> Launcher.framework.getSymbolicName() + " " : " ") + "failed!", e);
> System.exit(-1);
> }
> }
> }
> });
>
> Thanks and kind regards,
>
> Martin
>
> _______________________________________________
> OSGi Developer Mail List
> [email protected]
> https://mail.osgi.org/mailman/listinfo/osgi-dev
--
*Raymond Augé* <http://www.liferay.com/web/raymond.auge/profile>
(@rotty3000)
Senior Software Architect *Liferay, Inc.* <http://www.liferay.com>
(@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance <http://osgi.org> (@OSGiAlliance)
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev