Now is also a Runnable to be regisestered as shutdown hook if necessary

This commit is contained in:
Mauro Mugnaini 2020-06-29 16:52:46 +02:00
parent 59c3584f52
commit 164064e98b
1 changed files with 11 additions and 1 deletions

View File

@ -7,7 +7,7 @@ import com.liferay.portal.kernel.events.SimpleAction;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
public class ShutdownAction extends SimpleAction {
public class ShutdownAction extends SimpleAction implements Runnable {
protected static final Log log = LogFactoryUtil.getLog(ShutdownAction.class);
@ -15,6 +15,7 @@ public class ShutdownAction extends SimpleAction {
public ShutdownAction() {
eventPublisher = new ActionEventPublisher();
// Runtime.getRuntime().addShutdownHook(new Thread(this));
}
@Override
@ -25,4 +26,13 @@ public class ShutdownAction extends SimpleAction {
eventPublisher.publish(SimpleActionEvent.newShutdownEvent(ids));
}
@Override
public void run() {
try {
this.run(null);
} catch (ActionException e) {
// Left intentionally as it is
e.printStackTrace();
}
}
}