Do I smell DOS attack? :-) -- BJ Hargrave Senior Technical Staff Member, IBM OSGi Fellow and CTO of the OSGi Alliance hargr...@us.ibm.com
office: +1 386 848 1781 mobile: +1 386 848 3788 From: Neil Bartlett <njbartl...@gmail.com> To: Equinox development mailing list <equinox-dev@eclipse.org> Date: 2010/03/12 05:35 Subject: Re: [equinox-dev] Question on programatic close of the runtime Sent by: equinox-dev-boun...@eclipse.org Daniel, Stopping bundle zero is not a hack; this is the normal way to programmatically shutdown OSGi. However: 1) There is no need to check that the bundle is active first. Calling stop() on an already stopped bundle simply has no effect (likewise calling start() on an already active bundle has no effect). 2) There should be no need to wait for the framework to stop and then call System.exit(). Exiting the JVM should be the responsibility of whoever created and started the framework, i.e. the launcher. Calling System.exit() directly from within a bundle will cause big problems if your bundle is deployed to a framework embedded in a larger system, e.g. an application server. In other words, the code could be as simple as this: _componentContext.getBundleContext().getBundle(0).stop(); Regards, Neil On Fri, Mar 12, 2010 at 10:16 AM, <daniel.stu...@empolis.com> wrote: > Hi all, > > > > I would like to expose the functionality to close the Equinox runtime via an > HTTP request. Therefore I have implemented a Jetty ContextHandler as an > DeclarativeService. I used the FrameworkCommandProvider as an example on how > to close the runtime, but I was not able to get access to the Framework > class to call method close() on it. > > > > I came up with a workaround for that, which is basically like this: > > > > Bundle bundle = _componentContext.getBundleContext().getBundle(0); > > if (bundle.getState() == Bundle.ACTIVE) { > > bundle.stop(); > > while (bundle.getState() != Bundle.RESOLVED) { > > // WAIT N milliseconds and REPEAT at most M times > > } > > } > > System.exit(0); > > > > > > This works fine for me, although it seems to be a hack stopping bundle with > Id 0. Are there better ways to achieve my goal ? Are there any ways to get > access to the Framework class ? > > > > > > Bye, > > Daniel > > _______________________________________________ > equinox-dev mailing list > equinox-dev@eclipse.org > https://dev.eclipse.org/mailman/listinfo/equinox-dev > > _______________________________________________ equinox-dev mailing list equinox-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/equinox-dev
_______________________________________________ equinox-dev mailing list equinox-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/equinox-dev