新增注释,方便理解

master
星期八 5 years ago
parent 0d94eaa34a
commit 4017489c8e
  1. 14
      proxy-common/src/main/java/org/fengfei/lanproxy/common/container/ContainerHelper.java

@ -13,7 +13,7 @@ import org.slf4j.LoggerFactory;
*/ */
public class ContainerHelper { public class ContainerHelper {
private static Logger logger = LoggerFactory.getLogger(ContainerHelper.class); private static Logger LOGGER = LoggerFactory.getLogger(ContainerHelper.class);
private static volatile boolean running = true; private static volatile boolean running = true;
@ -25,7 +25,7 @@ public class ContainerHelper {
// 启动所有容器 // 启动所有容器
startContainers(); startContainers();
//在JVM销毁前执行的一个线程
Runtime.getRuntime().addShutdownHook(new Thread() { Runtime.getRuntime().addShutdownHook(new Thread() {
@Override @Override
@ -53,20 +53,20 @@ public class ContainerHelper {
private static void startContainers() { private static void startContainers() {
for (Container container : cachedContainers) { for (Container container : cachedContainers) {
logger.info("starting container [{}]", container.getClass().getName()); LOGGER.info("starting container [{}]", container.getClass().getName());
container.start(); container.start();
logger.info("container [{}] started", container.getClass().getName()); LOGGER.info("container [{}] started", container.getClass().getName());
} }
} }
private static void stopContainers() { private static void stopContainers() {
for (Container container : cachedContainers) { for (Container container : cachedContainers) {
logger.info("stopping container [{}]", container.getClass().getName()); LOGGER.info("stopping container [{}]", container.getClass().getName());
try { try {
container.stop(); container.stop();
logger.info("container [{}] stopped", container.getClass().getName()); LOGGER.info("container [{}] stopped", container.getClass().getName());
} catch (Exception ex) { } catch (Exception ex) {
logger.warn("container stopped with error", ex); LOGGER.warn("container stopped with error", ex);
} }
} }
} }

Loading…
Cancel
Save