Hello,
I’ve been looking into application management with KF.
I understand that the Kernel can stop an application with Feature.stop()
.
But it does not seem this method is part of the runtime API (neither is Kernel.getContextOwner()
which would seem the only way for a feature to get its Feature
instance.)
So, my questions are:
Can an application be stopped by itself ?
If not, when an application has terminated its execution, how should the associated resources be released ?
Thanks,
Alan
Hi Alan,
No, a Feature cannot stop itself. The call to Feature.stop()
must be triggered by the Kernel.
This is described in section 4.1 Type References
of the KF Specification:
However, you can still decide to open a custom API in your Kernel to do that. The following code snippet should work:
public static void stopMe() {
Feature f = (Feature) Kernel.getContextOwner();
// [here] optionally add a Permission check to stop itself
Kernel.enter();
do {
f.stop();
} while (f.getState() != State.INSTALLED);
}
–Frédéric
Hi Frédéric,
Thank you for the clarification and the recommendation !
Best regards,
Alan