// Path: cango-service/src/main/java/com/bella/cango/service/CangoManagerService.java
// public interface CangoManagerService {
// 
//     CangoResponseDto start(CangoRequestDto cangoRequestDto);
// 
//     CangoResponseDto add(CangoRequestDto cangoRequestDto);
// 
//     CangoResponseDto stop(CangoRequestDto cangoRequestDto);
// 
//     CangoResponseDto enable(CangoRequestDto cangoRequestDto);
// 
//     CangoResponseDto disable(CangoRequestDto cangoRequestDto);
// 
//     CangoResponseDto check(CangoRequestDto canalReqDto);
// 
//     CangoResponseDto startAll();
// 
//     CangoResponseDto stopAll();
// 
//     CangoResponseDto shutdown();
// 
//     CangoResponseDto clearAll();
// }
// 
// Path: cango-common/src/main/java/com/bella/cango/utils/PropertiesFileLoader.java
// public class PropertiesFileLoader {
//     public static final String PROJECT_DIR;
// 
//     public static final String CLASSPATH_DIR;
// 
//     public static final String DEFAULT_CONF_DIR;
// 
//     public static final String DEFAULT_KAFKA_PATH;
// 
//     public static final String DEFAULT_LOG_HOME;
// 
//     static {
//         File classFile = new File(Thread.currentThread().getContextClassLoader().getResource(".").getFile());
//         CLASSPATH_DIR = classFile.getAbsolutePath();
//         PROJECT_DIR = classFile.getParentFile().getParentFile().getAbsolutePath();
//         File confFile = new File(PROJECT_DIR, "src/conf");
//         DEFAULT_CONF_DIR = confFile.getAbsolutePath();
//         DEFAULT_KAFKA_PATH = DEFAULT_CONF_DIR + File.separator + "kafkaProduce.properties";
//         DEFAULT_LOG_HOME = DEFAULT_CONF_DIR + File.separator + "log";
//     }
// 
//     public static Properties loadKafkaProperties() throws IOException {
//         String kafkaPath = System.getProperty("kafkaProduce");
//         if (StringUtils.isEmpty(kafkaPath)) {
//             kafkaPath = DEFAULT_KAFKA_PATH;
//         }
// 
//         return PropertiesLoaderUtils.loadProperties(new FileSystemResource(kafkaPath));
//     }
// 
//     public static Properties load(String path) throws IOException {
//         if (StringUtils.isEmpty(path)) {
//             return new Properties();
//         }
// 
//         return PropertiesLoaderUtils.loadProperties(new FileSystemResource(path));
//     }
// }


import com.bella.cango.service.CangoManagerService;
import com.bella.cango.utils.PropertiesFileLoader;
import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.core.AprLifecycleListener;
import org.apache.catalina.core.JreMemoryLeakPreventionListener;
import org.apache.catalina.core.StandardServer;
import org.apache.catalina.startup.Tomcat;
import org.apache.commons.lang3.StringUtils;
import org.apache.coyote.http11.Http11NioProtocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import java.io.File;
                } catch (LifecycleException e) {
                    LOGGER.error("stop tomcat error : ", e);
                }
            }
        });
        tomcat.getServer().await();
    }

    private static void setSystemProperties() {
        System.setProperty("tomcat.util.scan.StandardJarScanFilter.jarsToSkip", "*.jar");
        String logHome = System.getProperty("cango.logHome");
        if (StringUtils.isEmpty(logHome)) {
            System.setProperty("cango.logHome", PropertiesFileLoader.DEFAULT_LOG_HOME);
        }
    }

    /**
     * Close tomcat gracefully.
     *
     * @param tomcat the tomcat
     * @throws LifecycleException the lifecycle exception
     */
    private static void closeTomcatGracefully(Tomcat tomcat) throws LifecycleException {
        // 平滑/优雅地关闭tomcat，防止kafka消息丢失
        Container[] containers = tomcat.getHost().findChildren();
        if (containers != null && containers.length > 0) {
            Container container = containers[0];
            if (container instanceof Context) {
                ServletContext servletContext = ((Context) container).getServletContext();
                WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
// Path: cango-service/src/main/java/com/bella/cango/service/CangoManagerService.java
// public interface CangoManagerService {
// 
//     CangoResponseDto start(CangoRequestDto cangoRequestDto);
// 
//     CangoResponseDto add(CangoRequestDto cangoRequestDto);
// 
//     CangoResponseDto stop(CangoRequestDto cangoRequestDto);
// 
//     CangoResponseDto enable(CangoRequestDto cangoRequestDto);
// 
//     CangoResponseDto disable(CangoRequestDto cangoRequestDto);
// 
//     CangoResponseDto check(CangoRequestDto canalReqDto);
// 
//     CangoResponseDto startAll();
// 
//     CangoResponseDto stopAll();
// 
//     CangoResponseDto shutdown();
// 
//     CangoResponseDto clearAll();
// }
// 
// Path: cango-common/src/main/java/com/bella/cango/utils/PropertiesFileLoader.java
// public class PropertiesFileLoader {
//     public static final String PROJECT_DIR;
// 
//     public static final String CLASSPATH_DIR;
// 
//     public static final String DEFAULT_CONF_DIR;
// 
//     public static final String DEFAULT_KAFKA_PATH;
// 
//     public static final String DEFAULT_LOG_HOME;
// 
//     static {
//         File classFile = new File(Thread.currentThread().getContextClassLoader().getResource(".").getFile());
//         CLASSPATH_DIR = classFile.getAbsolutePath();
//         PROJECT_DIR = classFile.getParentFile().getParentFile().getAbsolutePath();
//         File confFile = new File(PROJECT_DIR, "src/conf");
//         DEFAULT_CONF_DIR = confFile.getAbsolutePath();
//         DEFAULT_KAFKA_PATH = DEFAULT_CONF_DIR + File.separator + "kafkaProduce.properties";
//         DEFAULT_LOG_HOME = DEFAULT_CONF_DIR + File.separator + "log";
//     }
// 
//     public static Properties loadKafkaProperties() throws IOException {
//         String kafkaPath = System.getProperty("kafkaProduce");
//         if (StringUtils.isEmpty(kafkaPath)) {
//             kafkaPath = DEFAULT_KAFKA_PATH;
//         }
// 
//         return PropertiesLoaderUtils.loadProperties(new FileSystemResource(kafkaPath));
//     }
// 
//     public static Properties load(String path) throws IOException {
//         if (StringUtils.isEmpty(path)) {
//             return new Properties();
//         }
// 
//         return PropertiesLoaderUtils.loadProperties(new FileSystemResource(path));
//     }
// }


// Path: cango-server/src/main/java/com/bella/cango/server/startUp/TomcatBootstrap.java
import com.bella.cango.service.CangoManagerService;
import com.bella.cango.utils.PropertiesFileLoader;
import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.core.AprLifecycleListener;
import org.apache.catalina.core.JreMemoryLeakPreventionListener;
import org.apache.catalina.core.StandardServer;
import org.apache.catalina.startup.Tomcat;
import org.apache.commons.lang3.StringUtils;
import org.apache.coyote.http11.Http11NioProtocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import java.io.File;

                } catch (LifecycleException e) {
                    LOGGER.error("stop tomcat error : ", e);
                }
            }
        });
        tomcat.getServer().await();
    }

    private static void setSystemProperties() {
        System.setProperty("tomcat.util.scan.StandardJarScanFilter.jarsToSkip", "*.jar");
        String logHome = System.getProperty("cango.logHome");
        if (StringUtils.isEmpty(logHome)) {
            System.setProperty("cango.logHome", PropertiesFileLoader.DEFAULT_LOG_HOME);
        }
    }

    /**
     * Close tomcat gracefully.
     *
     * @param tomcat the tomcat
     * @throws LifecycleException the lifecycle exception
     */
    private static void closeTomcatGracefully(Tomcat tomcat) throws LifecycleException {
        // 平滑/优雅地关闭tomcat，防止kafka消息丢失
        Container[] containers = tomcat.getHost().findChildren();
        if (containers != null && containers.length > 0) {
            Container container = containers[0];
            if (container instanceof Context) {
                ServletContext servletContext = ((Context) container).getServletContext();
                WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
                webApplicationContext.getBean(CangoManagerService.class).shutdown();