GeoServer learning note (7): Servlet and HTTP dispatching process 4
Su Weimin http://www.gisdev.cn/http://blog.csdn.net/suen/ Date:
All copyrights reserved. If you need to reprint the information, contact the author and indicate the source in a conspicuous position.
The HTTP dispatch process (http://blog.csdn.net/suen/archive/2009/11/02/4759332.aspx) before GeoServer version 1.6 was introduced before, and now the dispatch process after version 1.6 is introduced.
HTTP distribution process after version 1.6
Later than version 1.6, GeoServer uses the OWS Dispatching System. Based on the Spring Web MVC Framework, HTTP requests can be sent to org. springframework. web. servlet. dispatcherServlet (Pre Control), which performs some common HTTP request processing (such as file upload), and forwards it to beans in Different Spring containers through an appropriate dispatch mechanism, that is, the Logic Control of different business Logic and service processing. These controllers are combined with different models, such as spatial data models, attribute data models, and map style models, to form a result model and return the result to the client through DispatcherServlet. Thus, the implementation of the GeoServer MVC Architecture is formed based on Spring Web MVC.
For details, see the Http request distribution process of GeoServer .)
GeoServer is one of the well-known open source WebGIS implementations that follow the OGC specifications. It uses Spring Web MVC as the external HTTP Request Processing Framework of OGC service, assign HTTP requests to services such as WMS, WFS, and WCS. These Service implementations are implemented based on the functions provided by the Geotools library. The following is a summary of the GetMap HTTP request to describe the dispatch process. (In addition to the OGC service, GeoServer management and other functions are implemented based on the Struts architecture ).
Org. springframework. web. servlet. dispatcherServlet, that is, the Pre-controller. Any HTTP request can be sent to this Servlet. After some common HTTP request processing (such as file uploading, the appropriate dispatch mechanism is used to forward the Bean to different Spring containers, that is, the Logic Control of different business Logic and service processing. These controllers are combined with different models ), for example, the spatial data model, attribute data model, and map style model are processed to form a result model, which is returned to the client through DispatcherServlet. Thus, the implementation of the GeoServer MVC Architecture is formed based on Spring Web MVC.
1. The Web. xml configuration file of the GeoServer web project shows the URLs to be passed to DispatcherServlet:
1. Servlet Declaration
Dispatcher
Org. springframework. web. servlet. DispatcherServlet
2. URL Mapping
Dispatcher
/Wms /*
Dispatcher
/Wcs /*
Dispatcher
/WFS /*
Dispatcher
/Ows /*
For more information, see Web. xml.
2. Using org. springframework. Web. servlet. handler. simpleurlhandlermapping in applicationcontext. XML, the spring configuration file of different geoservers indicates that different URL paths need different service logic controllers for further processing.
Similar descriptions are provided for WMS, WFS, web, WCS, wcs1_1, rest, and gwc projects, it also describes how to further process the geoserver controllers such as dispatcher, putstyleswrapper, filepublisher, restwrapper, gwcrestdispatcher, geowebcachedispatcher, and geowebcachedispatcher.
The getmap request of OGC is processed by dispatcher. It is declared as follows in the configuration file applicationcontext. xml of the main project:
Geoserver's dispatcher class extends org. springframework. Web. servlet. MVC. abstractcontroller and implements the interface org. springframework. Web. servlet. MVC. Controller required by spring dispatcherservlet through abstractcontroller.
3. geoserver dispatcher obtains the services to be accessed, the operations to be executed, and the operation parameters from the HTTP request, and calls the corresponding bean service method. Http: // localhost: 8080/geoserver/WMS? BBox =-74.01199448397661, 40.70732689845813,-74.00841053684495, 40.71216558957052 & amp; styles = & format = application/openlayers & request = getmap & version = 1.1.1 & layers = Tiger: poi & width = 457 & Height = 550 & SRS = epsg: 4326. In this request, WMS is the service to be requested, getmap is the service method of the request, and tiger: poi is the geographic data to be accessed. The dispatcher finds the defaultwebmapservice implementation encapsulation class and calls its getmap method. The getmap method further finds the implementation class getmap of the service method, and the getmap method finds the appropriate getmapproducer implementation, and call the relevant methods of the producer class to form the final result to be returned to the client. There are many subclasses of getmapproducer, such as pngmapproducer and pdfmapproducer. Different producer types are obtained based on different requests and different results are generated. The related producer is generally implemented based on the geotools class library.