⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.java

📁 电子地图服务器,搭建自己的地图服务
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                            eval = file.exists();
                        } catch (Exception e) {
                            if (_debug) {
                                e.printStackTrace();
                            }
                        }
                    } else if (condition.equals("java")) {
                        String operator = st.nextToken();
                        String version = st.nextToken();
                        ver.parse(version);
                        eval = (operator.equals("<") && (java_version.compare(ver) < 0))
                            || (operator.equals(">") && (java_version.compare(ver) > 0))
                            || (operator.equals("<=") && (java_version.compare(ver) <= 0))
                            || (operator.equals("=<") && (java_version.compare(ver) <= 0))
                            || (operator.equals("=>") && (java_version.compare(ver) >= 0))
                            || (operator.equals(">=") && (java_version.compare(ver) >= 0))
                            || (operator.equals("==") && (java_version.compare(ver) == 0))
                            || (operator.equals("!=") && (java_version.compare(ver) != 0));
                    } else if (condition.equals("nargs")) {
                        String operator = st.nextToken();
                        int number = Integer.parseInt(st.nextToken());
                        eval = (operator.equals("<") && (args.length < number))
                            || (operator.equals(">") && (args.length > number))
                            || (operator.equals("<=") && (args.length <= number))
                            || (operator.equals("=<") && (args.length <= number))
                            || (operator.equals("=>") && (args.length >= number))
                            || (operator.equals(">=") && (args.length >= number))
                            || (operator.equals("==") && (args.length == number))
                            || (operator.equals("!=") && (args.length != number));
                    } else {
                        System.err.println("ERROR: Unknown condition: " + condition);
                        eval = false;
                    }

                    expression &= (not ? (!eval) : eval);
                    not = false;
                }

                String file = expand(subject).replace('/', File.separatorChar);

                if (_debug) {
                    System.err.println((expression ? "T " : "F ") + line);
                }

                if (!expression) {
                    done.put(file, file);

                    continue;
                }

                // Handle the subject
                if (subject.indexOf("=") > 0) {
                    int i = file.indexOf("=");
                    String property = file.substring(0, i);
                    String value = file.substring(i + 1);

                    if (_debug) {
                        System.err.println("  " + property + "=" + value);
                    }

                    System.setProperty(property, value);
                } else if (subject.endsWith("/*")) {
                    // directory of JAR files
                    File extdir = new File(file.substring(0, file.length() - 1));
                    File[] jars = extdir.listFiles(new FilenameFilter() {
                                public boolean accept(File dir, String name) {
                                    String namelc = name
                                        .toLowerCase();

                                    return namelc.endsWith(".jar") || name.endsWith(".zip");
                                }
                            });

                    for (int i = 0; (jars != null) && (i < jars.length); i++) {
                        String jar = jars[i].getCanonicalPath();

                        if (!done.containsKey(jar)) {
                            done.put(jar, jar);

                            boolean added = _classpath.addComponent(jar);

                            if (_debug) {
                                System.err.println((added ? "  CLASSPATH+=" : "  !") + jar);
                            }
                        }
                    }
                } else if (subject.endsWith("/")) {
                    // class directory
                    File cd = new File(file);
                    String d = cd.getCanonicalPath();

                    if (!done.containsKey(d)) {
                        done.put(d, d);

                        boolean added = _classpath.addComponent(d);

                        if (_debug) {
                            System.err.println((added ? "  CLASSPATH+=" : "  !") + d);
                        }
                    }
                } else if (subject.toLowerCase().endsWith(".xml")) {
                    // Config file
                    File f = new File(file);

                    if (f.exists()) {
                        _xml.add(f.getCanonicalPath());
                    }

                    if (_debug) {
                        System.err.println("  ARGS+=" + f);
                    }
                } else if (subject.toLowerCase().endsWith(".class")) {
                    // Class
                    String cn = expand(subject.substring(0, subject.length() - 6));

                    if ((cn != null) && (cn.length() > 0)) {
                        if (_debug) {
                            System.err.println("  CLASS=" + cn);
                        }

                        _classname = cn;
                    }
                } else {
                    // single JAR file
                    File f = new File(file);
                    String d = f.getCanonicalPath();

                    if (!done.containsKey(d)) {
                        done.put(d, d);

                        boolean added = _classpath.addComponent(d);

                        if (!added) {
                            added = _classpath.addClasspath(expand(subject));

                            if (_debug) {
                                System.err.println((added ? "  CLASSPATH+=" : "  !") + d);
                            }
                        } else if (_debug) {
                            System.err.println((added ? "  CLASSPATH+=" : "  !") + d);
                        }
                    }
                }
            } catch (Exception e) {
                System.err.println("on line: '" + line + "'");
                e.printStackTrace();
            }
        }
    }

    /* ------------------------------------------------------------ */
    public void start(String[] args) {
        // set up classpath:
        try {
            Monitor.monitor();

            InputStream cpcfg = getClass().getClassLoader().getResourceAsStream(_config);

            if (_debug) {
                System.err.println("config=" + _config);
            }

            if (cpcfg == null) {
                cpcfg = new FileInputStream(_config);
            }

            configure(cpcfg, args);
            cpcfg.close();

            File file = new File(System.getProperty("jetty.home"));
            String canonical = file.getCanonicalPath();
            System.setProperty("jetty.home", canonical);
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }

        // okay, classpath complete.
        System.setProperty("java.class.path", _classpath.toString());

        ClassLoader cl = _classpath.getClassLoader();

        if (_debug) {
            System.err.println("java.class.path=" + System.getProperty("java.class.path"));
        }

        if (_debug) {
            System.err.println("jetty.home=" + System.getProperty("jetty.home"));
        }

        if (_debug) {
            System.err.println("java.io.tmpdir=" + System.getProperty("java.io.tmpdir"));
        }

        if (_debug) {
            System.err.println("java.class.path=" + _classpath);
        }

        if (_debug) {
            System.err.println("classloader=" + cl);
        }

        if (_debug) {
            System.err.println("classloader.parent=" + cl.getParent());
        }

        // Invoke main(args) using new classloader.
        Thread.currentThread().setContextClassLoader(cl);

        // re-eval the policy now that env is set
        try {
            Policy policy = Policy.getPolicy();

            if (policy != null) {
                policy.refresh();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        try {
            if (_xml.size() > 0) {
                for (int i = 0; i < args.length; i++)
                    _xml.add(args[i]);

                args = (String[]) _xml.toArray(args);
            }

            //check for override of start class
            String serverOverride = System.getProperty("jetty.server");

            if (_debug) {
                System.err.println("server.override=" + serverOverride);
            }

            if (serverOverride != null) {
                _classname = serverOverride;
            }

            invokeMain(cl, _classname, args);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -