GeoServer学习手记(六):Servlet及HTTP派发过程之三
2009-11-02 21:35
483 查看
GeoServer学习手记(六):Servlet及HTTP派发过程之三
粟卫民http://www.gisdev.cn/http://blog.csdn.net/suen/日期:2009-10-31
保留所有版权。如需转载,请联系作者,并在醒目位置注明出处
接上篇《GeoServer学习手记(五):Servlet及HTTP派发过程之二》(http://blog.csdn.net/suen/archive/2009/11/02/4759398.aspx)。
Response
TheResponseistheprocessingofwhatissentbacktotheuseraftertheirrequest.Theformatofthisrsponse,foragetFeaturerequest,isGML.
Hereisanoverviewoftheprocessinpictureformat:
WhereitStarts
Attheverybeginning,inWfsDispatcher,anHttpServeletResponseispassedintodoGet()anddoPost()
Letsreferbacktothisdiagram:
ThisresponseobjectispassedintotheFeatureservelet,soitcanbepopulatedonceithasaholdofaFeatureReader.
OutputStrategyObject
TheoutputstrategyobjecttellsGeoserverhowtoproceedewhenreturningthedata.Whatdoesthismean?Herearesomeexamplesthatarespecifiedintheweb.xmlfiletohelpexplainit:
WhyisitcalledStrategy?AStrategyisadesignpatternthatisdefinedintheGangofFourDesignPatternsbook(ISBN0201633612).Whatitessentiallydoes,isallowtheusertoplugintheirownmethodofperformingaspecifictask.SowhatGeoserverdoesisreadtheweb.xmlfile,seewhatstrategyyouwanttouse('speed'inourexample),andplugitintotheoutputresponseprocess.
Youcandefineyourownoutputstrategyobjectbylookinginorg.vfny.geoserver.servlets.AbstractService.Itmustimplementorg.vfny.geoserver.servlets.AbstractService.ServiceStrategy
Hereisatutorialonsettingupyourownoutputstrategy.
FeatureStreaming
ItsveryimportanttonotethattheGeoserver/GeotoolsdesignallowsforFeatureStreaming,meaningthatGeoserveronlyeverhasaroundonefeatureinmemoryatatime.Thisisveryimportantforlargequeries(oryou'drunoutofmemory)aswellassimutaneouslydoingmultiplequeries.
WhenaDataStoreacceptsaQuery,itdoesntactuallyreturnFeatures,insteaditreturnsaFeatureReaderwhichcanbeusedtoreadtheFeaturethattheQueryselectsone-at-a-time.Thedelegate(ie.GML2producerinourexample)readsasinglefeature,convertsittoGML2andsendtheresultsofftotheoutputStrategyobject.
GMLEncoding
Aftertheoutputstrategyhasbeendetermined,theFeaturesendstheoutputtoaFeatureResponseobject.ThisfeatureresponseobjectwillthenpassontheinformationtotheGML2FeatureResponseDelegateobject.
TheGMLencodingobjectwilltakecareoftherestoftheoutputforyouthatwillbestreamedthroughtheoutputstrategy.
TheEnd
Notes
HowDatastoresprocessQuery&Filter
SomeDataStores(liketheDatabasebackedones)candomostoftheFilterprocessinginthedatabaseusingthedatabase'sindexes.Otherdatastorescando"quick"processingofcertaincomponentsoftheFilter.Forexample,the"normalshapefile"datastorecanquicklydobounding-boxtestsforfeatures.The"indexshapefile"datastore(thatsashapefilewitha.qixspatialindexfile)candospatialsearchingquickly.
Basically,theFilterobjectissenttothedatastorewhichlooksattheFilterandbeaksitintocomponents:
portionsthatthedatastorecanindex(ie.quicklyapproximateasolution)
portionsthatthedatastorecanefficientlycalculate(ie.quicklycalculateasolution)
portionsthatthedatastorecannotefficientlycalculate(thesewillbehandledbyGeotoolsJavacode)
AllthisishandledtransparentlybythedatastoresotheprogrammerjusthastosendaQueryobjectofftotheDataStoreandnothavetoworryabouthowitprocessesit.ThefeaturesreturnedbytheFeatureReaderwillonlybeonesthatpasstheFilterconditions.
LetslooksataPostGISexampleforaQuery'sFilterthatlookslikethis:
(the_geomINTERSECTS)AND(population>1000000)
ThiswillbetranslatedintotheSQLquery:
WHERE
[/code]
粟卫民
保留所有版权。如需转载,请联系作者,并在醒目位置注明出处
接上篇《GeoServer学习手记(五):Servlet及HTTP派发过程之二》(
Response
TheResponseistheprocessingofwhatissentbacktotheuseraftertheirrequest.Theformatofthisrsponse,foragetFeaturerequest,isGML.
Hereisanoverviewoftheprocessinpictureformat:
WhereitStarts
Attheverybeginning,inWfsDispatcher,anHttpServeletResponseispassedintodoGet()anddoPost()
publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)
throwsServletException,IOException
publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)
throwsServletException,IOException
Letsreferbacktothisdiagram:
ThisresponseobjectispassedintotheFeatureservelet,soitcanbepopulatedonceithasaholdofaFeatureReader.
OutputStrategyObject
TheoutputstrategyobjecttellsGeoserverhowtoproceedewhenreturningthedata.Whatdoesthismean?Herearesomeexamplesthatarespecifiedintheweb.xmlfiletohelpexplainit:
serviceStratagy
SPEED
WhyisitcalledStrategy?AStrategyisadesignpatternthatisdefinedintheGangofFourDesignPatternsbook(ISBN0201633612).Whatitessentiallydoes,isallowtheusertoplugintheirownmethodofperformingaspecifictask.SowhatGeoserverdoesisreadtheweb.xmlfile,seewhatstrategyyouwanttouse('speed'inourexample),andplugitintotheoutputresponseprocess.
Youcandefineyourownoutputstrategyobjectbylookinginorg.vfny.geoserver.servlets.AbstractService.Itmustimplementorg.vfny.geoserver.servlets.AbstractService.ServiceStrategy
Hereisa
FeatureStreaming
ItsveryimportanttonotethattheGeoserver/GeotoolsdesignallowsforFeatureStreaming,meaningthatGeoserveronlyeverhasaroundonefeatureinmemoryatatime.Thisisveryimportantforlargequeries(oryou'drunoutofmemory)aswellassimutaneouslydoingmultiplequeries.
WhenaDataStoreacceptsaQuery,itdoesntactuallyreturnFeatures,insteaditreturnsaFeatureReaderwhichcanbeusedtoreadtheFeaturethattheQueryselectsone-at-a-time.Thedelegate(ie.GML2producerinourexample)readsasinglefeature,convertsittoGML2andsendtheresultsofftotheoutputStrategyobject.
GMLEncoding
Aftertheoutputstrategyhasbeendetermined,theFeaturesendstheoutputtoaFeatureResponseobject.ThisfeatureresponseobjectwillthenpassontheinformationtotheGML2FeatureResponseDelegateobject.
TheGMLencodingobjectwilltakecareoftherestoftheoutputforyouthatwillbestreamedthroughtheoutputstrategy.
TheEnd
Notes
HowDatastoresprocessQuery&Filter
SomeDataStores(liketheDatabasebackedones)candomostoftheFilterprocessinginthedatabaseusingthedatabase'sindexes.Otherdatastorescando"quick"processingofcertaincomponentsoftheFilter.Forexample,the"normalshapefile"datastorecanquicklydobounding-boxtestsforfeatures.The"indexshapefile"datastore(thatsashapefilewitha.qixspatialindexfile)candospatialsearchingquickly.
Basically,theFilterobjectissenttothedatastorewhichlooksattheFilterandbeaksitintocomponents:
portionsthatthedatastorecanindex(ie.quicklyapproximateasolution)
portionsthatthedatastorecanefficientlycalculate(ie.quicklycalculateasolution)
portionsthatthedatastorecannotefficientlycalculate(thesewillbehandledbyGeotoolsJavacode)
AllthisishandledtransparentlybythedatastoresotheprogrammerjusthastosendaQueryobjectofftotheDataStoreandnothavetoworryabouthowitprocessesit.ThefeaturesreturnedbytheFeatureReaderwillonlybeonesthatpasstheFilterconditions.
LetslooksataPostGISexampleforaQuery'sFilterthatlookslikethis:
(the_geomINTERSECTS)AND(population>1000000)
ThiswillbetranslatedintotheSQLquery:
SELECT...FROM
相关文章推荐
- GeoServer学习手记(五):Servlet及HTTP派发过程之二
- GeoServer学习手记(四):Servlet及HTTP派发过程之一
- GeoServer学习手记(五):Servlet及HTTP派发过程之二
- GeoServer学习手记(四):Servlet及HTTP派发过程之一
- GeoServer学习手记(六):Servlet及HTTP派发过程之三
- GeoServer学习手记(七):Servlet及HTTP派发过程之四
- GeoServer学习手记(七):Servlet及HTTP派发过程之四
- GeoServer学习手记(八):Servlet及HTTP派发过程之五
- GeoServer学习手记(八):Servlet及HTTP派发过程之五
- GeoServer学习手记(十):一个完整的WMS请求响应过程
- GeoServer学习手记(十):一个完整的WMS请求响应过程
- 我的servlet学习过程(二):tomcat服务器部分
- 系统学习JavaWeb之六别有洞天的Servlet进阶篇HttpServlet
- JavaWeb学习笔记--HttpServletRequest、HttpServletResponse对象常用方法
- GeoServer的Http请求派发过程------GeoServer研究随笔一
- java Web Servlet学习笔记-1 HttpServletQequest对象的学习
- java web开发--Servlet学习之HelloWorld 从部署到开发全过程
- Protocol Buffers学习小记-基于servlet的http RPC实现
- GeoServer学习手记(一):GeoServer概述
- GeoServer学习手记(二):代码下载及在Eclipse中加载