我的github

第一章 前言

第二章 基础开发环境搭建

第三章 走进Openlayers

第四章 Openlayers核心关键概念

第五章 走进地图对象Map

第六章 地图视图管理View

第七章 栅格图层

第八章 矢量图层

第九章 矢量要素

第十章 图层渲染Style

第十一章 投影projection

第十二章 地图交互

第十三章 Postgis数据库

第十四章 开源企业级架构解决方案

IDEA如何打开geoserver源码:https://blog.csdn.net/u010608964/article/details/83719105

GeoServer服务器开发框架

项目框架组织

Start.java

package org.geoserver.web;

public class Start {
    private static final Logger log =
            org.geotools.util.logging.Logging.getLogger(Start.class.getName());

    public static void main(String[] args) {
        final Server jettyServer = new Server();

        try {
            HttpConfiguration httpConfig = new HttpConfiguration();

            ServerConnector http =
                    new ServerConnector(jettyServer, new HttpConnectionFactory(httpConfig));
            http.setPort(Integer.getInteger("jetty.port", 8080));
            http.setAcceptQueueSize(100);
            http.setIdleTimeout(1000 * 60 * 60);
            http.setSoLingerTime(-1);

            // Use this to set a limit on the number of threads used to respond requests
            // BoundedThreadPool tp = new BoundedThreadPool();
            // tp.setMinThreads(8);
            // tp.setMaxThreads(8);
            // conn.setThreadPool(tp);

            // SSL host name given ?
            String sslHost = System.getProperty("ssl.hostname");
            ServerConnector https = null;
            if (sslHost != null && sslHost.length() > 0) {
                Security.addProvider(new BouncyCastleProvider());
                SslContextFactory ssl = createSSLContextFactory(sslHost);

                HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
                httpsConfig.addCustomizer(new SecureRequestCustomizer());

                https =
                        new ServerConnector(
                                jettyServer,
                                new SslConnectionFactory(ssl, HttpVersion.HTTP_1_1.asString()),
                                new HttpConnectionFactory(httpsConfig));
                https.setPort(8443);
            }

            jettyServer.setConnectors(
                    https != null ? new Connector[] {http, https} : new Connector[] {http});

            /*Constraint constraint = new Constraint();
            constraint.setName(Constraint.__BASIC_AUTH);;
            constraint.setRoles(new String[]{"user","admin","moderator"});
            constraint.setAuthenticate(true);

            ConstraintMapping cm = new ConstraintMapping();
            cm.setConstraint(constraint);
            cm.setPathSpec("/*");

            SecurityHandler sh = new SecurityHandler();
            sh.setUserRealm(new HashUserRealm("MyRealm","/Users/jdeolive/realm.properties"));
            sh.setConstraintMappings(new ConstraintMapping[]{cm});

            WebAppContext wah = new WebAppContext(sh, null, null, null);*/
            WebAppContext wah = new WebAppContext();
            wah.setContextPath("/geoserver");
            wah.setWar("src/main/webapp");

            jettyServer.setHandler(wah);
            wah.setTempDirectory(new File("target/work"));
            // this allows to send large SLD's from the styles form
            wah.getServletContext().getContextHandler().setMaxFormContentSize(1024 * 1024 * 5);
            // this allows to configure hyperspectral images
            wah.getServletContext().getContextHandler().setMaxFormKeys(2000);

            String jettyConfigFile = System.getProperty("jetty.config.file");
            if (jettyConfigFile != null) {
                log.info("Loading Jetty config from file: " + jettyConfigFile);
                (new XmlConfiguration(new FileInputStream(jettyConfigFile))).configure(jettyServer);
            }

            long start = System.currentTimeMillis();
            log.severe("GeoServer starting");

            jettyServer.start();

            long end = System.currentTimeMillis();
            log.severe("GeoServer startup complete in " + (end - start) / 1000. + "s");

            /*
             * Reads from System.in looking for the string "stop\n" in order to gracefully terminate
             * the jetty server and shut down the JVM. This way we can invoke the shutdown hooks
             * while debugging in eclipse. Can't catch CTRL-C to emulate SIGINT as the eclipse
             * console is not propagating that event
             */
            Thread stopThread =
                    new Thread() {
                        @Override
                        public void run() {
                            BufferedReader reader =
                                    new BufferedReader(new InputStreamReader(System.in));
                            String line;
                            try {
                                while (true) {
                                    line = reader.readLine();
                                    if ("stop".equals(line)) {
                                        jettyServer.stop();
                                        System.exit(0);
                                    }
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                                System.exit(1);
                            }
                        }
                    };
            stopThread.setDaemon(true);
            stopThread.run();

            // use this to test normal stop behaviour, that is, to check stuff that
            // need to be done on container shutdown (and yes, this will make
            // jetty stop just after you started it...)
            // jettyServer.stop();
        } catch (Exception e) {
            log.log(Level.SEVERE, "Could not start the Jetty server: " + e.getMessage(), e);

            if (jettyServer != null) {
                try {
                    jettyServer.stop();
                } catch (Exception e1) {
                    log.log(
                            Level.SEVERE,
                            "Unable to stop the " + "Jetty server:" + e1.getMessage(),
                            e1);
                }
            }
        }
    }

UML模型:Settings->Tools->Diagram设置显示项,确定,打开要显示的文件,按Ctrl + Shift + Alt + UCtrl + Alt + U或右键选择,生成类Uml关联图

从代码可知,GeoServer是基于Jetty开发的服务器软件

而对于数据库的管理使用的是jdbctemplate,对于业务逻辑,使用的是Spring,对于管理员或者用户的请求使用的是Spring mvc。

那么,问题是如何将jetty和spring嵌套在一起呢?:https://blog.csdn.net/kkkloveyou/article/details/79721416    https://www.cnblogs.com/zzw-blog/p/9140980.html   https://zhuanlan.zhihu.com/p/142672127

什么是servlet?

那么GeoServer是如何将GIS和Spring&Jetty完美结合的呢?以一个WMS请求服务为例

WMS.java

public class WMS implements ApplicationContextAware {

    public static final Version VERSION_1_1_1 = new Version("1.1.1");

    public static final Version VERSION_1_3_0 = new Version("1.3.0");

    public static final String JPEG_COMPRESSION = "jpegCompression";

    public static final int JPEG_COMPRESSION_DEFAULT = 25;

    public static final String PNG_COMPRESSION = "pngCompression";

    public static final int PNG_COMPRESSION_DEFAULT = 25;

    public static final String MAX_ALLOWED_FRAMES = "maxAllowedFrames";

    public static final int MAX_ALLOWED_FRAMES_DEFAULT = Integer.MAX_VALUE;

    public static final String MAX_RENDERING_TIME = "maxAnimatorRenderingTime";

    public static final String MAX_RENDERING_SIZE = "maxRenderingSize";

    public static final String FRAMES_DELAY = "framesDelay";

    public static final int FRAMES_DELAY_DEFAULT = 1000;

    public static final String DISPOSAL_METHOD = "disposalMethod";

    public static final String LOOP_CONTINUOUSLY = "loopContinuously";

    public static final Boolean LOOP_CONTINUOUSLY_DEFAULT = Boolean.FALSE;

    public static final String SCALEHINT_MAPUNITS_PIXEL = "scalehintMapunitsPixel";

    public static final Boolean SCALEHINT_MAPUNITS_PIXEL_DEFAULT = Boolean.FALSE;

    public static final String DYNAMIC_STYLING_DISABLED = "dynamicStylingDisabled";

    public static final String FEATURES_REPROJECTION_DISABLED = "featuresReprojectionDisabled";

    static final Logger LOGGER = Logging.getLogger(WMS.class);

    public static final String WEB_CONTAINER_KEY = "WMS";

    /** SVG renderers. */
    public static final String SVG_SIMPLE = "Simple";

    public static final String SVG_BATIK = "Batik";

    /** KML reflector mode */
    public static String KML_REFLECTOR_MODE = "kmlReflectorMode";

    /** KML reflector mode values */
    public static final String KML_REFLECTOR_MODE_REFRESH = "refresh";

    public static final String KML_REFLECTOR_MODE_SUPEROVERLAY = "superoverlay";

    public static final String KML_REFLECTOR_MODE_DOWNLOAD = "download";

    public static final String KML_REFLECTOR_MODE_DEFAULT = KML_REFLECTOR_MODE_REFRESH;

    /** KML superoverlay sub-mode */
    public static final String KML_SUPEROVERLAY_MODE = "kmlSuperoverlayMode";

    public static final String KML_SUPEROVERLAY_MODE_AUTO = "auto";

    public static final String KML_SUPEROVERLAY_MODE_RASTER = "raster";

    public static final String KML_SUPEROVERLAY_MODE_OVERVIEW = "overview";

    public static final String KML_SUPEROVERLAY_MODE_HYBRID = "hybrid";

    public static final String KML_SUPEROVERLAY_MODE_CACHED = "cached";

    public static final String KML_SUPEROVERLAY_MODE_DEFAULT = KML_SUPEROVERLAY_MODE_AUTO;

    public static final String KML_KMLATTR = "kmlAttr";

    public static final boolean KML_KMLATTR_DEFAULT = true;

    public static final String KML_KMLPLACEMARK = "kmlPlacemark";

    public static final boolean KML_KMLPLACEMARK_DEFAULT = false;

    public static final String KML_KMSCORE = "kmlKmscore";

    public static final int KML_KMSCORE_DEFAULT = 40;

    /** Enable continuous map wrapping (global sys var) */
    public static Boolean ENABLE_MAP_WRAPPING = null;

    /** Continuous map wrapping key */
    public static String MAP_WRAPPING_KEY = "mapWrapping";

    /** Enable advanced projection handling */
    public static Boolean ENABLE_ADVANCED_PROJECTION = null;

    /** Advanced projection key */
    public static String ADVANCED_PROJECTION_KEY = "advancedProjectionHandling";

    /** Enable advanced projection handling */
    public static Boolean ENABLE_ADVANCED_PROJECTION_DENSIFICATION = false;

    /** Advanced projection densification key */
    public static String ADVANCED_PROJECTION_DENSIFICATION_KEY = "advancedProjectionDensification";

    /** Disable DateLine Wrapping Heuristic. */
    public static Boolean DISABLE_DATELINE_WRAPPING_HEURISTIC = false;

    /** DateLine Wrapping Heuristic key */
    public static String DATELINE_WRAPPING_HEURISTIC_KEY = "disableDatelineWrappingHeuristic";

    /**
     * Capabilities will be produced with a root Layer element, only when needed (there is no single
     * top layer element) *
     */
    public static Boolean ROOT_LAYER_IN_CAPABILITIES_DEFAULT = true;

    /** Root Layer in Capabilities key * */
    public static String ROOT_LAYER_IN_CAPABILITIES_KEY = "rootLayerInCapabilities";

    /** GIF disposal methods */
    public static final String DISPOSAL_METHOD_NONE = "none";

    public static final String DISPOSAL_METHOD_NOT_DISPOSE = "doNotDispose";

    public static final String DISPOSAL_METHOD_BACKGROUND = "backgroundColor";

    public static final String DISPOSAL_METHOD_PREVIOUS = "previous";

    public static final String DISPOSAL_METHOD_DEFAULT = DISPOSAL_METHOD_NONE;

    public static final String[] DISPOSAL_METHODS = {
        DISPOSAL_METHOD_NONE,
        DISPOSAL_METHOD_NOT_DISPOSE,
        DISPOSAL_METHOD_BACKGROUND,
        DISPOSAL_METHOD_PREVIOUS
    };

Package WMS整个WMS包的结构

一个WMS请求,会返回一个数据或者一个操作后的数据,并在客户端展示。

 

posted on 2020-09-20 20:18  XiaoNiuFeiTian  阅读(1022)  评论(0编辑  收藏  举报