public static void main(String[] args) {
        if (args.length < 1)
            throw new IllegalArgumentException("You must specify a main dependency");
        //设定的路径可能包括lib/等目录
        String[] strings = args[0].split("\\|/");
        if (strings.length > 1) {
            args[0] = strings[strings.length - 1];
        }
        try {
            // When started by Service wrapper, the context class loader is URLClassLoader of wrapper.jar
            //  but this main class is loaded by the framework jar's ClassLoader(FactoryClassLoader)
            if (AppLauncher.class.getClassLoader() != ClassLoader.getSystemClassLoader()) {
                //说明是基于Service Wrapper启动
                Thread.currentThread()
                      .setContextClassLoader(MainClassLoader.getInstance(AppLauncher.class.getClassLoader()));
            } else {
                Thread.currentThread().setContextClassLoader(MainClassLoader.getInstance());
            }
            // To register the url handler by current context class loader, instead of system bootstrap class loader
            URL.setURLStreamHandlerFactory(ComponentURLStreamHandlerFactory.getFactory());
            int exitCode = mainWithExitCode(args);
            System.exit(exitCode);
        } catch (LaunchException e) {
            System.err.println(describeException(e));
            System.exit(e.getExitCode());
        } catch (Exception e) {
            System.err.println(describeException(e));
            System.exit(100);
        }
    }
public static void main(String[] args) {
        if (args.length < 1)
            throw new IllegalArgumentException("You must specify a main dependency");
        
        String[] strings = args[0].split("\\|/");
        if (strings.length > 1) {
            args[0] = strings[strings.length - 1];
        }
        try {
            
            
            if (AppLauncher.class.getClassLoader() != ClassLoader.getSystemClassLoader()) {
                
                Thread.currentThread()
                      .setContextClassLoader(MainClassLoader.getInstance(AppLauncher.class.getClassLoader()));
            } else {
                Thread.currentThread().setContextClassLoader(MainClassLoader.getInstance());
            }
            
            URL.setURLStreamHandlerFactory(ComponentURLStreamHandlerFactory.getFactory());
            int exitCode = mainWithExitCode(args);
            System.exit(exitCode);
        } catch (LaunchException e) {
            System.err.println(describeException(e));
            System.exit(e.getExitCode());
        } catch (Exception e) {
            System.err.println(describeException(e));
            System.exit(100);
        }
    }
public static void main ( String [ ] args ) { if ( args . length < 1 ) throw new IllegalArgumentException ( "You must specify a main dependency" ) ; //设定的路径可能包括lib/等目录 String [ ] strings = args [ 0 ] . split ( "\\|/" ) ; if ( strings . length > 1 ) { args [ 0 ] = strings [ strings . length - 1 ] ; } try { // When started by Service wrapper, the context class loader is URLClassLoader of wrapper.jar //  but this main class is loaded by the framework jar's ClassLoader(FactoryClassLoader) if ( AppLauncher . class . getClassLoader ( ) != ClassLoader . getSystemClassLoader ( ) ) { //说明是基于Service Wrapper启动 Thread . currentThread ( ) . setContextClassLoader ( MainClassLoader . getInstance ( AppLauncher . class . getClassLoader ( ) ) ) ; } else { Thread . currentThread ( ) . setContextClassLoader ( MainClassLoader . getInstance ( ) ) ; } // To register the url handler by current context class loader, instead of system bootstrap class loader URL . setURLStreamHandlerFactory ( ComponentURLStreamHandlerFactory . getFactory ( ) ) ; int exitCode = mainWithExitCode ( args ) ; System . exit ( exitCode ) ; } catch ( LaunchException e ) { System . err . println ( describeException ( e ) ) ; System . exit ( e . getExitCode ( ) ) ; } catch ( Exception e ) { System . err . println ( describeException ( e ) ) ; System . exit ( 100 ) ; } }
<h1>支持系统启动与停止</h1>
<p/>
<h2>启动方式</h2>
开发模式下，通过命令行以：
<p><strong>java -classpath jdk/jars;container/classes;other/classes
dnt.component.container.AppLauncher depended.group.artifact-version</strong></p>
生产模式下，通过命令行以：
<p><strong>java -Dapp.home=path/to/home -jar path/to/container.jar depended.group.artifact-version</strong></p>
的方式启动
<p>
定制方式：
用户可以通过　-Dapp.launch.environment=the.launch.env.class 的方式定制启动逻辑
但请注意将相应的Launch Env类配置在主jar的class-path中（或开发环境的pom依赖下）
</p>
退出情况:
<ul>
<li>0: 正常退出</li>
<li>1: Launch Env不能初始化</li>
<li>2: 目标主jar|classes未定义</li>
<li>3: 目标主jar|classes无法初始化</li>
<li>100: 未知异常</li>
<li>其他：业务异常，待明确</li>
</ul>
<p/>
<h2>停止方式</h2>
开发模式下，通过命令行以：
<p><strong>java -classpath jdk/jars;container/classes;other/classes
dnt.component.container.AppLauncher depended.group.artifact-version --stop</strong></p>
生产模式下，通过命令行以：
<p><strong>java -Dapp.home=path/to/home -jar path/to/container.jar depended.group.artifact-version --stop</strong></p>
的方式停止

@param args 最少要指定一个入口jar文件或者入口主模块输出路径
<h1 > 支持系统启动与停止< / h1 > <p / > <h2 > 启动方式< / h2 > 开发模式下，通过命令行以： <p > <strong > java - classpath jdk / jars ; container / classes ; other / classes dnt . component . container . AppLauncher depended . group . artifact - version< / strong > < / p > 生产模式下，通过命令行以： <p > <strong > java - Dapp . home = path / to / home - jar path / to / container . jar depended . group . artifact - version< / strong > < / p > 的方式启动 <p > 定制方式： 用户可以通过 - Dapp . launch . environment = the . launch . env . class 的方式定制启动逻辑 但请注意将相应的Launch Env类配置在主jar的class - path中（或开发环境的pom依赖下） < / p > 退出情况 : <ul > <li > 0 : 正常退出< / li > <li > 1 : Launch Env不能初始化< / li > <li > 2 : 目标主jar|classes未定义< / li > <li > 3 : 目标主jar|classes无法初始化< / li > <li > 100 : 未知异常< / li > <li > 其他：业务异常，待明确< / li > < / ul > <p / > <h2 > 停止方式< / h2 > 开发模式下，通过命令行以： <p > <strong > java - classpath jdk / jars ; container / classes ; other / classes dnt . component . container . AppLauncher depended . group . artifact - version -- stop< / strong > < / p > 生产模式下，通过命令行以： <p > <strong > java - Dapp . home = path / to / home - jar path / to / container . jar depended . group . artifact - version -- stop< / strong > < / p > 的方式停止