Skip to content

Commit

Permalink
OZ-476: Remove Utils class and refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
VaishSiddharth committed May 22, 2024
1 parent 0aa1c8c commit fa6be44
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/
package com.ozonehis.eip.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
Expand All @@ -18,6 +20,10 @@ public class ShutdownHandler implements ApplicationContextAware {

private ApplicationContext applicationContext;

private static boolean shuttingDown = false;

private static final Logger LOGGER = LoggerFactory.getLogger(ShutdownHandler.class);

@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
Expand All @@ -27,6 +33,17 @@ public void shutdown() {
ConfigurableApplicationContext configurableApplicationContext =
(ConfigurableApplicationContext) applicationContext;
configurableApplicationContext.close();
Utils.shutdown();
exitApplication();
}

public static synchronized void exitApplication() {
if (shuttingDown) {
LOGGER.info("Application is already shutting down");
return;
}
shuttingDown = true;
LOGGER.info("Shutting down the application...");
// Shutdown in a new thread to ensure other background shutdown threads complete too
new Thread(() -> System.exit(0)).start();
}
}
41 changes: 0 additions & 41 deletions commons/src/main/java/com/ozonehis/eip/utils/Utils.java

This file was deleted.

0 comments on commit fa6be44

Please sign in to comment.